diff --git a/charts/k3k/crds/k3k.io_clusters.yaml b/charts/k3k/templates/crds/k3k.io_clusters.yaml similarity index 99% rename from charts/k3k/crds/k3k.io_clusters.yaml rename to charts/k3k/templates/crds/k3k.io_clusters.yaml index 10a74741..c5d50fe3 100644 --- a/charts/k3k/crds/k3k.io_clusters.yaml +++ b/charts/k3k/templates/crds/k3k.io_clusters.yaml @@ -3,6 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + helm.sh/resource-policy: keep controller-gen.kubebuilder.io/version: v0.16.0 name: clusters.k3k.io spec: diff --git a/charts/k3k/crds/k3k.io_virtualclusterpolicies.yaml b/charts/k3k/templates/crds/k3k.io_virtualclusterpolicies.yaml similarity index 99% rename from charts/k3k/crds/k3k.io_virtualclusterpolicies.yaml rename to charts/k3k/templates/crds/k3k.io_virtualclusterpolicies.yaml index 83e9ac67..3699c610 100644 --- a/charts/k3k/crds/k3k.io_virtualclusterpolicies.yaml +++ b/charts/k3k/templates/crds/k3k.io_virtualclusterpolicies.yaml @@ -3,6 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + helm.sh/resource-policy: keep controller-gen.kubebuilder.io/version: v0.16.0 name: virtualclusterpolicies.k3k.io spec: diff --git a/k3k-kubelet/controller/syncer/syncer_suite_test.go b/k3k-kubelet/controller/syncer/syncer_suite_test.go index e1f4585d..2990ce6c 100644 --- a/k3k-kubelet/controller/syncer/syncer_suite_test.go +++ b/k3k-kubelet/controller/syncer/syncer_suite_test.go @@ -92,7 +92,7 @@ func NewTestEnv() *TestEnv { By("bootstrapping test environment") testEnv := &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "charts", "k3k", "crds")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "charts", "k3k", "templates", "crds")}, ErrorIfCRDPathMissing: true, BinaryAssetsDirectory: tempDir, Scheme: buildScheme(), diff --git a/pkg/controller/cluster/cluster_suite_test.go b/pkg/controller/cluster/cluster_suite_test.go index cf72d92a..510d428d 100644 --- a/pkg/controller/cluster/cluster_suite_test.go +++ b/pkg/controller/cluster/cluster_suite_test.go @@ -41,7 +41,7 @@ var ( var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "charts", "k3k", "crds")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "charts", "k3k", "templates", "crds")}, ErrorIfCRDPathMissing: true, } diff --git a/pkg/controller/policy/policy_suite_test.go b/pkg/controller/policy/policy_suite_test.go index 2ec1ab7a..0d39d925 100644 --- a/pkg/controller/policy/policy_suite_test.go +++ b/pkg/controller/policy/policy_suite_test.go @@ -38,7 +38,7 @@ var ( var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "charts", "k3k", "crds")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "charts", "k3k", "templates", "crds")}, ErrorIfCRDPathMissing: true, } cfg, err := testEnv.Start() diff --git a/scripts/generate b/scripts/generate index ae1c089d..9d865a74 100755 --- a/scripts/generate +++ b/scripts/generate @@ -10,4 +10,11 @@ CONTROLLER_TOOLS_VERSION=v0.16.0 go run sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_TOOLS_VERSION} \ crd:generateEmbeddedObjectMeta=true,allowDangerousTypes=false \ object paths=./pkg/apis/... \ - output:crd:dir=./charts/k3k/crds + output:crd:dir=./charts/k3k/templates/crds + +# add the 'helm.sh/resource-policy: keep' annotation to the CRDs +for f in ./charts/k3k/templates/crds/*.yaml; do + sed -i '0,/^[[:space:]]*annotations:/s/^[[:space:]]*annotations:/&\n helm.sh\/resource-policy: keep/' "$f" + echo "Validating $f" + yq . "$f" > /dev/null +done