@@ -28,25 +28,35 @@ const (
2828 ClusterAddonFinalizer = "clusteraddon.clusterstack.x-k8s.io"
2929)
3030
31+ // StageAnnotation is the annotation name and key for the stage annotation.
3132const StageAnnotation = "ClusterAddonStage"
3233
34+ // StageAnnotationValue is the value of the stage annotation.
3335type StageAnnotationValue string
3436
3537const (
36- StageCreated = StageAnnotationValue ("created" )
37- StageUpgraded = StageAnnotationValue ("upgraded" )
38+ // StageAnnotationValueCreated signifies the stage annotation created.
39+ StageAnnotationValueCreated = StageAnnotationValue ("created" )
40+ // StageAnnotationValueUpgraded signifies the stage annotation upgraded.
41+ StageAnnotationValueUpgraded = StageAnnotationValue ("upgraded" )
3842)
3943
4044// StagePhase defines the status of helm chart in the cluster addon.
4145type StagePhase string
4246
4347var (
44- None = StagePhase ("" )
45- Pending = StagePhase ("Pending" )
46- WaitingForPreCondition = StagePhase ("waitingForPreCondition" )
47- ApplyingOrDeleting = StagePhase ("applyingOrDeleting" )
48- WaitingForPostCondition = StagePhase ("waitingForPostCondition" )
49- Done = StagePhase ("done" )
48+ // StagePhaseNone signifies the empty stage phase.
49+ StagePhaseNone = StagePhase ("" )
50+ // StagePhasePending signifies the stage phase 'pending'.
51+ StagePhasePending = StagePhase ("Pending" )
52+ // StagePhaseWaitingForPreCondition signifies the stage phase 'waitingForPreCondition'.
53+ StagePhaseWaitingForPreCondition = StagePhase ("waitingForPreCondition" )
54+ // StagePhaseApplyingOrDeleting signifies the stage phase 'applyingOrDeleting'.
55+ StagePhaseApplyingOrDeleting = StagePhase ("applyingOrDeleting" )
56+ // StagePhaseWaitingForPostCondition signifies the stage phase 'waitingForPostCondition'.
57+ StagePhaseWaitingForPostCondition = StagePhase ("waitingForPostCondition" )
58+ // StagePhaseDone signifies the stage phase 'done'.
59+ StagePhaseDone = StagePhase ("done" )
5060)
5161
5262// StageStatus represents the helm charts of the hook and it's phases.
@@ -131,18 +141,19 @@ func (r *ClusterAddon) GetStagePhase(helmChartName string, action clusteraddon.A
131141 }
132142
133143 // This cannot occur as we populate phase value with "pending".
134- return None
144+ return StagePhaseNone
135145}
136146
137147// SetStagePhase sets the helm chart status phase.
138148func (r * ClusterAddon ) SetStagePhase (helmChartName string , action clusteraddon.Action , phase StagePhase ) {
139- for i , _ := range r .Status .Stages {
149+ for i := range r .Status .Stages {
140150 if r .Status .Stages [i ].Name == helmChartName && r .Status .Stages [i ].Action == action {
141151 r .Status .Stages [i ].Phase = phase
142152 }
143153 }
144154}
145155
156+ // SetStageAnnotations sets the annotation whether the cluster got created or upgraded.
146157func (r * ClusterAddon ) SetStageAnnotations (value StageAnnotationValue ) {
147158 if r .Annotations == nil {
148159 r .Annotations = make (map [string ]string , 0 )
@@ -153,7 +164,7 @@ func (r *ClusterAddon) SetStageAnnotations(value StageAnnotationValue) {
153164 }
154165}
155166
156- // HasAnnotation returns a bool if passed in annotation exists.
167+ // HasStageAnnotation returns whether the stage annotation exists with a certain value .
157168func (r * ClusterAddon ) HasStageAnnotation (value StageAnnotationValue ) bool {
158169 val , found := r .Annotations [StageAnnotation ]
159170 if found && val == string (value ) {
0 commit comments