mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-04-20 23:36:29 -04:00
cli: return a more helpful error message on maa patch failure
This commit is contained in:
parent
2c03a16a68
commit
887587ba62
@ -9,6 +9,7 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/profiles/latest/attestation/attestation"
|
||||
@ -55,10 +56,14 @@ func (p AzurePolicyPatcher) Patch(ctx context.Context, attestationURL string) er
|
||||
if err != nil {
|
||||
return fmt.Errorf("sending request: %w", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("updating attestation policy: unexpected status code: %s", resp.Status)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("updating attestation policy: unexpected status code: %s\nread response body: %w", resp.Status, err)
|
||||
}
|
||||
return fmt.Errorf("updating attestation policy: unexpected status code: %s\nresponse body: %s", resp.Status, string(body))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user