Skip to content

Commit a271abc

Browse files
authored
Merge pull request #756 from application-stacks/warning-status
Create AddStatusWarning helper
2 parents b4479b8 + c6764ba commit a271abc

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

utils/reconciler.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ func (r *ReconcilerBase) SetStatusWarnings(statusWarnings []StatusWarning) {
112112
r.statusWarnings = statusWarnings
113113
}
114114

115+
// Adds a new status warning into the ReconcilerBase or updates one that already exists
116+
func (r *ReconcilerBase) AddStatusWarning(newWarning StatusWarning) {
117+
index := -1
118+
for i, statusWarning := range r.statusWarnings {
119+
if statusWarning.Message == newWarning.Message {
120+
index = i
121+
break
122+
}
123+
}
124+
if index == -1 {
125+
r.statusWarnings = append(r.statusWarnings, newWarning)
126+
} else if index < len(r.statusWarnings) {
127+
r.statusWarnings[index] = newWarning
128+
}
129+
}
130+
115131
// Deletes a status warning from the ReconcilerBase if a status message matches
116132
func (r *ReconcilerBase) DeleteStatusWarning(message string) {
117133
for {

0 commit comments

Comments
 (0)