From 95a66ca193ac23090f93e082b8685f8171fc476f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20B=C3=A4hler?= Date: Sat, 7 May 2022 17:27:48 +0200 Subject: [PATCH] Migrate Helmize Chart (#6) Migrate Helm Chart --- .github/workflows/lint-and-test.yml | 42 +++ .../workflows/{gh-pages.yaml => release.yaml} | 29 +- .github/workflows/release.yml | 30 -- charts/ct.yaml | 14 + charts/helmize/Chart.yaml | 7 +- .../render/func/files => bin}/_parse.tpl | 0 charts/helmize/templates/config/_types.tpl | 5 +- .../templates/entrypoint/_defaults.tpl | 26 +- .../templates/entrypoint/func/_deploy.tpl | 8 +- .../templates/entrypoint/func/_resolve.tpl | 8 +- .../entrypoint/templates/_render.tpl | 13 + .../helmize/templates/helpers/_timestamp.tpl | 3 + charts/helmize/templates/render/_defaults.tpl | 38 +- charts/helmize/templates/render/_types.tpl | 25 +- .../templates/render/func/_identifier.tpl | 30 ++ .../templates/render/func/_resolve.tpl | 36 +- .../helmize/templates/render/func/_train.tpl | 265 +++++++++----- .../render/func/files/_identifier.tpl | 115 ------ .../{ => render}/postrenders/_defaults.tpl | 0 .../{ => render}/postrenders/_includes.tpl | 0 .../postrenders/func/_execute.tpl | 0 .../{ => render}/postrenders/func/_get.tpl | 0 .../postrenders/renders/_annotations.tpl | 0 .../postrenders/renders/_labels.tpl | 0 .../render/templates/_identifier.tpl | 41 +++ charts/helmize/values.yaml | 5 +- charts/lint.yaml | 44 +++ charts/test/.helmignore | 23 -- charts/test/Chart.yaml | 24 -- charts/test/templates/remove.yaml | 6 - charts/test/values.yaml | 9 - examples/ct.yaml | 15 + examples/file-cfg/Chart.yaml | 11 + examples/file-cfg/helmize.yaml | 6 + .../patches/forks/prod-deployment.yaml | 17 + .../file-cfg/structure/patches/label.yaml | 9 + .../structure/patches/z/prod-deployment.yaml | 13 + .../structure/resources/base-deployment.yaml | 24 ++ examples/file-cfg/templates/deploy.yaml | 1 + examples/file-cfg/values.yaml | 7 + examples/multi-yaml/Chart.yaml | 10 + examples/multi-yaml/helmize.yaml | 6 + .../structure/patches/configmap.yaml | 13 + .../structure/resources/configmap.yaml | 24 ++ .../structure/resources/multi-line.yaml | 47 +++ .../structure/resources/repositories.yaml | 12 + .../structure/resources/wrong-template.yaml | 16 + examples/multi-yaml/templates/deploy.yaml | 1 + examples/multi-yaml/values.yaml | 7 + examples/podinfo/Chart.lock | 6 - examples/podinfo/helmize.yaml | 14 +- .../location/east/podinfo/labels.yaml | 0 .../podinfo/structure/patches/labels.yaml | 6 + examples/podinfo/values.yaml | 11 +- examples/priority/Chart.yaml | 8 + examples/priority/helmize.yaml | 11 + examples/priority/structure/prio1/1.yaml | 6 + examples/priority/structure/prio1/a.yaml | 6 + examples/priority/structure/prio1/z.yaml | 6 + examples/priority/templates/deploy.yaml | 1 + examples/reference/helmize.yaml | 22 ++ .../structure/base/backend/deployment.yaml | 73 ++++ .../reference/structure/base/backend/hpa.yaml | 18 + .../structure/base/backend/service.yaml | 17 + .../structure/base/frontend/deployment.yaml | 72 ++++ .../structure/base/frontend/hpa.yaml | 21 ++ .../structure/base/frontend/service.yaml | 13 + .../environments/prod/podinfo/deploy.yaml | 6 + .../podinfo/frontend/deployment-frontend.yaml | 14 + .../test/podinfo/frontend/hpa.yaml | 19 + .../east/podinfo/frontend/deploy.yaml | 8 + .../west/podinfo/frontend/deploy.yaml | 10 + .../reference/structure/patches/labels.yaml | 6 + examples/reference/values.yaml | 11 + hugo/content/documentation/advanced/_index.md | 9 - hugo/content/documentation/advanced/data.md | 5 - .../advanced/templates/_index.md | 30 -- .../documentation/configuration/file.md | 20 -- .../documentation/configuration/general.md | 17 +- .../documentation/customization/_index.md | 10 + .../identifiers.md | 21 -- .../post-renderers/_index.md | 0 .../post-renderers/built-in/_index.md | 0 .../post-renderers/built-in/labels.md | 0 .../post-renderers/customize.md | 0 .../documentation/customization/render.md | 27 ++ .../{advanced/debug/_index.md => debug.md} | 0 .../content/documentation/structure/_index.md | 7 + .../documentation/structure/files/_index.md | 138 ++++++++ .../structure/files/identifiers.md | 309 ++++++++++++++++ .../documentation/structure/multiyaml.md | 330 ++++++++++++++++++ .../documentation/structure/priority.md | 7 + .../documentation/structure/templating.md | 5 + icons/icon-transparent.png => icon.png | Bin icons/icon.jpg | Bin 31985 -> 0 bytes 95 files changed, 1936 insertions(+), 469 deletions(-) create mode 100644 .github/workflows/lint-and-test.yml rename .github/workflows/{gh-pages.yaml => release.yaml} (55%) delete mode 100644 .github/workflows/release.yml create mode 100644 charts/ct.yaml rename charts/helmize/{templates/render/func/files => bin}/_parse.tpl (100%) create mode 100644 charts/helmize/templates/entrypoint/templates/_render.tpl create mode 100644 charts/helmize/templates/helpers/_timestamp.tpl create mode 100644 charts/helmize/templates/render/func/_identifier.tpl delete mode 100644 charts/helmize/templates/render/func/files/_identifier.tpl rename charts/helmize/templates/{ => render}/postrenders/_defaults.tpl (100%) rename charts/helmize/templates/{ => render}/postrenders/_includes.tpl (100%) rename charts/helmize/templates/{ => render}/postrenders/func/_execute.tpl (100%) rename charts/helmize/templates/{ => render}/postrenders/func/_get.tpl (100%) rename charts/helmize/templates/{ => render}/postrenders/renders/_annotations.tpl (100%) rename charts/helmize/templates/{ => render}/postrenders/renders/_labels.tpl (100%) create mode 100644 charts/helmize/templates/render/templates/_identifier.tpl create mode 100644 charts/lint.yaml delete mode 100644 charts/test/.helmignore delete mode 100644 charts/test/Chart.yaml delete mode 100644 charts/test/templates/remove.yaml delete mode 100644 charts/test/values.yaml create mode 100644 examples/ct.yaml create mode 100644 examples/file-cfg/Chart.yaml create mode 100644 examples/file-cfg/helmize.yaml create mode 100644 examples/file-cfg/structure/patches/forks/prod-deployment.yaml create mode 100644 examples/file-cfg/structure/patches/label.yaml create mode 100644 examples/file-cfg/structure/patches/z/prod-deployment.yaml create mode 100644 examples/file-cfg/structure/resources/base-deployment.yaml create mode 100644 examples/file-cfg/templates/deploy.yaml create mode 100644 examples/file-cfg/values.yaml create mode 100644 examples/multi-yaml/Chart.yaml create mode 100644 examples/multi-yaml/helmize.yaml create mode 100644 examples/multi-yaml/structure/patches/configmap.yaml create mode 100644 examples/multi-yaml/structure/resources/configmap.yaml create mode 100644 examples/multi-yaml/structure/resources/multi-line.yaml create mode 100644 examples/multi-yaml/structure/resources/repositories.yaml create mode 100644 examples/multi-yaml/structure/resources/wrong-template.yaml create mode 100644 examples/multi-yaml/templates/deploy.yaml create mode 100644 examples/multi-yaml/values.yaml delete mode 100644 examples/podinfo/Chart.lock delete mode 100644 examples/podinfo/structure/location/east/podinfo/labels.yaml create mode 100644 examples/podinfo/structure/patches/labels.yaml create mode 100644 examples/priority/Chart.yaml create mode 100644 examples/priority/helmize.yaml create mode 100644 examples/priority/structure/prio1/1.yaml create mode 100644 examples/priority/structure/prio1/a.yaml create mode 100644 examples/priority/structure/prio1/z.yaml create mode 100644 examples/priority/templates/deploy.yaml create mode 100644 examples/reference/helmize.yaml create mode 100644 examples/reference/structure/base/backend/deployment.yaml create mode 100644 examples/reference/structure/base/backend/hpa.yaml create mode 100644 examples/reference/structure/base/backend/service.yaml create mode 100644 examples/reference/structure/base/frontend/deployment.yaml create mode 100644 examples/reference/structure/base/frontend/hpa.yaml create mode 100644 examples/reference/structure/base/frontend/service.yaml create mode 100644 examples/reference/structure/environments/prod/podinfo/deploy.yaml create mode 100644 examples/reference/structure/environments/test/podinfo/frontend/deployment-frontend.yaml create mode 100644 examples/reference/structure/environments/test/podinfo/frontend/hpa.yaml create mode 100644 examples/reference/structure/locations/east/podinfo/frontend/deploy.yaml create mode 100644 examples/reference/structure/locations/west/podinfo/frontend/deploy.yaml create mode 100644 examples/reference/structure/patches/labels.yaml create mode 100644 examples/reference/values.yaml delete mode 100644 hugo/content/documentation/advanced/_index.md delete mode 100644 hugo/content/documentation/advanced/data.md delete mode 100644 hugo/content/documentation/advanced/templates/_index.md delete mode 100644 hugo/content/documentation/configuration/file.md create mode 100644 hugo/content/documentation/customization/_index.md rename hugo/content/documentation/{advanced => customization}/identifiers.md (85%) rename hugo/content/documentation/{ => customization}/post-renderers/_index.md (100%) rename hugo/content/documentation/{ => customization}/post-renderers/built-in/_index.md (100%) rename hugo/content/documentation/{ => customization}/post-renderers/built-in/labels.md (100%) rename hugo/content/documentation/{ => customization}/post-renderers/customize.md (100%) create mode 100644 hugo/content/documentation/customization/render.md rename hugo/content/documentation/{advanced/debug/_index.md => debug.md} (100%) create mode 100644 hugo/content/documentation/structure/_index.md create mode 100644 hugo/content/documentation/structure/files/_index.md create mode 100644 hugo/content/documentation/structure/files/identifiers.md create mode 100644 hugo/content/documentation/structure/multiyaml.md create mode 100644 hugo/content/documentation/structure/priority.md create mode 100644 hugo/content/documentation/structure/templating.md rename icons/icon-transparent.png => icon.png (100%) delete mode 100644 icons/icon.jpg diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml new file mode 100644 index 0000000..c729d24 --- /dev/null +++ b/.github/workflows/lint-and-test.yml @@ -0,0 +1,42 @@ +# +# Reference: https://github.com/helm/chart-testing-action +# +name: Linting and Testing +on: pull_request +jobs: + chart-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v1 + + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Setup Chart Linting + id: lint + uses: helm/chart-testing-action@v2.0.1 + + - name: Install Plugins + run: | + helm plugin install https://github.com/quintush/helm-unittest > /dev/null 2>&1 + + - name: Run chart-testing (lint) Helmize + run: ct lint --config ./charts/ct.yaml --lint-conf ./charts/lint.yaml + + - name: Run chart-testing (lint) Examples + run: ct lint --config ./examples/ct.yaml + + - name: Create kind cluster + uses: helm/kind-action@v1.2.0 + if: steps.list-changed.outputs.changed == 'true' + + - name: Run chart-testing (install) Examples + run: ct install --config ./ct.yaml + if: steps.list-changed.outputs.changed == 'true' diff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/release.yaml similarity index 55% rename from .github/workflows/gh-pages.yaml rename to .github/workflows/release.yaml index 2f8e01e..1ec8826 100644 --- a/.github/workflows/gh-pages.yaml +++ b/.github/workflows/release.yaml @@ -5,6 +5,32 @@ on: branches: - main # Set a branch to deploy jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Helm + uses: azure/setup-helm@v1 + + - name: Add dependency chart repos + run: | + helm repo add buttahtoast https://buttahtoast.github.io/helm-charts/ + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.2.0 + with: + charts_dir: charts + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + deploy: runs-on: ubuntu-20.04 concurrency: @@ -34,4 +60,5 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./hugo/public \ No newline at end of file + publish_dir: ./hugo/public + keep_files: true \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 3a1116a..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Helm Chart Release -on: - push: - branches: - - main -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Install Helm - uses: azure/setup-helm@v1 - - - name: Add dependency chart repos - run: | - helm repo add buttahtoast https://buttahtoast.github.io/helm-charts/ - - name: Configure Git - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.2.0 - with: - charts_dir: charts - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/charts/ct.yaml b/charts/ct.yaml new file mode 100644 index 0000000..91b96c7 --- /dev/null +++ b/charts/ct.yaml @@ -0,0 +1,14 @@ +## Reference: https://github.com/helm/chart-testing/blob/master/doc/ct_lint-and-install.md +## +remote: origin +target-branch: main +chart-dirs: + - charts/ +chart-repos: + - buttahtoast=https://buttahtoast.github.io/helm-charts/ +validate-chart-schema: true +validate-maintainers: true +validate-yaml: true +helm-extra-args: "--timeout 600s" +exclude-deprecated: true +debug: true \ No newline at end of file diff --git a/charts/helmize/Chart.yaml b/charts/helmize/Chart.yaml index 2e78f40..3e1f8ed 100644 --- a/charts/helmize/Chart.yaml +++ b/charts/helmize/Chart.yaml @@ -2,15 +2,14 @@ apiVersion: v2 name: helmize description: Go Sprig based deployment engine deployed via Helm type: library -version: "0.1.0-rc.3" +version: "0.1.0-rc.4" appVersion: "0.1.0" home: https://helmize.dev -icon: https://raw.githubusercontent.com/buttahtoast/helmize/main/icons/icon-transparent.png +icon: https://raw.githubusercontent.com/buttahtoast/helmize/main/icon.png dependencies: - name: library version: "2.2.3" - #repository: "file://../../../helm-charts-1/charts/library" - repository: https://buttahtoast.github.io/helm-charts/ + repository: https://buttahtoast.github.io/helm-charts/ keywords: - library - sprig diff --git a/charts/helmize/templates/render/func/files/_parse.tpl b/charts/helmize/bin/_parse.tpl similarity index 100% rename from charts/helmize/templates/render/func/files/_parse.tpl rename to charts/helmize/bin/_parse.tpl diff --git a/charts/helmize/templates/config/_types.tpl b/charts/helmize/templates/config/_types.tpl index 9d3a884..0372ef0 100644 --- a/charts/helmize/templates/config/_types.tpl +++ b/charts/helmize/templates/config/_types.tpl @@ -18,7 +18,10 @@ default: [ ".yaml", ".yml", ".tpl" ] {{ include "inventory.render.defaults.files.identifier_template" $ }}: types: [ "string" ] - default: "inventory.render.func.files.identifier.template" + default: "inventory.render.templates.identifier" +{{ include "inventory.entrypoint.defaults.render_template" $ }}: + types: [ "string" ] + default: "inventory.entrypoint.templates.render" {{ include "inventory.postrenders.defaults.cfg.post_renderers" $ }}: types: [ "slice" ] default: [ "{{ include "inventory.postrenders.defaults.cfg.post_renderers.inject_key" $ }}" ] diff --git a/charts/helmize/templates/entrypoint/_defaults.tpl b/charts/helmize/templates/entrypoint/_defaults.tpl index deb951b..823b6ba 100644 --- a/charts/helmize/templates/entrypoint/_defaults.tpl +++ b/charts/helmize/templates/entrypoint/_defaults.tpl @@ -1,4 +1,4 @@ -{{/* Force