@@ -42,28 +42,47 @@ type SubscriptionConditionType string
42
42
const (
43
43
// SubscriptionCatalogSourcesUnhealthy indicates that some or all of the CatalogSources to be used in resolution are unhealthy.
44
44
SubscriptionCatalogSourcesUnhealthy SubscriptionConditionType = "CatalogSourcesUnhealthy"
45
+
46
+ // SubscriptionInstallPlanMissing indicates that a Subscription's InstallPlan is missing.
47
+ SubscriptionInstallPlanMissing SubscriptionConditionType = "InstallPlanMissing"
48
+
49
+ // SubscriptionInstallPlanPending indicates that a Subscription's InstallPlan is pending installation.
50
+ SubscriptionInstallPlanPending SubscriptionConditionType = "InstallPlanPending"
51
+
52
+ // SubscriptionInstallPlanFailed indicates that the installation of a Subscription's InstallPlan has failed.
53
+ SubscriptionInstallPlanFailed SubscriptionConditionType = "InstallPlanFailed"
45
54
)
46
55
47
56
const (
48
57
// NoCatalogSourcesFound is a reason string for Subscriptions with unhealthy CatalogSources due to none being available.
49
58
NoCatalogSourcesFound = "NoCatalogSourcesFound"
50
59
51
- // AllCatalogSourcesHealthy is a reason string for Subscriptions whose CatalogSources are all healthy.
60
+ // AllCatalogSourcesHealthy is a reason string for Subscriptions that transitioned due to all CatalogSources being healthy.
52
61
AllCatalogSourcesHealthy = "AllCatalogSourcesHealthy"
53
62
54
63
// CatalogSourcesAdded is a reason string for Subscriptions that transitioned due to CatalogSources being added.
55
64
CatalogSourcesAdded = "CatalogSourcesAdded"
56
65
57
- // CatalogSourcesUpdated is a reason string for Subscriptions that transitioned due to CatalogSource being updated..
66
+ // CatalogSourcesUpdated is a reason string for Subscriptions that transitioned due to CatalogSource being updated.
58
67
CatalogSourcesUpdated = "CatalogSourcesUpdated"
59
68
60
69
// CatalogSourcesDeleted is a reason string for Subscriptions that transitioned due to CatalogSources being removed.
61
70
CatalogSourcesDeleted = "CatalogSourcesDeleted"
62
71
63
72
// UnhealthyCatalogSourceFound is a reason string for Subscriptions that transitioned because an unhealthy CatalogSource was found.
64
73
UnhealthyCatalogSourceFound = "UnhealthyCatalogSourceFound"
74
+
75
+ // ReferencedInstallPlanNotFound is a reason string for Subscriptions that transitioned due to a referenced InstallPlan not being found.
76
+ ReferencedInstallPlanNotFound = "ReferencedInstallPlanNotFound"
77
+
78
+ // InstallPlanNotYetReconciled is a reason string for Subscriptions that transitioned due to a referenced InstallPlan not being reconciled yet.
79
+ InstallPlanNotYetReconciled = "InstallPlanNotYetReconciled"
80
+
81
+ // InstallPlanFailed is a reason string for Subscriptions that transitioned due to a referenced InstallPlan failing without setting an explicit failure condition.
82
+ InstallPlanFailed = "InstallPlanFailed"
65
83
)
66
84
85
+ // SubscriptionCondition represents the latest available observations of a Subscription's state.
67
86
type SubscriptionCondition struct {
68
87
// Type is the type of Subscription condition.
69
88
Type SubscriptionConditionType
@@ -127,16 +146,16 @@ type SubscriptionStatus struct {
127
146
128
147
// Conditions is a list of the latest available observations about a Subscription's current state.
129
148
// +optional
130
- Conditions []SubscriptionCondition
149
+ Conditions []SubscriptionCondition `hash:"set"`
131
150
132
151
// LastUpdated represents the last time that the Subscription status was updated.
133
152
LastUpdated metav1.Time
134
153
}
135
154
136
155
// GetCondition returns the SubscriptionCondition of the given type if it exists in the SubscriptionStatus' Conditions.
137
156
// Returns a condition of the given type with a ConditionStatus of "Unknown" if not found.
138
- func (status SubscriptionStatus ) GetCondition (conditionType SubscriptionConditionType ) SubscriptionCondition {
139
- for _ , cond := range status .Conditions {
157
+ func (s SubscriptionStatus ) GetCondition (conditionType SubscriptionConditionType ) SubscriptionCondition {
158
+ for _ , cond := range s .Conditions {
140
159
if cond .Type == conditionType {
141
160
return cond
142
161
}
@@ -149,15 +168,34 @@ func (status SubscriptionStatus) GetCondition(conditionType SubscriptionConditio
149
168
}
150
169
151
170
// SetCondition sets the given SubscriptionCondition in the SubscriptionStatus' Conditions.
152
- func (status * SubscriptionStatus ) SetCondition (condition SubscriptionCondition ) {
153
- for i , cond := range status .Conditions {
171
+ func (s * SubscriptionStatus ) SetCondition (condition SubscriptionCondition ) {
172
+ for i , cond := range s .Conditions {
154
173
if cond .Type == condition .Type {
155
- status .Conditions [i ] = condition
174
+ s .Conditions [i ] = condition
156
175
return
157
176
}
158
177
}
159
178
160
- status .Conditions = append (status .Conditions , condition )
179
+ s .Conditions = append (s .Conditions , condition )
180
+ }
181
+
182
+ // RemoveConditions removes any conditions of the given types from the SubscriptionStatus' Conditions.
183
+ func (s * SubscriptionStatus ) RemoveConditions (remove ... SubscriptionConditionType ) {
184
+ exclusions := map [SubscriptionConditionType ]struct {}{}
185
+ for _ , r := range remove {
186
+ exclusions [r ] = struct {}{}
187
+ }
188
+
189
+ var filtered []SubscriptionCondition
190
+ for _ , cond := range s .Conditions {
191
+ if _ , ok := exclusions [cond .Type ]; ok {
192
+ // Skip excluded condition types
193
+ continue
194
+ }
195
+ filtered = append (filtered , cond )
196
+ }
197
+
198
+ s .Conditions = filtered
161
199
}
162
200
163
201
type InstallPlanReference struct {
0 commit comments