Skip to content

Commit a4dc03e

Browse files
authored
Merge pull request #575 from fluxcd/runtime-meta-rc
2 parents 423cdde + 855d57c commit a4dc03e

31 files changed

+276
-231
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
IMG ?= fluxcd/kustomize-controller:latest
33
# Produce CRDs that work back to Kubernetes 1.16
44
CRD_OPTIONS ?= crd:crdVersions=v1
5-
SOURCE_VER ?= v0.21.2
5+
SOURCE_VER ?= v0.22.0
66

77
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
88
ifeq (,$(shell go env GOBIN))
@@ -84,8 +84,8 @@ api-docs: gen-crd-api-reference-docs
8484

8585
# Run go mod tidy
8686
tidy:
87-
cd api; rm -f go.sum; go mod tidy
88-
rm -f go.sum; go mod tidy
87+
cd api; rm -f go.sum; go mod tidy -compat=1.17
88+
rm -f go.sum; go mod tidy -compat=1.17
8989

9090
# Run go fmt against code
9191
fmt:

api/go.mod

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@ go 1.17
44

55
require (
66
github.com/fluxcd/pkg/apis/kustomize v0.3.1
7-
github.com/fluxcd/pkg/apis/meta v0.10.2
8-
github.com/fluxcd/pkg/runtime v0.12.5
7+
github.com/fluxcd/pkg/apis/meta v0.12.1
98
k8s.io/apiextensions-apiserver v0.23.2
10-
k8s.io/apimachinery v0.23.2
9+
k8s.io/apimachinery v0.23.4
1110
sigs.k8s.io/controller-runtime v0.11.1
1211
)
1312

1413
require (
1514
github.com/go-logr/logr v1.2.2 // indirect
1615
github.com/gogo/protobuf v1.3.2 // indirect
17-
github.com/google/go-cmp v0.5.6 // indirect
16+
github.com/google/go-cmp v0.5.7 // indirect
1817
github.com/google/gofuzz v1.2.0 // indirect
1918
github.com/json-iterator/go v1.1.12 // indirect
2019
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2120
github.com/modern-go/reflect2 v1.0.2 // indirect
21+
github.com/onsi/gomega v1.18.1 // indirect
22+
github.com/stretchr/testify v1.7.1 // indirect
2223
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
24+
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
2325
golang.org/x/text v0.3.7 // indirect
26+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
2427
gopkg.in/inf.v0 v0.9.1 // indirect
2528
gopkg.in/yaml.v2 v2.4.0 // indirect
26-
k8s.io/klog/v2 v2.30.0 // indirect
27-
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect
29+
k8s.io/api v0.23.4 // indirect
30+
k8s.io/klog/v2 v2.50.0 // indirect
31+
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
2832
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
2933
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
3034
sigs.k8s.io/yaml v1.3.0 // indirect

api/go.sum

+26-42
Large diffs are not rendered by default.

api/v1beta1/kustomization_types.go

+25-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727

2828
"github.com/fluxcd/pkg/apis/kustomize"
2929
"github.com/fluxcd/pkg/apis/meta"
30-
"github.com/fluxcd/pkg/runtime/dependency"
3130
)
3231

