diff --git a/cmd/gsap-attestor/main.go b/cmd/gsap-attestor/main.go index 726a79f..7598344 100644 --- a/cmd/gsap-attestor/main.go +++ b/cmd/gsap-attestor/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "sync" "github.com/hashicorp/hcl/v2/hclsimple" @@ -41,12 +42,15 @@ func (p *Plugin) Attest(ctx context.Context, req *workloadattestorv1.AttestReque func decodeConfig(data string) (GsapAttestorConfig, error) { var cfg GsapAttestorConfig - if err := hclsimple.Decode("plugin.json", []byte(data), nil, &cfg); err != nil { - if err2 := hclsimple.Decode("plugin.hcl", []byte(data), nil, &cfg); err2 != nil { - return cfg, err2 - } + jsonErr := hclsimple.Decode("plugin.json", []byte(data), nil, &cfg) + if jsonErr == nil { + return cfg, nil } - return cfg, nil + hclErr := hclsimple.Decode("plugin.hcl", []byte(data), nil, &cfg) + if hclErr == nil { + return cfg, nil + } + return cfg, fmt.Errorf("json: %v; hcl: %v; raw input: %q", jsonErr, hclErr, data) } func (p *Plugin) Configure(_ context.Context, req *configv1.ConfigureRequest) (*configv1.ConfigureResponse, error) {