Skip to content

Commit 1cb4332

Browse files
authored
Merge pull request #1642 from fluxcd/update-pkg-deps/main
Update fluxcd/pkg dependencies
2 parents 41638da + 5cc19aa commit 1cb4332

7 files changed

Lines changed: 206 additions & 15 deletions

File tree

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/fluxcd/kustomize-controller/api
33
go 1.25.0
44

55
require (
6-
github.com/fluxcd/pkg/apis/kustomize v1.16.0
6+
github.com/fluxcd/pkg/apis/kustomize v1.17.0
77
github.com/fluxcd/pkg/apis/meta v1.26.0
88
k8s.io/apiextensions-apiserver v0.35.2
99
k8s.io/apimachinery v0.35.2

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
44
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
66
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7-
github.com/fluxcd/pkg/apis/kustomize v1.16.0 h1:PhWXEhqQqsisIpwp1/wHvTvo+MO+GGzsBPoN0ZnRE3Y=
8-
github.com/fluxcd/pkg/apis/kustomize v1.16.0/go.mod h1:IZOy4CCtR/hxMGb7erK1RfbGnczVv4/dRBoVD37AywI=
7+
github.com/fluxcd/pkg/apis/kustomize v1.17.0 h1:xINP8vW0c6Iz99AFzNX5gFkb8I2QYVCzEaU8HfvajNM=
8+
github.com/fluxcd/pkg/apis/kustomize v1.17.0/go.mod h1:IZOy4CCtR/hxMGb7erK1RfbGnczVv4/dRBoVD37AywI=
99
github.com/fluxcd/pkg/apis/meta v1.26.0 h1:dxP1FfBpTCYso6odzRcltVnnRuBb2VyhhgV0VX9YbUE=
1010
github.com/fluxcd/pkg/apis/meta v1.26.0/go.mod h1:c7o6mJGLCMvNrfdinGZehkrdZuFT9vZdZNrn66DtVD0=
1111
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=

config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ spec:
202202
required:
203203
- apiVersion
204204
- current
205-
- kind
206205
type: object
207206
type: array
208207
healthChecks:

docs/spec/v1/kustomizations.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,12 @@ health checks on custom resources. This is done through Common Expression
355355
Language (CEL) expressions. This field accepts a list of objects with the
356356
following fields:
357357

358-
- `apiVersion`: The API version of the custom resource. Required.
359-
- `kind`: The kind of the custom resource. Required.
358+
- `apiVersion`: The API version of the custom resource. Required. Only the
359+
group portion is used for matching; the version is ignored, so the same
360+
entry applies to every served version of the resource.
361+
- `kind`: The kind of the custom resource. Optional. When omitted, the entry
362+
applies to all kinds under the given `apiVersion`'s group. An entry with a
363+
specific `kind` takes precedence over a group-only entry for that same kind.
360364
- `current`: A required CEL expression that returns `true` if the resource is ready.
361365
- `inProgress`: An optional CEL expression that returns `true` if the resource
362366
is still being reconciled.

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ require (
2222
github.com/fluxcd/kustomize-controller/api v1.8.0
2323
github.com/fluxcd/pkg/apis/acl v0.9.0
2424
github.com/fluxcd/pkg/apis/event v0.25.0
25-
github.com/fluxcd/pkg/apis/kustomize v1.16.0
25+
github.com/fluxcd/pkg/apis/kustomize v1.17.0
2626
github.com/fluxcd/pkg/apis/meta v1.26.0
2727
github.com/fluxcd/pkg/auth v0.41.0
2828
github.com/fluxcd/pkg/cache v0.13.0
2929
github.com/fluxcd/pkg/http/fetch v0.24.0
30-
github.com/fluxcd/pkg/kustomize v1.30.0
31-
github.com/fluxcd/pkg/runtime v0.103.0
30+
github.com/fluxcd/pkg/kustomize v1.31.0
31+
github.com/fluxcd/pkg/runtime v0.104.0
3232
github.com/fluxcd/pkg/ssa v0.71.0
3333
github.com/fluxcd/pkg/tar v1.1.0
3434
github.com/fluxcd/pkg/testserver v0.13.0

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ github.com/fluxcd/pkg/apis/acl v0.9.0 h1:wBpgsKT+jcyZEcM//OmZr9RiF8klL3ebrDp2u2T
209209
github.com/fluxcd/pkg/apis/acl v0.9.0/go.mod h1:TttNS+gocsGLwnvmgVi3/Yscwqrjc17+vhgYfqkfrV4=
210210
github.com/fluxcd/pkg/apis/event v0.25.0 h1:zdwytvDhG+fk+Ywl5DOtv7TklkrVgM21WHm1f+YhleE=
211211
github.com/fluxcd/pkg/apis/event v0.25.0/go.mod h1:TlK8HWYrTwl0raqBRC+ROoNpYW5fdVnwcwOBOx5Kzw8=
212-
github.com/fluxcd/pkg/apis/kustomize v1.16.0 h1:PhWXEhqQqsisIpwp1/wHvTvo+MO+GGzsBPoN0ZnRE3Y=
213-
github.com/fluxcd/pkg/apis/kustomize v1.16.0/go.mod h1:IZOy4CCtR/hxMGb7erK1RfbGnczVv4/dRBoVD37AywI=
212+
github.com/fluxcd/pkg/apis/kustomize v1.17.0 h1:xINP8vW0c6Iz99AFzNX5gFkb8I2QYVCzEaU8HfvajNM=
213+
github.com/fluxcd/pkg/apis/kustomize v1.17.0/go.mod h1:IZOy4CCtR/hxMGb7erK1RfbGnczVv4/dRBoVD37AywI=
214214
github.com/fluxcd/pkg/apis/meta v1.26.0 h1:dxP1FfBpTCYso6odzRcltVnnRuBb2VyhhgV0VX9YbUE=
215215
github.com/fluxcd/pkg/apis/meta v1.26.0/go.mod h1:c7o6mJGLCMvNrfdinGZehkrdZuFT9vZdZNrn66DtVD0=
216216
github.com/fluxcd/pkg/auth v0.41.0 h1:7NaaPN03ginRUUA928n7hiRJoBoMrF/Prl0AtDlLXBQ=
@@ -221,10 +221,10 @@ github.com/fluxcd/pkg/envsubst v1.6.0 h1:up1bcNAQ6cCm1OA2aWlcERZqRhXE/V/QasHht5/
221221
github.com/fluxcd/pkg/envsubst v1.6.0/go.mod h1:c3a8DYI855sZUubHFYQbjfjop6Wu4/zg1cLyf7SnCes=
222222
github.com/fluxcd/pkg/http/fetch v0.24.0 h1:helmjE86zZG6UTcWDV0IxkKpDKWh96FKeGDSz+W1ZcM=
223223
github.com/fluxcd/pkg/http/fetch v0.24.0/go.mod h1:4gGHbadYT5PpVELFfzPx+3FrXSJupcTxu4qciYsFZas=
224-
github.com/fluxcd/pkg/kustomize v1.30.0 h1:WVufDRbpgCTy+bR+ALVtKFfFpKXVAIEIlEceJbA210M=
225-
github.com/fluxcd/pkg/kustomize v1.30.0/go.mod h1:LBo4uYZdnPFQnCBg1qnPtSpntK6XJbybVSovdH+IxZw=
226-
github.com/fluxcd/pkg/runtime v0.103.0 h1:J5y5GPhWdkyqIUBlaI1FP2N02TtZmsjbWhhZubuTSFk=
227-
github.com/fluxcd/pkg/runtime v0.103.0/go.mod h1:mbo2f3azo3yVQgm7XZGxQB6/2zvzQ5Wgtd8TjRRwwAw=
224+
github.com/fluxcd/pkg/kustomize v1.31.0 h1:VjzSzQsysvnQJ//wbcLERtW3GwXZSIR52ChwbBaaIIU=
225+
github.com/fluxcd/pkg/kustomize v1.31.0/go.mod h1:0PmQOAJ1gselt1DrJ1pmoJg37LPDACiSU9bbqZ7pysk=
226+
github.com/fluxcd/pkg/runtime v0.104.0 h1:6isoyeCvYTXRozknz87pU/Z1eWdm4Hi+ojZFwcwnaqs=
227+
github.com/fluxcd/pkg/runtime v0.104.0/go.mod h1:I7KymH0BM5YUSd68ohjm/RTLXGkw59IXFuu8ISLbLvs=
228228
github.com/fluxcd/pkg/sourceignore v0.17.0 h1:Z72nruRMhC15zIEpWoDrAcJcJ1El6QDnP/aRDfE4WOA=
229229
github.com/fluxcd/pkg/sourceignore v0.17.0/go.mod h1:3e/VmYLId0pI/H5sK7W9Ibif+j0Ahns9RxNjDMtTTfY=
230230
github.com/fluxcd/pkg/ssa v0.71.0 h1:xEGkY4OLo0tODJxjh3TX/lzxeqAiwjRDyKZ7dakz5Sc=

internal/controller/kustomization_wait_test.go

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,3 +640,191 @@ spec:
640640
g.Expect(cancelEvent.Message).To(ContainSubstring("Health checks canceled"))
641641
g.Expect(cancelEvent.Message).To(ContainSubstring("GitRepository"))
642642
}
643+
644+
func TestKustomizationReconciler_HealthCheckExprs_GroupOnly(t *testing.T) {
645+
g := NewWithT(t)
646+
id := "cel-grp-" + randStringRunes(5)
647+
revision := "v1.0.0"
648+
resultK := &kustomizev1.Kustomization{}
649+
timeout := 60 * time.Second
650+
651+
err := createNamespace(id)
652+
g.Expect(err).NotTo(HaveOccurred(), "failed to create test namespace")
653+
654+
err = createKubeConfigSecret(id)
655+
g.Expect(err).NotTo(HaveOccurred(), "failed to create kubeconfig secret")
656+
657+
// Unique group per test run to avoid CRD name collisions within the shared envtest.
658+
group := fmt.Sprintf("%s.flux-test.io", id)
659+
fooCRName := "foo-" + randStringRunes(5)
660+
barCRName := "bar-" + randStringRunes(5)
661+
662+
// Two cluster-scoped CRDs in the same group, plus one CR of each kind.
663+
// The CEL expression reads `spec.ready`, applied via SSA from the artifact.
664+
buildFiles := func(barReady bool) []testserver.File {
665+
return []testserver.File{
666+
{
667+
Name: "crd-foo.yaml",
668+
Body: fmt.Sprintf(`---
669+
apiVersion: apiextensions.k8s.io/v1
670+
kind: CustomResourceDefinition
671+
metadata:
672+
name: foos.%[1]s
673+
spec:
674+
group: %[1]s
675+
names:
676+
kind: Foo
677+
listKind: FooList
678+
plural: foos
679+
singular: foo
680+
scope: Cluster
681+
versions:
682+
- name: v1
683+
served: true
684+
storage: true
685+
schema:
686+
openAPIV3Schema:
687+
type: object
688+
properties:
689+
spec:
690+
type: object
691+
properties:
692+
ready:
693+
type: boolean
694+
`, group),
695+
},
696+
{
697+
Name: "crd-bar.yaml",
698+
Body: fmt.Sprintf(`---
699+
apiVersion: apiextensions.k8s.io/v1
700+
kind: CustomResourceDefinition
701+
metadata:
702+
name: bars.%[1]s
703+
spec:
704+
group: %[1]s
705+
names:
706+
kind: Bar
707+
listKind: BarList
708+
plural: bars
709+
singular: bar
710+
scope: Cluster
711+
versions:
712+
- name: v1
713+
served: true
714+
storage: true
715+
schema:
716+
openAPIV3Schema:
717+
type: object
718+
properties:
719+
spec:
720+
type: object
721+
properties:
722+
ready:
723+
type: boolean
724+
`, group),
725+
},
726+
{
727+
Name: "foo.yaml",
728+
Body: fmt.Sprintf(`---
729+
apiVersion: %[1]s/v1
730+
kind: Foo
731+
metadata:
732+
name: %[2]s
733+
spec:
734+
ready: true
735+
`, group, fooCRName),
736+
},
737+
{
738+
Name: "bar.yaml",
739+
Body: fmt.Sprintf(`---
740+
apiVersion: %[1]s/v1
741+
kind: Bar
742+
metadata:
743+
name: %[2]s
744+
spec:
745+
ready: %[3]t
746+
`, group, barCRName, barReady),
747+
},
748+
}
749+
}
750+
751+
artifact, err := testServer.ArtifactFromFiles(buildFiles(true))
752+
g.Expect(err).NotTo(HaveOccurred())
753+
754+
repositoryName := types.NamespacedName{
755+
Name: fmt.Sprintf("grp-%s", randStringRunes(5)),
756+
Namespace: id,
757+
}
758+
759+
err = applyGitRepository(repositoryName, artifact, revision)
760+
g.Expect(err).NotTo(HaveOccurred())
761+
762+
kustomization := &kustomizev1.Kustomization{
763+
ObjectMeta: metav1.ObjectMeta{
764+
Name: fmt.Sprintf("grp-%s", randStringRunes(5)),
765+
Namespace: id,
766+
},
767+
Spec: kustomizev1.KustomizationSpec{
768+
Interval: metav1.Duration{Duration: 2 * time.Minute},
769+
Path: "./",
770+
KubeConfig: &meta.KubeConfigReference{
771+
SecretRef: &meta.SecretKeyReference{
772+
Name: "kubeconfig",
773+
},
774+
},
775+
SourceRef: kustomizev1.CrossNamespaceSourceReference{
776+
Name: repositoryName.Name,
777+
Namespace: repositoryName.Namespace,
778+
Kind: sourcev1.GitRepositoryKind,
779+
},
780+
Prune: true,
781+
Wait: true,
782+
// Single group-only healthcheck (empty Kind) that must be applied
783+
// to both Foo and Bar custom resources.
784+
HealthCheckExprs: []kustomize.CustomHealthCheck{{
785+
APIVersion: group + "/v1",
786+
HealthCheckExpressions: kustomize.HealthCheckExpressions{
787+
Current: "has(spec.ready) && spec.ready == true",
788+
},
789+
}},
790+
},
791+
}
792+
793+
g.Expect(k8sClient.Create(context.Background(), kustomization)).To(Succeed())
794+
795+
t.Run("group-only healthcheck succeeds for both kinds", func(t *testing.T) {
796+
g.Eventually(func() bool {
797+
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), resultK)
798+
return isReconcileSuccess(resultK)
799+
}, timeout, time.Second).Should(BeTrue())
800+
logStatus(t, resultK)
801+
802+
g.Expect(conditions.IsTrue(resultK, meta.HealthyCondition)).To(BeTrue())
803+
g.Expect(conditions.GetReason(resultK, meta.HealthyCondition)).To(BeIdenticalTo(meta.SucceededReason))
804+
})
805+
806+
t.Run("reports unhealthy when one kind stops satisfying the group expression", func(t *testing.T) {
807+
badArtifact, err := testServer.ArtifactFromFiles(buildFiles(false))
808+
g.Expect(err).NotTo(HaveOccurred())
809+
810+
err = applyGitRepository(repositoryName, badArtifact, "v1.0.1")
811+
g.Expect(err).NotTo(HaveOccurred())
812+
813+
// Shorten healthcheck timeout so the failure surfaces quickly.
814+
g.Eventually(func() error {
815+
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), resultK)
816+
resultK.Spec.Timeout = &metav1.Duration{Duration: 5 * time.Second}
817+
return k8sClient.Update(context.Background(), resultK)
818+
}, timeout, time.Second).Should(BeNil())
819+
820+
g.Eventually(func() bool {
821+
_ = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(kustomization), resultK)
822+
return conditions.IsFalse(resultK, meta.HealthyCondition) &&
823+
conditions.GetReason(resultK, meta.HealthyCondition) == meta.HealthCheckFailedReason
824+
}, timeout, time.Second).Should(BeTrue())
825+
826+
msg := conditions.GetMessage(resultK, meta.HealthyCondition)
827+
g.Expect(msg).To(ContainSubstring("Bar"))
828+
g.Expect(msg).To(ContainSubstring(barCRName))
829+
})
830+
}

0 commit comments

Comments
 (0)