Helm: `lint` reports error when required value is not set in `values.yaml`

Created on 19 Dec 2019  Â·  3Comments  Â·  Source: helm/helm

Description

If a chart has required settings (defined in values.schema.json), but those settings don't have a default provided in values.yaml, helm lint will always report an error, even when the values are set “externally” to the chart.

For instance, with the following chart:

$ tree -F .
.
├── Chart.yaml
├── templates/
├── values.schema.json
├── values.test.yaml
└── values.yaml

$ tail -n +1 Chart.yaml values.schema.json values.yaml values.test.yaml
==> Chart.yaml <==
---
apiVersion: v2
name: foobar
version: 0.1.0
appVersion: 0.1.0

==> values.schema.json <==
{
  "$schema": "https://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "foo": {
      "type": "string"
    },
    "bar": {
      "type": "string"
    }
  },
  "additionalProperties": false,
  "required": [
    "foo",
    "bar"
  ]
}

==> values.yaml <==

==> values.test.yaml <==
---
foo: foo
bar: bar

This is an expected behavior:

$ helm lint .; echo $?
==> Linting .
[INFO] Chart.yaml: icon is recommended
[ERROR] values.yaml: - (root): foo is required
- (root): bar is required

[ERROR] templates/: values don't meet the specifications of the schema(s) in the following chart(s):
foobar:
- (root): foo is required
- (root): bar is required


Error: 1 chart(s) linted, 1 chart(s) failed
1

But this should not report any errors:

$ helm lint --set foo=foo --set bar=bar .; echo $?
==> Linting .
[INFO] Chart.yaml: icon is recommended
[ERROR] values.yaml: - (root): foo is required
- (root): bar is required


Error: 1 chart(s) linted, 1 chart(s) failed
1

$ helm lint --set foo=foo --set bar=bar .; echo $?
==> Linting .
[INFO] Chart.yaml: icon is recommended
[ERROR] values.yaml: - (root): foo is required
- (root): bar is required


Error: 1 chart(s) linted, 1 chart(s) failed
1

$ helm lint -f values.test.yaml .; echo $? 
==> Linting .
[INFO] Chart.yaml: icon is recommended
[ERROR] values.yaml: - (root): foo is required
- (root): bar is required


Error: 1 chart(s) linted, 1 chart(s) failed
1

Expected behavior

helm lint should not report an error when required values are set “externally”.

Installation details

Output of helm version: version.BuildInfo{Version:"v3.0.2", GitCommit:"19e47ee3283ae98139d98460de796c1be1e3975f", GitTreeState:"clean", GoVersion:"go1.13.5"}
Output of kubectl version: not relevant
Cloud Provider/Platform (AKS, GKE, Minikube etc.): not relevant

bug

Most helpful comment

So I did a bit of digging, and it looks like the values specified on the command line aren't passed down to the function that lints a chart's values.yaml file

https://github.com/helm/helm/blob/v3.0.2/pkg/lint/lint.go#L33

I might take a stab at pushing up a fix depending on how lost I get or not in the code

All 3 comments

This just bit me earlier today. Thanks for already reporting the issue!

So I did a bit of digging, and it looks like the values specified on the command line aren't passed down to the function that lints a chart's values.yaml file

https://github.com/helm/helm/blob/v3.0.2/pkg/lint/lint.go#L33

I might take a stab at pushing up a fix depending on how lost I get or not in the code

Closed by #7984

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sgoings picture sgoings  Â·  3Comments

bq1756 picture bq1756  Â·  3Comments

danielcb picture danielcb  Â·  3Comments

itnilesh picture itnilesh  Â·  3Comments

dkirrane picture dkirrane  Â·  3Comments