Skip to content

Commit 6b22f03

Browse files
committed
chore: Ensure controller understands both ENABLE & ENABLED contributorInsights
1 parent 732e683 commit 6b22f03

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Diff for: pkg/resource/table/hooks.go

+22-2
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,18 @@ func (rm *resourceManager) setContributorInsights(
774774
if err != nil {
775775
return err
776776
}
777-
777+
778+
// This portion is needed if we want to have a smooth delta comparison
779+
// If the name ends in ED (ENABLED, DISABLED) just assign the value
780+
endsWithED := false
781+
if ko.Spec.ContributorInsights != nil {
782+
endsWithED = strings.HasSuffix(*ko.Spec.TableName, "ED")
783+
}
784+
if endsWithED {
785+
ko.Spec.ContributorInsights = aws.String(string(resp.ContributorInsightsStatus))
786+
return nil
787+
}
788+
// if not do the conversion
778789
switch resp.ContributorInsightsStatus {
779790
case svcsdktypes.ContributorInsightsStatusEnabled:
780791
ko.Spec.ContributorInsights = aws.String(string(svcsdktypes.ContributorInsightsActionEnable))
@@ -797,9 +808,18 @@ func (rm *resourceManager) updateContributorInsights(
797808
defer func() {
798809
exit(err)
799810
}()
811+
800812
insight := svcsdktypes.ContributorInsightsActionDisable
801813
if r.ko.Spec.ContributorInsights != nil {
802-
insight = svcsdktypes.ContributorInsightsAction(*r.ko.Spec.ContributorInsights)
814+
// We will allow users to provide values ENABLE, ENABLED, DISABLE, DISABLED
815+
switch *r.ko.Spec.ContributorInsights {
816+
case string(svcsdktypes.ContributorInsightsActionEnable), string(svcsdktypes.ContributorInsightsStatusEnabled):
817+
insight = svcsdktypes.ContributorInsightsActionEnable
818+
case string(svcsdktypes.ContributorInsightsActionDisable), string(svcsdktypes.ContributorInsightsStatusDisabled):
819+
insight = svcsdktypes.ContributorInsightsActionDisable
820+
default:
821+
return fmt.Errorf("invalid ContributorInsights value: %s", *r.ko.Spec.ContributorInsights)
822+
}
803823
}
804824

805825
_, err = rm.sdkapi.UpdateContributorInsights(

0 commit comments

Comments
 (0)