Commit Graph
211 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 1002ec5ae9 Update tests in lint_test.go
Signed-off-by: Zach Burgess <zachburg@google.com>
2025-07-07 21:11:05 -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
Zach Burgess dadaff716a Merge branch 'helm:main' into crds_lint 2025-07-07 09:48:38 -07:00
Zach Burgess 6e30619d8f Merge branch 'helm:main' into templates_lint 2025-07-07 09:34:04 -07:00
George Jenkins 4c674728d2 Privatize 'k8sYamlStruct'
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
2025-07-05 11:48:22 -07:00
George Jenkins a3bcc5b184 fix: 'TestRunLinterRule' stateful test
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
2025-07-02 21:14:35 -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 e4c88faeff Update test assertions
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 e414695a5b fix
Signed-off-by: Edward Miller <edmiller287@gmail.com>
2025-04-19 13:41:43 +01: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 MillerandAndrew Block 9d43f70643 Update error message
Co-authored-by: Andrew Block <andy.block@gmail.com>
Signed-off-by: Edward Miller <55854159+edbmiller@users.noreply.github.com>
2025-04-18 19:13:40 +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 a8d39e6a17 Merge pull request #13576 from gjenkins8/consolidate_lint_run_functions
refactor: Consolidate lint package Run() functions
2025-01-07 08:41:18 -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
George Jenkins edabef668a more tidy
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
2024-12-27 21:17:35 -08:00
George Jenkins 63623665ae refactor: Consolidate lint package Run() functions
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
2024-12-27 21:12:48 -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