From d54ef0f1e61d970ddfbcc63e1571380b2ad75552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Wed, 19 Apr 2023 14:57:07 +0200 Subject: [PATCH] Use pre-commit to generate the expected files --- .github/workflows/main.yaml | 3 --- .pre-commit-config.yaml | 17 +++++++++++++++++ Makefile | 6 ------ tests/expected.yaml | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 24 deletions(-) delete mode 100644 Makefile diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 095833b..b1408d3 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -60,9 +60,6 @@ jobs: - run: helm dependency update . - run: helm lint . - run: helm lint --values=tests/values.yaml . - - run: helm template --namespace=default --values=tests/values.yaml custom . > tests/actual.yaml - - run: diff --ignore-trailing-space tests/actual.yaml tests/expected.yaml - if: matrix.helm == 'master' - name: Setup k3s/k3d run: c2cciutils-k8s-install diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ef14e2a..ad61f3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,7 @@ ci: - helm-lock - helmlint - ripsecrets + - helm-template-gen repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -29,6 +30,22 @@ repos: - id: copyright - id: workflows-require-timeout - id: helm-lock + - repo: https://github.com/camptocamp/helm-common + rev: 0.6.0 + hooks: + - id: helm-template-gen + files: |- + (?x)( + ^templates/.*$ + |^values\.yaml$ + |^Chart\.yaml$ + |^tests/values\.yaml$ + ) + args: + - --values=tests/values.yaml + - custom + - . + - tests/expected.yaml - repo: https://github.com/codespell-project/codespell rev: v2.2.4 hooks: diff --git a/Makefile b/Makefile deleted file mode 100644 index ad43435..0000000 --- a/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -HELM ?= helm - -gen-expected: - ${HELM} template --namespace=default --values=tests/values.yaml custom . > tests/expected.yaml || \ - ${HELM} template --debug --namespace=default --values=tests/values.yaml custom . - sed -i 's/[[:blank:]]\+$$//g' tests/expected.yaml diff --git a/tests/expected.yaml b/tests/expected.yaml index b542c17..04064bf 100644 --- a/tests/expected.yaml +++ b/tests/expected.yaml @@ -3,7 +3,7 @@ apiVersion: policy/v1 kind: PodDisruptionBudget metadata: - name: custom-custom-pod-with-serv + name: custom-custom-pod-with-service-name labels: app.kubernetes.io/name: custom-pod app.kubernetes.io/instance: custom @@ -54,7 +54,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: custom-custom-pod-with-serv + name: custom-custom-pod-with-service-name labels: helm.sh/chart: custom-pod app.kubernetes.io/version: "1.0" @@ -62,7 +62,7 @@ metadata: app.kubernetes.io/name: custom-pod app.kubernetes.io/instance: custom app.kubernetes.io/component: with-service-name - one-custom-label: "hello-world" + one-custom-label: hello-world annotations: one-custom-annotation: abc two-custom-annotations: xyz @@ -130,7 +130,7 @@ spec: apiVersion: apps/v1 kind: Deployment metadata: - name: custom-custom-pod-with-serv + name: custom-custom-pod-with-service-name labels: helm.sh/chart: custom-pod app.kubernetes.io/version: "1.0" @@ -168,7 +168,7 @@ spec: imagePullPolicy: IfNotPresent env: - name: "TEST" - value: "aa" + value: aa terminationMessagePolicy: FallbackToLogsOnError resources: limits: @@ -192,7 +192,7 @@ spec: name: "jwt-key-secret" key: "JWT_SECRET_KEY" - name: "MY_ENV_VAR" - value: "some-value" + value: some-value terminationMessagePolicy: FallbackToLogsOnError resources: null @@ -220,7 +220,7 @@ spec: imagePullPolicy: IfNotPresent env: - name: "TEST" - value: "aa" + value: aa terminationMessagePolicy: FallbackToLogsOnError resources: limits: @@ -244,7 +244,7 @@ spec: name: "jwt-key-secret" key: "JWT_SECRET_KEY" - name: "MY_ENV_VAR" - value: "some-value" + value: some-value terminationMessagePolicy: FallbackToLogsOnError resources: null @@ -329,7 +329,7 @@ spec: imagePullPolicy: IfNotPresent env: - name: "TEST" - value: "aa" + value: aa terminationMessagePolicy: FallbackToLogsOnError resources: limits: @@ -353,7 +353,7 @@ spec: name: "jwt-key-secret" key: "JWT_SECRET_KEY" - name: "MY_ENV_VAR" - value: "some-value" + value: some-value terminationMessagePolicy: FallbackToLogsOnError resources: null @@ -437,7 +437,7 @@ spec: imagePullPolicy: IfNotPresent env: - name: "TEST" - value: "aa" + value: aa terminationMessagePolicy: FallbackToLogsOnError resources: limits: @@ -461,7 +461,7 @@ spec: name: "jwt-key-secret" key: "JWT_SECRET_KEY" - name: "MY_ENV_VAR" - value: "some-value" + value: some-value terminationMessagePolicy: FallbackToLogsOnError resources: null @@ -532,7 +532,7 @@ spec: pathType: Prefix backend: service: - name: custom-custom-pod-with-serv + name: custom-custom-pod-with-service-name port: number: 8080 - path: "/two" @@ -556,7 +556,7 @@ spec: pathType: Prefix backend: service: - name: custom-custom-pod-with-serv + name: custom-custom-pod-with-service-name port: number: 8080 - path: "/two" @@ -602,7 +602,7 @@ spec: pathType: Prefix backend: service: - name: custom-custom-pod-with-serv + name: custom-custom-pod-with-service-name port: number: 8080 - path: "/two"