From 96e5d258221a075b1ec12c7fae68d865652d05b0 Mon Sep 17 00:00:00 2001 From: Joshua Duffney Date: Wed, 30 Oct 2024 14:50:51 -0500 Subject: [PATCH] mod: Use errors.As to check for specific error Signed-off-by: Joshua Duffney --- pkg/keymanagementprovider/azurekeyvault/provider.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/keymanagementprovider/azurekeyvault/provider.go b/pkg/keymanagementprovider/azurekeyvault/provider.go index 841b4e402..ec9544008 100644 --- a/pkg/keymanagementprovider/azurekeyvault/provider.go +++ b/pkg/keymanagementprovider/azurekeyvault/provider.go @@ -24,6 +24,7 @@ import ( "encoding/base64" "encoding/json" "encoding/pem" + "errors" "fmt" "strconv" "strings" @@ -170,8 +171,10 @@ func (s *akvKMProvider) GetCertificates(ctx context.Context) (map[keymanagementp secretBundle, err := s.kvClient.GetSecret(ctx, s.vaultURI, keyVaultCert.Name, keyVaultCert.Version) if err != nil { // certificate is disabled, remove it from the map - if de, ok := err.(autorest.DetailedError); ok { - if re, ok := de.Original.(*azure.RequestError); ok { + var de autorest.DetailedError + if errors.As(err, &de) { + var re *azure.RequestError + if errors.As(de.Original, &re) { if re.ServiceError.Code == "SecretDisabled" { certBundle, err := s.kvClient.GetCertificate(ctx, s.vaultURI, keyVaultCert.Name, keyVaultCert.Version) if err != nil {