fix(lint): reject invalid chart names#32075
Open
AkashKumar7902 wants to merge 2 commits intohelm:mainfrom
Open
fix(lint): reject invalid chart names#32075AkashKumar7902 wants to merge 2 commits intohelm:mainfrom
AkashKumar7902 wants to merge 2 commits intohelm:mainfrom
Conversation
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Helm chartfile linting to reject invalid chart names and applies the same rule/tests to both the v2 and v3 chartfile lint rule sets.
Changes:
- Add a stricter chart name validator (lowercase letters/digits with internal dashes; no leading/trailing dash).
- Improve invalid-name lint output by appending a clearer constraint message.
- Replace fixture-based tests with table-driven test cases for chart name validation (v2 and v3).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/chart/v2/lint/rules/chartfile.go | Adds regex-based chart name validation and a clearer guidance message for lint failures. |
| pkg/chart/v2/lint/rules/chartfile_test.go | Converts chart-name validation coverage to a table-driven test set. |
| internal/chart/v3/lint/rules/chartfile.go | Mirrors the v2 regex-based chart name validation for the v3 lint path. |
| internal/chart/v3/lint/rules/chartfile_test.go | Mirrors the v2 table-driven chart-name validation tests for the v3 lint path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Promptless prepared a documentation update related to this change. Triggered by this PR Documents the stricter chart name validation requirements in the Chart Best Practices guide, clarifying that chart names must use only lowercase letters, numbers, and dashes, and must start and end with a lowercase letter or number. Updated both v3 and v4 documentation. |
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Closes #10537.
This updates chartfile lint validation so chart names must use lower case letters, numbers, and internal dashes. The new lint rule rejects names with uppercase letters, dots, underscores, or leading/trailing dashes and reports a clearer pattern message.
The same validation is used by chart creation, including starter-based chart creation, so
helm createdoes not scaffold chart names thathelm lintrejects. The same validation and table-driven coverage are applied to the v2 and v3 chart paths so both stay consistent.Special notes for your reviewer:
Validation run locally:
go test -count=1 ./pkg/chart/v2/lint/... ./internal/chart/v3/lint/... ./pkg/chart/v2/util ./internal/chart/v3/utilgo test ./pkg/action -run TestLint -count=1go test -count=1 ./pkg/cmd -run TestCreatego run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.3 run --allow-parallel-runners ./pkg/chart/v2/lint/rules ./internal/chart/v3/lint/rules ./pkg/chart/v2/util ./internal/chart/v3/utilscripts/validate-license.shgit diff --checkIf applicable:
docs neededlabel should be applied if so)