Skip to content

Commit

Permalink
optimized the code to reduce the no. of api calls made
Browse files Browse the repository at this point in the history
  • Loading branch information
schiruma committed Sep 13, 2023
1 parent a0c35bb commit 8af04f1
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions pkg/frontend/encryptionathost_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ func (e encryptionAtHostValidator) ValidateEncryptionAtHost(ctx context.Context,
}

func validateEncryptionAtHost(ctx context.Context, subFeatureRegistrationsClient features.SubscriptionFeatureRegistrationsClient, oc *api.OpenShiftCluster) error {
encryptionSettings := make(map[api.EncryptionAtHost]bool)

encryptionSettings[oc.Properties.MasterProfile.EncryptionAtHost] = true

for _, wp := range oc.Properties.WorkerProfiles {
encryptionSettings[wp.EncryptionAtHost] = true
var hasEncryptionAtHostEnabled bool
profilesToCheck := append([]api.WorkerProfile{{EncryptionAtHost: oc.Properties.MasterProfile.EncryptionAtHost}}, oc.Properties.WorkerProfiles...)
for _, profile := range profilesToCheck {
if profile.EncryptionAtHost == api.EncryptionAtHostEnabled {
hasEncryptionAtHostEnabled = true
break
}
}

for setting := range encryptionSettings {
if setting == api.EncryptionAtHostEnabled {
if err := IsRegisteredForEncryptionAtHostFeature(ctx, subFeatureRegistrationsClient); err != nil {
return err
}
if hasEncryptionAtHostEnabled {
err := IsRegisteredForEncryptionAtHostFeature(ctx, subFeatureRegistrationsClient)
if err != nil {
return err
}
}

Expand Down

0 comments on commit 8af04f1

Please sign in to comment.