From 6448af74860ff7c869e54ed86b786ca54fa3a7e5 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Tue, 19 Mar 2024 02:34:46 +0100 Subject: [PATCH] docs: fix oci-image example, add test + docs Closes #72 --- README.md | 8 ++++++++ e2e/cli-tests.bats | 5 +++-- e2e/kustomize-plugin-tests.bats | 4 ++++ example/oci-image/generator.yaml | 5 ++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c049d39..cb96381 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,14 @@ When running khelm as kpt function or within a container the `repositories.yaml` Unlike Helm khelm allows usage of any repository when `repositories.yaml` is not present or `--trust-any-repo` (env var `KHELM_TRUST_ANY_REPO`) is enabled. +### Loading a chart from an OCI registry + +Using Helm, you can store a Helm chart as OCI image within a container registry. +To load a chart from an OCI registry using khelm you can leave the `repository` field empty and specify the container registry/image name within the `chart` field, prefixed with `oci://`. +When using a chart from an OCI registry, Helm's `repository.yaml` configuration is not used. +Instead, Docker's `config.json` is used to read private registry credentials from, if any. +This behaviour is aligned with Helm. + ## Helm support * Helm 2 is supported by the `v1` module version. diff --git a/e2e/cli-tests.bats b/e2e/cli-tests.bats index 3eefd64..2086a89 100755 --- a/e2e/cli-tests.bats +++ b/e2e/cli-tests.bats @@ -39,8 +39,9 @@ teardown() { grep -q myreleasex "$OUT_DIR/manifest.yaml" } -@test "CLI should support oci registry" { - docker run --rm -u $(id -u):$(id -g) -v "$OUT_DIR:/out" "$IMAGE" template myreleasex oci://public.ecr.aws/karpenter/karpenter \ +@test "CLI should support OCI registry" { + docker run --rm -u $(id -u):$(id -g) -v "$OUT_DIR:/out" "$IMAGE" \ + template myreleasex oci://public.ecr.aws/karpenter/karpenter \ --version v0.27.0 \ --output /out/manifest.yaml \ --debug diff --git a/e2e/kustomize-plugin-tests.bats b/e2e/kustomize-plugin-tests.bats index 73dd3fa..4c1492d 100755 --- a/e2e/kustomize-plugin-tests.bats +++ b/e2e/kustomize-plugin-tests.bats @@ -30,3 +30,7 @@ kustomizeBuild() { @test "kustomize vars can overwrite helm values" { kustomizeBuild example/kustomize-var/overlay ' value: changed by kustomization overlay' } + +@test "kustomize generator should support OCI registry" { + kustomizeBuild example/oci-image 'app.kubernetes.io/name: karpenter' +} diff --git a/example/oci-image/generator.yaml b/example/oci-image/generator.yaml index 92dcecf..9c0abe9 100644 --- a/example/oci-image/generator.yaml +++ b/example/oci-image/generator.yaml @@ -3,6 +3,5 @@ kind: ChartRenderer metadata: name: karpenter namespace: kube-system -repository: "oci://public.ecr.aws/karpenter" -chart: karpenter -version: 0.27.0 +chart: "oci://public.ecr.aws/karpenter/karpenter" +version: 0.35.0