Commit Graph
177 Commits
Author SHA1 Message Date
Joe Julian 7f4eb407c6 add missing template directory to badcrdfile testdata
Signed-off-by: Joe Julian <me@joejulian.name>
2025-07-17 13:14:24 -07:00
Joe Julian 08909e030b Merge pull request #31019 from zachburg/templates_lint
Return early when linting if the `templates/` directory does not exist
2025-07-17 11:08:20 -07:00
Zach Burgess 35434947a3 Return a lint warning if templates/ does not exist.
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 21:02:11 -07:00
Zach Burgess b6e3301bef Merge branch 'helm:main' into templates_lint 2025-07-07 20:46:46 -07:00
Zach Burgess fe11438715 Raise error instead of warning if crds/ is not a valid directory
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 20:39:27 -07:00
Zach Burgess eea2d4577b Raise an error if the templates/ dir is not valid and return early.
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 20:31:48 -07:00
Zach Burgess 3a318c2fa3 Update crds.go after https://github.com/helm/helm/pull/31029
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 14:42:08 -07:00
Zach Burgess 81af3c9570 Merge branch 'helm:main' into crds_lint 2025-07-07 14:38:58 -07:00
Zach Burgess cc85352a0e Use assert.Len instead of assert.Lenf
The default message from testify is descriptive enough.

Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 14:28:19 -07:00
Zach Burgess c59a097209 Remove duplicate test case from crds_test.go
The "good" test case for CRDs is done in `TestGoodChart` in lint_test.go.

Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 14:19:41 -07:00
Zach Burgess bf9084a16a Rename validateCrdApiVersion to validateCrdAPIVersion
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 11:09:11 -07:00
Zach Burgess 357957b0d3 Use testify and add a CRD to the goodone test case.
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 11:04:31 -07:00
George Jenkins 4c674728d2 Privatize 'k8sYamlStruct'
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
2025-07-05 11:48:22 -07:00
Zach Burgess b703d5b4bb Return early when linting if the templates/ dir does not exist
The `vaildateTemplatesDir` function would still return `nil` if the directory doesn't exist,
so the early return that was documented never occurs.

Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-01 14:29:40 -07:00
Zach Burgess 562ff982cb Early return if the /crds directory does not exist and don't silently discard the error from os.Stat.
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-01 14:07:50 -07:00
Zach Burgess d6ddd8e661 Document that attempting to parse YAML checks that the CRD is not a
template

Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-01 14:07:50 -07:00
Zach Burgess bc35ea5ad7 Fix comment in pkg/lint/rules/testdata/invalidcrdsdir/values.yaml
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-01 14:07:50 -07:00
Zach Burgess 21b9aa3d94 Lint the crds/ directory.
This checks that the `crds/` dir only contains YAML files that define
K8s resources with `kind: CustomResourceDefinition`.

Checking that the YAML files are not templates will be done in a
separate commit.

Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-01 14:07:50 -07:00
findnature ac8d2f9aed refactor: use slices.Contains to simplify code
Signed-off-by: findnature <cricis@aliyun.com>
2025-05-02 09:43:25 +08:00
George Jenkins ecf1730689 Merge pull request #13460 from justenstall/stdlib-errors-2
fix: replace "github.com/pkg/errors" with stdlib "errors" package
2025-04-23 15:47:35 -07:00
Matt Farina fcd37bcea7 Merge pull request #30783 from rpolishchuk/investigate-TestValidateChartIconPresence
fix: chart icon presence test
2025-04-23 20:58:14 +01:00
Rostyslav Polishchuk 1c8d1e375f fix: chart icon presence test
The `TestValidateChartIconPresence` test fails when run after
`TestValidateChartIconURL` as they both are using a global
variable `badChart.Icon`

```
: go test -v -test.shuffle 1 -run '^(TestValidateChartIconPresence|TestValidateChartIconURL)$' ./pkg/lint/rules/
-test.shuffle 1
=== RUN   TestValidateChartIconURL
--- PASS: TestValidateChartIconURL (0.00s)
=== RUN   TestValidateChartIconPresence
    chartfile_test.go:171: validateChartIconPresence to return a linter error, got no error
--- FAIL: TestValidateChartIconPresence (0.00s)
FAIL
FAIL    helm.sh/helm/v4/pkg/lint/rules  0.051s
FAIL

: go test -v -test.shuffle 2 -run '^(TestValidateChartIconPresence|TestValidateChartIconURL)$' ./pkg/lint/rules/
-test.shuffle 2
=== RUN   TestValidateChartIconPresence
--- PASS: TestValidateChartIconPresence (0.00s)
=== RUN   TestValidateChartIconURL
--- PASS: TestValidateChartIconURL (0.00s)
PASS
ok      helm.sh/helm/v4/pkg/lint/rules  0.050s
```

This commit:

1. Remove dependency on global variable
2. Explicitly set the state of the test object.

Signed-off-by: Rostyslav Polishchuk <rostyslavp@google.com>
2025-04-22 18:56:13 +00:00
Justen Stall 3877ec9049 fix golangci-lint issues
Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com>
2025-04-21 12:44:40 -04:00
Justen Stall 065e2eb3eb updates after merge conflict resolution
Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com>
2025-04-21 12:17:50 -04:00
Justen Stall 280a9ddbdb Merge branch 'main' into stdlib-errors-2
Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com>
2025-04-21 12:13:10 -04:00
Edward Miller 629780a34a fix: reapply error message fix
Signed-off-by: Edward Miller <edmiller287@gmail.com>
2025-04-18 19:18:55 +01:00
Edward Miller 14a468f24d Add chartutil.StrictLoadChartfile for strict (WARNING-level) lint
Signed-off-by: Edward Miller <edmiller287@gmail.com>
2025-04-18 19:13:40 +01:00
Edward Miller 00f8561ad4 fix(pkg/lint): unmarshals Chart.yaml strictly
When "helm lint" is run, it now errors on invalid chartfiles,
e.g. those with duplicate keys

