From 63d938d9a4bf327aae69dc142d07d51ff583dc45 Mon Sep 17 00:00:00 2001 From: Nils Hanke Date: Wed, 22 Mar 2023 16:53:01 +0100 Subject: [PATCH] cli: improve error handling for validator --- cli/internal/cloudcmd/validators.go | 2 +- cli/internal/cmd/init.go | 2 +- cli/internal/cmd/recover.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/internal/cloudcmd/validators.go b/cli/internal/cloudcmd/validators.go index 0450fed71..68796a825 100644 --- a/cli/internal/cloudcmd/validators.go +++ b/cli/internal/cloudcmd/validators.go @@ -42,7 +42,7 @@ func UpdateInitMeasurements(config config.AttestationCfg, ownerID, clusterID str // the current implementation does not support it, but can be changed if we decide to add support in the future return updateMeasurementTDX(m, uint32(measurements.TDXIndexClusterID), clusterID) default: - return fmt.Errorf("UpdateInitMeasurements: unknown attestation variant") + return fmt.Errorf("selecting attestation variant: unknown attestation variant") } } diff --git a/cli/internal/cmd/init.go b/cli/internal/cmd/init.go index 4c565cc22..161aa9da6 100644 --- a/cli/internal/cmd/init.go +++ b/cli/internal/cmd/init.go @@ -144,7 +144,7 @@ func (i *initCmd) initialize(cmd *cobra.Command, newDialer func(validator atls.V i.log.Debugf("Creating aTLS Validator for %s", conf.GetAttestationConfig().GetVariant()) validator, err := cloudcmd.NewValidator(cmd, conf.GetAttestationConfig(), i.log) if err != nil { - return err + return fmt.Errorf("creating new validator: %w", err) } i.log.Debugf("Created a new validator") serviceAccURI, err := i.getMarshaledServiceAccountURI(provider, conf, fileHandler) diff --git a/cli/internal/cmd/recover.go b/cli/internal/cmd/recover.go index ad48b03c2..b90b1c5be 100644 --- a/cli/internal/cmd/recover.go +++ b/cli/internal/cmd/recover.go @@ -101,7 +101,7 @@ func (r *recoverCmd) recover( r.log.Debugf("Creating aTLS Validator for %s", conf.GetAttestationConfig().GetVariant()) validator, err := cloudcmd.NewValidator(cmd, conf.GetAttestationConfig(), r.log) if err != nil { - return err + return fmt.Errorf("creating new validator: %w", err) } r.log.Debugf("Created a new validator") doer.setDialer(newDialer(validator), flags.endpoint)