Skip to content

Commit

Permalink
fix: account matching issue in account search
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
andyzhangx committed Jan 8, 2023
1 parent 3f197cb commit bc5ada1
Show file tree
Hide file tree
Showing 2 changed files with 380 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/provider/azure_storageaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (az *Cloud) getStorageAccounts(ctx context.Context, accountOptions *Account
isTaggedWithSkip(acct) &&
isHnsPropertyEqual(acct, accountOptions) &&
isEnableNfsV3PropertyEqual(acct, accountOptions) &&
isAllowBlobPublicAccessEqual(acct, accountOptions) &&
isRequireInfrastructureEncryptionEqual(acct, accountOptions) &&
isAllowSharedKeyAccessEqual(acct, accountOptions) &&
isPrivateEndpointAsExpected(acct, accountOptions)) {
continue
}
Expand Down Expand Up @@ -627,10 +630,16 @@ func isTagsEqual(account storage.Account, accountOptions *AccountOptions) bool {
}

func isHnsPropertyEqual(account storage.Account, accountOptions *AccountOptions) bool {
if accountOptions.IsHnsEnabled == nil {
return true
}
return pointer.BoolDeref(account.IsHnsEnabled, false) == pointer.BoolDeref(accountOptions.IsHnsEnabled, false)
}

func isEnableNfsV3PropertyEqual(account storage.Account, accountOptions *AccountOptions) bool {
if accountOptions.EnableNfsV3 == nil {
return true
}
return pointer.BoolDeref(account.EnableNfsV3, false) == pointer.BoolDeref(accountOptions.EnableNfsV3, false)
}

Expand All @@ -643,3 +652,27 @@ func isPrivateEndpointAsExpected(account storage.Account, accountOptions *Accoun
}
return false
}

func isAllowBlobPublicAccessEqual(account storage.Account, accountOptions *AccountOptions) bool {
if accountOptions.AllowBlobPublicAccess == nil {
return true
}
return pointer.BoolDeref(account.AllowBlobPublicAccess, false) == pointer.BoolDeref(accountOptions.AllowBlobPublicAccess, false)
}

func isRequireInfrastructureEncryptionEqual(account storage.Account, accountOptions *AccountOptions) bool {
if accountOptions.RequireInfrastructureEncryption == nil {
return true
}
if *accountOptions.RequireInfrastructureEncryption {
return account.Encryption != nil && pointer.BoolDeref(account.Encryption.RequireInfrastructureEncryption, false)
}
return account.Encryption == nil || !pointer.BoolDeref(account.Encryption.RequireInfrastructureEncryption, false)
}

func isAllowSharedKeyAccessEqual(account storage.Account, accountOptions *AccountOptions) bool {
if accountOptions.AllowSharedKeyAccess == nil {
return true
}
return pointer.BoolDeref(account.AllowSharedKeyAccess, false) == pointer.BoolDeref(accountOptions.AllowSharedKeyAccess, false)
}

0 comments on commit bc5ada1

Please sign in to comment.