Skip to content

Commit 15cdc47

Browse files
committed
fix(kamaji): anchor the ignore patterns to the chart root
Helm skips .helmignore when it reads a chart out of an archive and honours it when it reads one out of a directory. A pattern with no slash is matched against the base name at any depth, so `hack` reached charts/kamaji-crds/hack, where the CRD templates keep the schema they pull in with .Files.Get. The cluster, which gets the archive, has always had the full CRDs; every local render, lint and package produced three CustomResourceDefinitions with an empty spec, and no check that runs before a cluster sees the chart could have caught a schema defect. There is no hack directory at the top level of this package, so the pattern excluded that subchart and nothing else. `images` is anchored alongside it against the same trap; it matches only the intended directory today and the packaged file list is unchanged by it. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 6b6c982 commit 15cdc47

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎hack/kamaji-crds-schema.bats‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bats
2+
# The kamaji package ships its CRDs from charts/kamaji-crds/templates/, which
3+
# read their schema with .Files.Get from charts/kamaji-crds/hack/. Helm skips
4+
# .helmignore when it reads a chart out of an archive and honours it when it
5+
# reads one out of a directory, so a pattern matching that hack/ directory
6+
# leaves the cluster with full schemas and every local render, lint and package
7+
# with a CRD whose spec is empty. That split hides schema defects from every
8+
# check that runs before a cluster sees the chart, which is all of ours.
9+
#
10+
# The package path is relative because both runners invoke these from the
11+
# repository root, as the neighbouring render tests assume too.
12+
13+
@test "kamaji CRD templates render their schema" {
14+
rendered=$(helm template kamaji packages/system/kamaji --namespace cozy-kamaji)
15+
16+
for crd in tenantcontrolplanes datastores kubeconfiggenerators; do
17+
versions=$(printf '%s\n' "$rendered" | yq -r "select(.metadata.name == \"$crd.kamaji.clastix.io\") | .spec.versions | length")
18+
[ "$versions" -gt 0 ]
19+
done
20+
21+
spec_props=$(printf '%s\n' "$rendered" | yq -r 'select(.metadata.name == "tenantcontrolplanes.kamaji.clastix.io") | .spec.versions[0].schema.openAPIV3Schema.properties.spec.properties | length')
22+
[ "$spec_props" -gt 0 ]
23+
}

‎packages/system/kamaji/.helmignore‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
images
2-
hack
1+
/images
2+
/hack

0 commit comments

Comments
 (0)