Skip to content

Commit

Permalink
mod: Use errors.As to check for specific error
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Duffney <[email protected]>
  • Loading branch information
duffney committed Oct 30, 2024
1 parent fbac504 commit 96e5d25
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/keymanagementprovider/azurekeyvault/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 96e5d25

Please sign in to comment.