@@ -615,8 +615,16 @@ func customPreCompare(
615615 // This will ensure controller does not act on this field
616616 // if user is unaware of it.
617617 if a .ko .Spec .ContributorInsights == nil {
618- a . ko . Spec . ContributorInsights = b . ko . Spec . ContributorInsights
618+ return
619619 }
620+ // latestInsight will always be either ENABLED or DISABLED, since we requeue at readOne if its not
621+ // either
622+ desiredInsight , _ := ensureContibutorInsight (a )
623+ latestInsight , _ := ensureContibutorInsight (b )
624+ if desiredInsight != latestInsight {
625+ delta .Add ("Spec.ContributorInsights" , a .ko .Spec .ContributorInsights , b .ko .Spec .ContributorInsights )
626+ }
627+
620628}
621629
622630// equalAttributeDefinitions return whether two AttributeDefinition arrays are equal or not.
@@ -775,19 +783,33 @@ func (rm *resourceManager) setContributorInsights(
775783 return err
776784 }
777785
778- switch resp .ContributorInsightsStatus {
779- case svcsdktypes .ContributorInsightsStatusEnabled :
780- ko .Spec .ContributorInsights = aws .String (string (svcsdktypes .ContributorInsightsActionEnable ))
781- case svcsdktypes .ContributorInsightsStatusDisabled :
782- ko .Spec .ContributorInsights = aws .String (string (svcsdktypes .ContributorInsightsActionDisable ))
783- default :
786+ // Only manage ContributorInsights if it is defined
787+ if ko .Spec .ContributorInsights != nil {
784788 ko .Spec .ContributorInsights = aws .String (string (resp .ContributorInsightsStatus ))
785-
786789 }
787790
788791 return nil
789792}
790793
794+ // ensureContibutorInsight ensures the controller understands ENABLE and ENABLED are the same.
795+ // We choose to return ContributorInsightsAction because that is the enum used to update.
796+ func ensureContibutorInsight (r * resource ) (svcsdktypes.ContributorInsightsAction , error ) {
797+ insight := svcsdktypes .ContributorInsightsActionDisable
798+ if r .ko .Spec .ContributorInsights != nil {
799+ // We will allow users to provide values ENABLE, ENABLED, DISABLE, DISABLED
800+ switch * r .ko .Spec .ContributorInsights {
801+ case string (svcsdktypes .ContributorInsightsActionEnable ), string (svcsdktypes .ContributorInsightsStatusEnabled ):
802+ insight = svcsdktypes .ContributorInsightsActionEnable
803+ case string (svcsdktypes .ContributorInsightsActionDisable ), string (svcsdktypes .ContributorInsightsStatusDisabled ):
804+ insight = svcsdktypes .ContributorInsightsActionDisable
805+ default :
806+ return "" , fmt .Errorf ("invalid ContributorInsights value: %s" , * r .ko .Spec .ContributorInsights )
807+ }
808+ }
809+
810+ return insight , nil
811+ }
812+
791813func (rm * resourceManager ) updateContributorInsights (
792814 ctx context.Context ,
793815 r * resource ,
@@ -797,9 +819,10 @@ func (rm *resourceManager) updateContributorInsights(
797819 defer func () {
798820 exit (err )
799821 }()
800- insight := svcsdktypes .ContributorInsightsActionDisable
801- if r .ko .Spec .ContributorInsights != nil {
802- insight = svcsdktypes .ContributorInsightsAction (* r .ko .Spec .ContributorInsights )
822+
823+ insight , err := ensureContibutorInsight (r )
824+ if err != nil {
825+ return fmt .Errorf ("failed preparing contributorInsight: %v" , err )
803826 }
804827
805828 _ , err = rm .sdkapi .UpdateContributorInsights (
0 commit comments