Closes #12381

Signed-off-by: Edward Miller <edmiller287@gmail.com>
2025-04-18 19:13:40 +01:00
Robert Sirchia da096e1b7a Merge pull request #30752 from benoittgt/bump-golangci-lint-action
Bump golangci lint to last major version and fix static-check errors
2025-04-16 15:50:55 -04:00
Matt Farina 0dffc580b0 Simpligy the JSON Schema checking
A new library was introduced that provides JSON Schema checking for
newer versions of the schema. In Helm v4, there is no need to have
two packages doing the JSON schema validation. The message output
can have breaking changes.

This change moves everything to the newer library. It also uses a
wrapper error to enable a clean Helm only interface for the
public Go API validation functions. This would enable the replacement
of the Schema validation library, if needed, without breaking the
Go API contract.

Signed-off-by: Matt Farina <matt.farina@suse.com>
2025-04-14 19:32:01 -04:00
Benoit Tigeot eb65ce280b could apply De Morgan's law
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
2025-04-14 11:11:37 +02:00
George Jenkins be2b84685a cleanup: Remove Helm v2 template lint rules
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
2025-04-05 10:34:59 -07:00
Matt Farina 61d3eca55c Move pkg/chart to pkg/chart/v2 to prepare for v3 charts
This change moves the code, updates the import locations, and
adds a doc.go file to document what the v2 package is for.

This is part of HIP 20 for v3 charts

Signed-off-by: Matt Farina <matt.farina@suse.com>
2025-02-25 15:20:44 -05:00
Matt Farina 5c0deec327 Moving chartutil to chart/util
chartutil was originally created to operate on protobufs which are
no longer part of Helm. The util package makes more sense to be
part of the chart package.

This change is part of the HIP 20 to create v3 charts and
explicitly call out v2 charts. The changes for this are in smaller
bite size changes.

Signed-off-by: Matt Farina <matt.farina@suse.com>
2025-02-21 15:25:55 -05:00
George Jenkins 415c7e10fd Merge pull request #13516 from TerryHowe/new-lint
chore: fix problems with latest lint
2025-01-23 18:30:23 -08:00
George Jenkins bd897c96fb Merge pull request #13601 from gjenkins8/cleanup_values_lint
cleanup: Remove superseded 'lint/rules.Values' function
2025-01-08 16:46:19 -08:00
George Jenkins 1c807df5ba cleanup: Remove superceeded 'lint/rules.Values' function
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
2025-01-05 14:05:12 -08:00
George Jenkins 3b9cce9669 cleanup: Remove 'ProcessDependenciesWithMerge'
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
2025-01-05 10:09:16 -08:00
Matt Farina 2236294119 Updating to helm.sh/helm/v4
Since Helm is going through breaking changes with Helm v4, the version path to
Helm needs to be updated.

Signed-off-by: Matt Farina <matt.farina@suse.com>
2024-12-26 16:33:51 -05:00
Terry Howe 569f62e58b chore: fix problems with latest lint
Signed-off-by: Terry Howe <terrylhowe@gmail.com>
2024-12-10 10:40:37 -07:00
Justen Stall 63cf42a843 fix: replace "github.com/pkg/errors" with stdlib "errors" package
Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com>
2024-11-18 11:35:59 -05:00
Zach Burgess 0cc78c6ac3 Fix typo in pkg/lint/rules/chartfile_test.go
Signed-off-by: Zach Burgess <zachburg@google.com>
2024-11-04 17:41:39 -08:00
anessi acf7158565 feat(helm): add --skip-schema-validation flag to helm 'install', 'upgrade' and 'lint'
When --skip-schema-validation is set, any schema contain in the helm chart is ignored. Defaults to 'false'.

Closes #10398

Signed-off-by: anessi <16045045+anessi@users.noreply.github.com>
2024-06-25 16:43:48 +02:00
Robert Sirchia d58d7b3762 Fixing all the linting errors
Cleaned up all the linting errors we are getting.

Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
2024-03-11 17:13:34 -04:00
Matt Farina 8e6a5149d2 validation fix
Signed-off-by: Matt Farina <matt.farina@suse.com>
2024-02-07 10:54:15 -05:00
Antoine Deschênes 869c1d2560 lint: Add --kube-version flag to set capabilities and deprecation rules
Signed-off-by: Antoine Deschênes <antoine@antoinedeschenes.com>
2024-01-08 19:35:41 -05:00
Joe Julian 762a1c7adc Merge pull request #12688 from mattfarina/bump-go-1.21
Update to Go 1.21 for builds
2024-01-08 13:53:56 -08:00
Matt Farina 83a76cea6a Merge pull request #9176 from dastrobu/#9169/lint-dependency-shadowing
lint and validate dependency metadata to reference dependencies with …
2024-01-08 15:56:29 -05:00
Matt Farina 847369c184 Update to Go 1.21 for builds
Noteis:
1. This moves golangci scanning to a GitHub action. This will
   enable inline pointers to issues in the PR where linting fails.
2. Go 1.21 is specified in the go.mod because Kubernetes libs
   require it.
3. The lint issues were removed. Some were fixed while others
   were handled by skipping linting or using _ as an argument.
   Many of these can be refactored later for better cleanup.

Signed-off-by: Matt Farina <matt.farina@suse.com>
2024-01-08 15:48:36 -05:00
Matt Farina 5a1475ee36 Merge pull request #11294 from Juneezee/test/t.TempDir
test: replace `ensure.TempDir` with `t.TempDir`
2023-09-14 09:55:51 -04:00