diff --git a/component/cluster-api.jsonnet b/component/cluster-api.jsonnet index 760fe66..b0934f5 100644 --- a/component/cluster-api.jsonnet +++ b/component/cluster-api.jsonnet @@ -52,7 +52,6 @@ com.Kustomization( }, ], patchesStrategicMerge: [ 'rm-namespace.yaml' ], - patches: [ capi.kustomize_patch_crd_clusterctl_label.patch ], // NOTE(sg): Somehow the upstream replacements don't take our `namespace` // override into account? For now, we replicate the namespace replacements // here to workaround this issue. @@ -143,4 +142,4 @@ com.Kustomization( }, }, ], -} + capi.kustomize_patch_crd_clusterctl_label.patch_file +} + capi.kustomize_crd_clusterctl_label_patch diff --git a/docs/modules/ROOT/pages/references/library.adoc b/docs/modules/ROOT/pages/references/library.adoc index 0ae829a..2d2161d 100644 --- a/docs/modules/ROOT/pages/references/library.adoc +++ b/docs/modules/ROOT/pages/references/library.adoc @@ -50,3 +50,9 @@ This function creates a minimal custom resource based on the function arguments. The function only populates fields `apiVersion`, `kind` and `metadata.name`. The function uses library field `apiVersion` to create field `apiVersion` based on the provided `apiGroup`. Fields `kind` and `metadata.name` are set to the values of arguments `kind` and `name` respectively. + +== `kustomize_crd_clusterctl_label_patch` + +This library field provides a Kustomize patch which applies label `clusterctl.cluster.x-k8s.io=""` to all CRDs which are part of the target Kustomization. + +This library field provides the patch as an object which is suitable to be merged into the output of https://syn.tools/commodore/reference/commodore-libjsonnet.html#_kustomizationbase_url_base_version_images_kustomize_input[the Commodore `com.Kustomization()` helper function]. diff --git a/lib/capi-core.libsonnet b/lib/capi-core.libsonnet index 5f62a1a..37c4786 100644 --- a/lib/capi-core.libsonnet +++ b/lib/capi-core.libsonnet @@ -1,22 +1,24 @@ { - kustomize_patch_crd_clusterctl_label: { - patch: { - path: 'clusterctl-label.yaml', - target: { - group: 'apiextensions.k8s.io', - version: 'v1', - kind: 'CustomResourceDefinition', - }, + // NOTE(sg): This is structured in a way that allows it to be merged into + // the result of `com.Kustomzation()` without any adjustments. + kustomize_crd_clusterctl_label_patch: { + kustomization+: { + patches+: [ { + path: 'capi-core-clusterctl-label.yaml', + target: { + group: 'apiextensions.k8s.io', + version: 'v1', + kind: 'CustomResourceDefinition', + }, + } ], }, - patch_file: { - 'clusterctl-label': { - apiVersion: 'apiextensions.k8s.io/v1', - kind: 'CustomResourceDefinition', - metadata: { - name: 'REPLACE_ME', - labels: { - 'clusterctl.cluster.x-k8s.io': '', - }, + 'capi-core-clusterctl-label': { + apiVersion: 'apiextensions.k8s.io/v1', + kind: 'CustomResourceDefinition', + metadata: { + name: 'REPLACE_ME', + labels: { + 'clusterctl.cluster.x-k8s.io': '', }, }, },