cli: allow manual patch of attestation policy

This commit is contained in:
Malte Poll 2023-07-19 13:27:44 +02:00
parent 46afb07ccf
commit d4c0213f60

View file

@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
package cloudcmd package cloudcmd
import ( import (
"bytes"
"context" "context"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
@ -55,10 +56,13 @@ func (p AzurePolicyPatcher) Patch(ctx context.Context, attestationURL string) er
if err != nil { if err != nil {
return fmt.Errorf("sending request: %w", err) return fmt.Errorf("sending request: %w", err)
} }
resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return fmt.Errorf("updating attestation policy: unexpected status code: %s", resp.Status) buf := new(bytes.Buffer)
_, _ = buf.ReadFrom(resp.Body)
fmt.Printf("updating attestation policy: unexpected status code: %s with message %q", resp.Status, buf.String())
fmt.Println("Patching the attestations policy failed. Please patch the policy manually before continuing to initialize the cluster.")
} }
return nil return nil