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 d4b897c commit ee24eb7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/cloud/services/eks/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ import (
"sigs.k8s.io/cluster-api/controllers/remote"
)

const (
// 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"
)

func (s *Service) reconcileOIDCProvider(cluster *eks.Cluster) error {
if !s.scope.ControlPlane.Spec.AssociateOIDCProvider {
return nil
Expand Down Expand Up @@ -141,7 +148,7 @@ func (s *Service) reconcileTrustPolicy() error {

func (s *Service) deleteOIDCProvider() error {
annotations := s.scope.ControlPlane.GetAnnotations()
arn := annotations["aws.spectrocloud.com/oidcProviderArn"]
arn := annotations[OidcProviderArnAnnotation]

if arn == "" {
arn = s.scope.ControlPlane.Status.OIDCProvider.ARN
Expand All @@ -161,7 +168,7 @@ func (s *Service) deleteOIDCProvider() error {
return errors.Wrap(err, "failed to update control plane with OIDC provider ARN")
}

annotations["aws.spectrocloud.com/oidcProviderArn"] = ""
annotations[OidcProviderArnAnnotation] = ""
s.scope.ControlPlane.SetAnnotations(annotations)

return nil
Expand Down

0 comments on commit ee24eb7

Please sign in to comment.