pelotech / drone-helm3

Plugin for drone to deploy helm charts using helm3
Apache License 2.0
31 stars 36 forks source link

Run the `helm lint` command when HELM_COMMAND=lint #18

Closed ErinCall closed 4 years ago

ErinCall commented 4 years ago

Fixes #3.

I think this is code-complete, but I'm marking the PR a draft until I've had a chance to test it with a real drone job and helm chart.

ErinCall commented 4 years ago

I ran this with a fixture chart (the helm chart for helm's chartmuseum), and it looks good!

With a valid chart and debug: true:

§ drone exec -include lint
[lint:0] calling *run.Lint.Prepare (step 0)
[lint:1] Generated command: '/usr/bin/helm --namespace erincall --debug lint ./'
[lint:2] calling *run.Lint.Execute (step 0)
[lint:3] ==> Linting ./
[lint:4]
[lint:5] 1 chart(s) linted, 0 chart(s) failed

With an invalid chart and debug: true:

§ drone exec -include lint
[lint:0] calling *run.Lint.Prepare (step 0)
[lint:1] Generated command: '/usr/bin/helm --namespace erincall --debug lint ./'
[lint:2] calling *run.Lint.Execute (step 0)
[lint:3] ==> Linting ./
[lint:4] [ERROR] templates/: template: chartmuseum/templates/pvc.yaml:24:55: executing "chartmuseum/templates/pvc.yaml" at <.Values.persistence.pv.enabled>: nil pointer evaluating interface {}.enabled
[lint:5]
[lint:6] Error: 1 chart(s) linted, 1 chart(s) failed
[lint:7] helm.go:76: [debug] 1 chart(s) linted, 1 chart(s) failed
[lint:8] main.newLintCmd.func1
[lint:9]    /home/circleci/helm.sh/helm/cmd/helm/lint.go:96
[lint:10] github.com/spf13/cobra.(*Command).execute
[lint:11]   /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:826
[lint:12] github.com/spf13/cobra.(*Command).ExecuteC
[lint:13]   /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914
[lint:14] github.com/spf13/cobra.(*Command).Execute
[lint:15]   /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
[lint:16] main.main
[lint:17]   /home/circleci/helm.sh/helm/cmd/helm/helm.go:75
[lint:18] runtime.main
[lint:19]   /usr/local/go/src/runtime/proc.go:203
[lint:20] runtime.goexit
[lint:21]   /usr/local/go/src/runtime/asm_amd64.s:1357
[lint:22] in execution step 0: exit status 12019/12/19 10:03:48 lint : exit code 1

With an invalid chart and debug: false:

§ drone exec -include lint
[lint:0] ==> Linting ./
[lint:1] [ERROR] templates/: template: chartmuseum/templates/pvc.yaml:24:55: executing "chartmuseum/templates/pvc.yaml" at <.Values.persistence.pv.enabled>: nil pointer evaluating interface {}.enabled
[lint:2]
[lint:3] Error: 1 chart(s) linted, 1 chart(s) failed
2019/12/19 10:04:19 lint : exit code 1