Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitSahastra committed Mar 27, 2024
1 parent 0545224 commit 7047c04
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/cloud/services/eks/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import (
)

const (
// OidcProviderArnAnnotation set/unset this annotation to managed control plane.
// OIDCProviderARNAnnotation set/unset this annotation to managed control plane.
// This is required in case of force pivot control plane status do not have ARN in status.
// In that cases annotation will be used to delete oidc resource.
OidcProviderArnAnnotation = "aws.spectrocloud.com/oidcProviderArn"
OIDCProviderARNAnnotation = "aws.spectrocloud.com/oidcProviderArn"
)

func (s *Service) reconcileOIDCProvider(cluster *eks.Cluster) error {
Expand All @@ -63,7 +63,7 @@ func (s *Service) reconcileOIDCProvider(cluster *eks.Cluster) error {
if anno == nil {
anno = make(map[string]string)
}
anno[OidcProviderArnAnnotation] = oidcProvider
anno[OIDCProviderARNAnnotation] = oidcProvider
s.scope.ControlPlane.SetAnnotations(anno)
if err := s.scope.PatchObject(); err != nil {
return errors.Wrap(err, "failed to update control plane with OIDC provider ARN")
Expand Down Expand Up @@ -149,13 +149,13 @@ func (s *Service) reconcileTrustPolicy() error {
func (s *Service) deleteOIDCProvider() error {

// In case of force pivot managed control plane do not have ARN in status, that lead to oidcProvider not getting cleaned up during delete.
// OidcProviderArnAnnotation will be used to avoid it.
// OIDCProviderARNAnnotation will be used to avoid it.

annotations := s.scope.ControlPlane.GetAnnotations()
arn := annotations[OidcProviderArnAnnotation]
arn := annotations[OIDCProviderARNAnnotation]

if arn == "" {
// Upgrade support for cluster without OidcProviderArnAnnotation set
// Upgrade support for cluster without OIDCProviderARNAnnotation set
arn = s.scope.ControlPlane.Status.OIDCProvider.ARN
}

Expand All @@ -173,8 +173,8 @@ func (s *Service) deleteOIDCProvider() error {
return errors.Wrap(err, "failed to update control plane with OIDC provider ARN")
}

// Remove OidcProviderArnAnnotation after successfully deleting oidc provider
annotations[OidcProviderArnAnnotation] = ""
// Remove OIDCProviderARNAnnotation after successfully deleting oidc provider
annotations[OIDCProviderARNAnnotation] = ""
s.scope.ControlPlane.SetAnnotations(annotations)

return nil
Expand Down

0 comments on commit 7047c04

Please sign in to comment.