@@ -19,14 +19,11 @@ package v1beta2
19
19
import (
20
20
"time"
21
21
22
+ "github.com/fluxcd/pkg/apis/kustomize"
23
+ "github.com/fluxcd/pkg/apis/meta"
22
24
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
23
25
apimeta "k8s.io/apimachinery/pkg/api/meta"
24
26
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25
- "k8s.io/apimachinery/pkg/types"
26
-
27
- "github.com/fluxcd/pkg/apis/kustomize"
28
- "github.com/fluxcd/pkg/apis/meta"
29
- "github.com/fluxcd/pkg/runtime/dependency"
30
27
)
31
28
32
29
const (
@@ -39,11 +36,11 @@ const (
39
36
40
37
// KustomizationSpec defines the configuration to calculate the desired state from a Source using Kustomize.
41
38
type KustomizationSpec struct {
42
- // DependsOn may contain a dependency.CrossNamespaceDependencyReference slice
39
+ // DependsOn may contain a meta.NamespacedObjectReference slice
43
40
// with references to Kustomization resources that must be ready before this
44
41
// Kustomization can be reconciled.
45
42
// +optional
46
- DependsOn []dependency. CrossNamespaceDependencyReference `json:"dependsOn,omitempty"`
43
+ DependsOn []meta. NamespacedObjectReference `json:"dependsOn,omitempty"`
47
44
48
45
// Decrypt Kubernetes secrets before applying them on the cluster.
49
46
// +optional
@@ -245,7 +242,13 @@ type KustomizationStatus struct {
245
242
// KustomizationProgressing resets the conditions of the given Kustomization to a single
246
243
// ReadyCondition with status ConditionUnknown.
247
244
func KustomizationProgressing (k Kustomization , message string ) Kustomization {
248
- meta .SetResourceCondition (& k , meta .ReadyCondition , metav1 .ConditionUnknown , meta .ProgressingReason , message )
245
+ newCondition := metav1.Condition {
246
+ Type : meta .ReadyCondition ,
247
+ Status : metav1 .ConditionUnknown ,
248
+ Reason : meta .ProgressingReason ,
249
+ Message : trimString (message , MaxConditionMessageLength ),
250
+ }
251
+ apimeta .SetStatusCondition (k .GetStatusConditions (), newCondition )
249
252
return k
250
253
}
251
254
@@ -254,14 +257,27 @@ func SetKustomizationHealthiness(k *Kustomization, status metav1.ConditionStatus
254
257
if ! k .Spec .Wait && len (k .Spec .HealthChecks ) == 0 {
255
258
apimeta .RemoveStatusCondition (k .GetStatusConditions (), HealthyCondition )
256
259
} else {
257
- meta .SetResourceCondition (k , HealthyCondition , status , reason , trimString (message , MaxConditionMessageLength ))
260
+ newCondition := metav1.Condition {
261
+ Type : HealthyCondition ,
262
+ Status : status ,
263
+ Reason : reason ,
264
+ Message : trimString (message , MaxConditionMessageLength ),
265
+ }
266
+ apimeta .SetStatusCondition (k .GetStatusConditions (), newCondition )
258
267
}
259
268
260
269
}
261
270
262
271
// SetKustomizationReadiness sets the ReadyCondition, ObservedGeneration, and LastAttemptedRevision, on the Kustomization.
263
272
func SetKustomizationReadiness (k * Kustomization , status metav1.ConditionStatus , reason , message string , revision string ) {
264
- meta .SetResourceCondition (k , meta .ReadyCondition , status , reason , trimString (message , MaxConditionMessageLength ))
273
+ newCondition := metav1.Condition {
274
+ Type : meta .ReadyCondition ,
275
+ Status : status ,
276
+ Reason : reason ,
277
+ Message : trimString (message , MaxConditionMessageLength ),
278
+ }
279
+ apimeta .SetStatusCondition (k .GetStatusConditions (), newCondition )
280
+
265
281
k .Status .ObservedGeneration = k .Generation
266
282
k .Status .LastAttemptedRevision = revision
267
283
}
@@ -312,18 +328,32 @@ func (in Kustomization) GetRetryInterval() time.Duration {
312
328
if in .Spec .RetryInterval != nil {
313
329
return in .Spec .RetryInterval .Duration
314
330
}
331
+ return in .GetRequeueAfter ()
332
+ }
333
+
334
+ // GetRequeueAfter returns the duration after which the Kustomization must be
335
+ // reconciled again.
336
+ func (in Kustomization ) GetRequeueAfter () time.Duration {
315
337
return in .Spec .Interval .Duration
316
338
}
317
339
318
340
// GetDependsOn returns the list of dependencies across-namespaces.
319
- func (in Kustomization ) GetDependsOn () (types.NamespacedName , []dependency.CrossNamespaceDependencyReference ) {
320
- return types.NamespacedName {
321
- Namespace : in .Namespace ,
322
- Name : in .Name ,
323
- }, in .Spec .DependsOn
341
+ func (in Kustomization ) GetDependsOn () []meta.NamespacedObjectReference {
342
+ return in .Spec .DependsOn
343
+ }
344
+
345
+ // GetConditions returns the status conditions of the object.
346
+ func (in Kustomization ) GetConditions () []metav1.Condition {
347
+ return in .Status .Conditions
348
+ }
349
+
350
+ // SetConditions sets the status conditions on the object.
351
+ func (in * Kustomization ) SetConditions (conditions []metav1.Condition ) {
352
+ in .Status .Conditions = conditions
324
353
}
325
354
326
355
// GetStatusConditions returns a pointer to the Status.Conditions slice.
356
+ // Deprecated: use GetConditions instead.
327
357
func (in * Kustomization ) GetStatusConditions () * []metav1.Condition {
328
358
return & in .Status .Conditions
329
359
}
0 commit comments