From 37bcaf1dd57731e39e6ecfb4c2b42c287635c08f Mon Sep 17 00:00:00 2001 From: Shiv Jha-Mathur Date: Thu, 13 Oct 2022 13:16:14 +0530 Subject: [PATCH 1/5] deps: update Go, Kubeconform, Alpine, and Helm --- .github/workflows/publish.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 1aac756..cf15ec6 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -5,8 +5,8 @@ on: env: image: ghcr.io/shivjm/helm-kubeconform-action - go: "1.18.3" - helm: "v3.9.4" + go: "1.19.2" + helm: "v3.10.1" schema: "master" kubeconform: "v0.4.14" From 27340888de58db95170813a005d24e07b65aee1c Mon Sep 17 00:00:00 2001 From: Shiv Jha-Mathur Date: Thu, 13 Oct 2022 13:21:52 +0530 Subject: [PATCH 2/5] build(docker): remove defaults for build args --- Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 38bfc1d..91a06a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -ARG GO_VERSION=1.16.5 +ARG GO_VERSION -ARG KUBECONFORM_VERSION=v0.4.11 +ARG KUBECONFORM_VERSION FROM golang:$GO_VERSION-alpine AS builder @@ -14,11 +14,10 @@ FROM ghcr.io/yannh/kubeconform:$KUBECONFORM_VERSION-alpine AS kubeconform # for curl & unzip FROM alpine:3.14 AS downloader -ARG HELM_VERSION=v3.7.0 +ARG HELM_VERSION RUN apk add -q --no-cache curl -# https://get.helm.sh/helm-v3.7.0-linux-amd64.tar.gz RUN mkdir /helm && cd /helm && curl -sSL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar xzf - FROM gcr.io/distroless/static@sha256:912bd2c2b9704ead25ba91b631e3849d940f9d533f0c15cf4fc625099ad145b1 From 510c8941cb28b2b07106a02502437f0bf6733d35 Mon Sep 17 00:00:00 2001 From: Shiv Jha-Mathur Date: Wed, 14 Feb 2024 16:48:14 +0530 Subject: [PATCH 3/5] docs: update README --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68d43c1..4bf7905 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Helm Kubeconform Action -A flexible GitHub Action to validate [Helm charts](https://helm.sh/docs/topics/charts/) with [Kubeconform](https://github.com/yannh/kubeconform/). +A flexible GitHub Action to validate [Helm +charts](https://helm.sh/docs/topics/charts/) with +[Kubeconform](https://github.com/yannh/kubeconform/). The target may +be either a single chart directory or a directory containing multiple +charts, at any level. ## Usage From c8c211bea42ffc3c54987364d5571c57840e8f70 Mon Sep 17 00:00:00 2001 From: Shiv Jha-Mathur Date: Wed, 14 Feb 2024 16:50:01 +0530 Subject: [PATCH 4/5] fix: remove extraneous output when log level is unparseable --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index e6e7274..5886877 100644 --- a/main.go +++ b/main.go @@ -61,7 +61,7 @@ func main() { level, err := zerolog.ParseLevel(cfg.LogLevel) if err != nil { - log.Fatal().Stack().Err(err).Msgf("%+v\n", err) + log.Fatal().Err(err).Msgf("Could not parse log level") return } From 52c4151e3b4129f945040ec8648a9ff549e92237 Mon Sep 17 00:00:00 2001 From: Shiv Jha-Mathur Date: Wed, 14 Feb 2024 17:09:58 +0530 Subject: [PATCH 5/5] fix: correctly handle kubeconform not being executed --- main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 5886877..588f230 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "encoding/json" "errors" "io/fs" "os" @@ -128,7 +129,16 @@ func run(cfg Config, additionalSchemaPaths []string, updateDependencies bool) er // , // so instead we shell out to it output, err := runKubeconform(manifests, cfg.Kubeconform.path, cfg.Strict, additionalSchemaPaths, cfg.KubernetesVersion) - logger.Err(err).RawJSON("kubeconform", output).Msg("") + + // if kubeconform could not be executed, the output will not be + // in JSON format + var js json.RawMessage + if json.Unmarshal([]byte(output), &js) == nil { + logger.Err(err).RawJSON("kubeconform", output).Msg("") + } else { + logger.Err(err).Msgf("kubeconform failed: %s", output) + } + if err != nil { validationsErrors = append(validationsErrors, err) } @@ -143,6 +153,7 @@ func run(cfg Config, additionalSchemaPaths []string, updateDependencies bool) er if validationsErrors != nil { return errors.New("Validation failed") } + return nil }