Skip to content

Commit

Permalink
chore: stop printing out error stack trace (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
binbin-li authored Aug 20, 2024
1 parent f495934 commit be3adc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/certificateprovider/azurekeyvault/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *akvCertProvider) GetCertificates(ctx context.Context, attrib map[string
}

if len(keyVaultCerts) == 0 {
return nil, nil, re.ErrorCodeConfigInvalid.NewError(re.CertProvider, providerName, re.EmptyLink, nil, "no keyvault certificate configured", re.PrintStackTrace)
return nil, nil, re.ErrorCodeConfigInvalid.NewError(re.CertProvider, providerName, re.EmptyLink, nil, "no keyvault certificate configured", re.HideStackTrace)
}

logger.GetLogger(ctx, logOpt).Debugf("vaultURI %s", keyvaultURI)
Expand Down Expand Up @@ -155,7 +155,7 @@ func getKeyvaultRequestObj(ctx context.Context, attrib map[string]string) ([]typ
for i, object := range objects.Array {
var keyVaultCert types.KeyVaultCertificate
if err = yaml.Unmarshal([]byte(object), &keyVaultCert); err != nil {
return nil, re.ErrorCodeDataDecodingFailure.NewError(re.CertProvider, providerName, re.EmptyLink, err, fmt.Sprintf("unmarshal failed for keyVaultCerts at index: %d", i), re.PrintStackTrace)
return nil, re.ErrorCodeDataDecodingFailure.NewError(re.CertProvider, providerName, re.EmptyLink, err, fmt.Sprintf("unmarshal failed for keyVaultCerts at index: %d", i), re.HideStackTrace)
}
// remove whitespace from all fields in keyVaultCert
formatKeyVaultCertificate(&keyVaultCert)
Expand Down Expand Up @@ -213,12 +213,12 @@ func initializeKvClient(ctx context.Context, keyVaultEndpoint, tenantID, clientI

err := kvClient.AddToUserAgent("ratify")
if err != nil {
return nil, re.ErrorCodeConfigInvalid.NewError(re.CertProvider, providerName, re.AKVLink, err, "failed to add user agent to keyvault client", re.PrintStackTrace)
return nil, re.ErrorCodeConfigInvalid.NewError(re.CertProvider, providerName, re.AKVLink, err, "failed to add user agent to keyvault client", re.HideStackTrace)
}

kvClient.Authorizer, err = getAuthorizerForWorkloadIdentity(ctx, tenantID, clientID, kvEndpoint)
if err != nil {
return nil, re.ErrorCodeAuthDenied.NewError(re.CertProvider, providerName, re.AKVLink, err, "failed to get authorizer for keyvault client", re.PrintStackTrace)
return nil, re.ErrorCodeAuthDenied.NewError(re.CertProvider, providerName, re.AKVLink, err, "failed to get authorizer for keyvault client", re.HideStackTrace)
}
return &kvClient, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/keymanagementprovider/azurekeyvault/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ func initializeKvClient(ctx context.Context, keyVaultEndpoint, tenantID, clientI

err := kvClient.AddToUserAgent("ratify")
if err != nil {
return nil, re.ErrorCodeConfigInvalid.NewError(re.KeyManagementProvider, ProviderName, re.AKVLink, err, "failed to add user agent to keyvault client", re.PrintStackTrace)
return nil, re.ErrorCodeConfigInvalid.NewError(re.KeyManagementProvider, ProviderName, re.AKVLink, err, "failed to add user agent to keyvault client", re.HideStackTrace)
}

kvClient.Authorizer, err = getAuthorizerForWorkloadIdentity(ctx, tenantID, clientID, kvEndpoint)
if err != nil {
return nil, re.ErrorCodeAuthDenied.NewError(re.KeyManagementProvider, ProviderName, re.AKVLink, err, "failed to get authorizer for keyvault client", re.PrintStackTrace)
return nil, re.ErrorCodeAuthDenied.NewError(re.KeyManagementProvider, ProviderName, re.AKVLink, err, "failed to get authorizer for keyvault client", re.HideStackTrace)
}
return &kvClient, nil
}
Expand Down

0 comments on commit be3adc1

Please sign in to comment.