Skip to content

Commit 69f9bbd

Browse files
committed
Use SetStatusCondition vs FilterOutCondition
Change to rely on the upstream k8s api/meta SetStatusCondition to set/update the resources status conditions rather than FilterOutCondition from apis/meta which is due to be removed. Signed-off-by: Aurel Canciu <[email protected]>
1 parent 00bb853 commit 69f9bbd

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

api/v1beta1/bucket_types.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,19 @@ func BucketProgressing(bucket Bucket) Bucket {
120120

121121
// SetBucketCondition sets the given condition with the given status, reason and
122122
// message on the Bucket.
123-
func SetBucketCondition(bucket *Bucket, conditionType string, status metav1.ConditionStatus, reason, message string) {
124-
bucket.Status.Conditions = meta.FilterOutCondition(bucket.Status.Conditions, conditionType)
125-
bucket.Status.Conditions = append(bucket.Status.Conditions, metav1.Condition{
126-
Type: conditionType,
123+
func SetBucketCondition(bucket *Bucket, condition string, status metav1.ConditionStatus, reason, message string) {
124+
conditions := &bucket.Status.Conditions
125+
generation := bucket.GetGeneration()
126+
newCondition := metav1.Condition{
127+
Type: condition,
127128
Status: status,
128129
LastTransitionTime: metav1.Now(),
129130
Reason: reason,
130131
Message: message,
131-
})
132+
ObservedGeneration: generation,
133+
}
134+
135+
apimeta.SetStatusCondition(conditions, newCondition)
132136
}
133137

134138
// BucketReady sets the given Artifact and URL on the Bucket and sets the

api/v1beta1/gitrepository_types.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,18 @@ func GitRepositoryProgressing(repository GitRepository) GitRepository {
143143
// SetGitRepositoryCondition sets the given condition with the given status,
144144
// reason and message on the GitRepository.
145145
func SetGitRepositoryCondition(repository *GitRepository, condition string, status metav1.ConditionStatus, reason, message string) {
146-
repository.Status.Conditions = meta.FilterOutCondition(repository.Status.Conditions, condition)
147-
repository.Status.Conditions = append(repository.Status.Conditions, metav1.Condition{
146+
conditions := &repository.Status.Conditions
147+
generation := repository.GetGeneration()
148+
newCondition := metav1.Condition{
148149
Type: condition,
149150
Status: status,
150151
LastTransitionTime: metav1.Now(),
151152
Reason: reason,
152153
Message: message,
153-
})
154+
ObservedGeneration: generation,
155+
}
156+
157+
apimeta.SetStatusCondition(conditions, newCondition)
154158
}
155159

156160
// GitRepositoryReady sets the given Artifact and URL on the GitRepository and

api/v1beta1/helmchart_types.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,18 @@ func HelmChartProgressing(chart HelmChart) HelmChart {
120120
// SetHelmChartCondition sets the given condition with the given status, reason
121121
// and message on the HelmChart.
122122
func SetHelmChartCondition(chart *HelmChart, condition string, status metav1.ConditionStatus, reason, message string) {
123-
chart.Status.Conditions = meta.FilterOutCondition(chart.Status.Conditions, condition)
124-
chart.Status.Conditions = append(chart.Status.Conditions, metav1.Condition{
123+
conditions := &chart.Status.Conditions
124+
generation := chart.GetGeneration()
125+
newCondition := metav1.Condition{
125126
Type: condition,
126127
Status: status,
127128
LastTransitionTime: metav1.Now(),
128129
Reason: reason,
129130
Message: message,
130-
})
131+
ObservedGeneration: generation,
132+
}
133+
134+
apimeta.SetStatusCondition(conditions, newCondition)
131135
}
132136

133137
// HelmChartReady sets the given Artifact and URL on the HelmChart and sets the

api/v1beta1/helmrepository_types.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,18 @@ func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
100100
// SetHelmRepositoryCondition sets the given condition with the given status,
101101
// reason and message on the HelmRepository.
102102
func SetHelmRepositoryCondition(repository *HelmRepository, condition string, status metav1.ConditionStatus, reason, message string) {
103-
repository.Status.Conditions = meta.FilterOutCondition(repository.Status.Conditions, condition)
104-
repository.Status.Conditions = append(repository.Status.Conditions, metav1.Condition{
103+
conditions := &repository.Status.Conditions
104+
generation := repository.GetGeneration()
105+
newCondition := metav1.Condition{
105106
Type: condition,
106107
Status: status,
107108
LastTransitionTime: metav1.Now(),
108109
Reason: reason,
109110
Message: message,
110-
})
111+
ObservedGeneration: generation,
112+
}
113+
114+
apimeta.SetStatusCondition(conditions, newCondition)
111115
}
112116

113117
// HelmRepositoryReady sets the given Artifact and URL on the HelmRepository and

0 commit comments

Comments
 (0)