Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #9

Merged
merged 5 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 13 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"encoding/json"
"errors"
"io/fs"
"os"
Expand Down Expand Up @@ -61,7 +62,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
}

Expand Down Expand Up @@ -128,7 +129,16 @@ func run(cfg Config, additionalSchemaPaths []string, updateDependencies bool) er
// <https://github.com/yannh/kubeconform/blob/dcc77ac3a39ed1fb538b54fab57bbe87d1ece490/cmd/kubeconform/main.go#L47>,
// 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)
}
Expand All @@ -143,6 +153,7 @@ func run(cfg Config, additionalSchemaPaths []string, updateDependencies bool) er
if validationsErrors != nil {
return errors.New("Validation failed")
}

return nil
}

Expand Down
Loading