3332
const (
@@ -39,11 +38,11 @@ const (
3938

4039
// KustomizationSpec defines the desired state of a kustomization.
4140
type KustomizationSpec struct {
42-
// DependsOn may contain a dependency.CrossNamespaceDependencyReference slice
41+
// DependsOn may contain a meta.NamespacedObjectReference slice
4342
// with references to Kustomization resources that must be ready before this
4443
// Kustomization can be reconciled.
4544
// +optional
46-
DependsOn []dependency.CrossNamespaceDependencyReference `json:"dependsOn,omitempty"`
45+
DependsOn []meta.NamespacedObjectReference `json:"dependsOn,omitempty"`
4746

4847
// Decrypt Kubernetes secrets before applying them on the cluster.
4948
// +optional
@@ -235,7 +234,13 @@ type KustomizationStatus struct {
235234
// KustomizationProgressing resets the conditions of the given Kustomization to a single
236235
// ReadyCondition with status ConditionUnknown.
237236
func KustomizationProgressing(k Kustomization) Kustomization {
238-
meta.SetResourceCondition(&k, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
237+
newCondition := metav1.Condition{
238+
Type: meta.ReadyCondition,
239+
Status: metav1.ConditionUnknown,
240+
Reason: meta.ProgressingReason,
241+
Message: "reconciliation in progress",
242+
}
243+
apimeta.SetStatusCondition(k.GetStatusConditions(), newCondition)
239244
return k
240245
}
241246

@@ -245,14 +250,27 @@ func SetKustomizationHealthiness(k *Kustomization, status metav1.ConditionStatus
245250
case 0:
246251
apimeta.RemoveStatusCondition(k.GetStatusConditions(), HealthyCondition)
247252
default:
248-
meta.SetResourceCondition(k, HealthyCondition, status, reason, trimString(message, MaxConditionMessageLength))
253+
newCondition := metav1.Condition{
254+
Type: HealthyCondition,
255+
Status: status,
256+
Reason: reason,
257+
Message: trimString(message, MaxConditionMessageLength),
258+
}
259+
apimeta.SetStatusCondition(k.GetStatusConditions(), newCondition)
249260
}
250261
}
251262

252263
// SetKustomizeReadiness sets the ReadyCondition, ObservedGeneration, and LastAttemptedRevision,
253264
// on the Kustomization.
254265
func SetKustomizationReadiness(k *Kustomization, status metav1.ConditionStatus, reason, message string, revision string) {
255-
meta.SetResourceCondition(k, meta.ReadyCondition, status, reason, trimString(message, MaxConditionMessageLength))
266+
newCondition := metav1.Condition{
267+
Type: meta.ReadyCondition,
268+
Status: status,
269+
Reason: reason,
270+
Message: trimString(message, MaxConditionMessageLength),
271+
}
272+
apimeta.SetStatusCondition(k.GetStatusConditions(), newCondition)
273+
256274
k.Status.ObservedGeneration = k.Generation
257275
k.Status.LastAttemptedRevision = revision
258276
}
@@ -305,7 +323,7 @@ func (in Kustomization) GetRetryInterval() time.Duration {
305323
return in.Spec.Interval.Duration
306324
}
307325

308-
func (in Kustomization) GetDependsOn() (types.NamespacedName, []dependency.CrossNamespaceDependencyReference) {
326+
func (in Kustomization) GetDependsOn() (types.NamespacedName, []meta.NamespacedObjectReference) {
309327
return types.NamespacedName{
310328
Namespace: in.Namespace,
311329
Name: in.Name,

api/v1beta1/zz_generated.deepcopy.go

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/condition_types.go

+12
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,16 @@ const (
3636
// HealthCheckFailedReason represents the fact that
3737
// one of the health checks failed.
3838
HealthCheckFailedReason string = "HealthCheckFailed"
39+
40+
// DependencyNotReadyReason represents the fact that
41+
// one of the dependencies is not ready.
42+
DependencyNotReadyReason string = "DependencyNotReady"
43+
44+
// ReconciliationSucceededReason represents the fact that
45+
// the reconciliation succeeded.
46+
ReconciliationSucceededReason string = "ReconciliationSucceeded"
47+
48+
// ReconciliationFailedReason represents the fact that
49+
// the reconciliation failed.
50+
ReconciliationFailedReason string = "ReconciliationFailed"
3951
)

api/v1beta2/kustomization_types.go

+45-15
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ package v1beta2
1919
import (
2020
"time"
2121

22+
"github.com/fluxcd/pkg/apis/kustomize"
23+
"github.com/fluxcd/pkg/apis/meta"
2224
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2325
apimeta "k8s.io/apimachinery/pkg/api/meta"
2426
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"
3027
)
3128

3229
const (
@@ -39,11 +36,11 @@ const (
3936

4037
// KustomizationSpec defines the configuration to calculate the desired state from a Source using Kustomize.
4138
type KustomizationSpec struct {
42-
// DependsOn may contain a dependency.CrossNamespaceDependencyReference slice
39+
// DependsOn may contain a meta.NamespacedObjectReference slice
4340
// with references to Kustomization resources that must be ready before this
4441
// Kustomization can be reconciled.
4542
// +optional
46-
DependsOn []dependency.CrossNamespaceDependencyReference `json:"dependsOn,omitempty"`
43+
DependsOn []meta.NamespacedObjectReference `json:"dependsOn,omitempty"`
4744

4845
// Decrypt Kubernetes secrets before applying them on the cluster.
4946
// +optional
@@ -245,7 +242,13 @@ type KustomizationStatus struct {
245242
// KustomizationProgressing resets the conditions of the given Kustomization to a single
246243
// ReadyCondition with status ConditionUnknown.
247244
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)
249252
return k
250253
}
251254

@@ -254,14 +257,27 @@ func SetKustomizationHealthiness(k *Kustomization, status metav1.ConditionStatus
254257
if !k.Spec.Wait && len(k.Spec.HealthChecks) == 0 {
255258
apimeta.RemoveStatusCondition(k.GetStatusConditions(), HealthyCondition)
256259
} 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)
258267
}
259268

260269
}
261270

262271
// SetKustomizationReadiness sets the ReadyCondition, ObservedGeneration, and LastAttemptedRevision, on the Kustomization.
263272
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+
265281
k.Status.ObservedGeneration = k.Generation
266282
k.Status.LastAttemptedRevision = revision
267283
}
@@ -312,18 +328,32 @@ func (in Kustomization) GetRetryInterval() time.Duration {
312328
if in.Spec.RetryInterval != nil {
313329
return in.Spec.RetryInterval.Duration
314330
}
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 {
315337
return in.Spec.Interval.Duration
316338
}
317339

318340
// 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
324353
}
325354

326355
// GetStatusConditions returns a pointer to the Status.Conditions slice.
356+
// Deprecated: use GetConditions instead.
327357
func (in *Kustomization) GetStatusConditions() *[]metav1.Condition {
328358
return &in.Status.Conditions
329359
}

api/v1beta2/zz_generated.deepcopy.go

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)