|
| 1 | +--- |
| 2 | +hip: 0019 |
| 3 | +title: "Add Exclude File Option to Helm Lint Command" |
| 4 | +authors: Danilo Patrucco |
| 5 | +created: "2024-07-03" |
| 6 | +type: "feature" |
| 7 | +status: "draft" |
| 8 | +--- |
| 9 | + |
| 10 | +## Abstract |
| 11 | +This proposal suggests enhancing the `helm lint` command to exclude specific files or patterns from linting through a `.helmlintignore` file, similar to `.gitignore` or `.helmignore`. Additionally, a `--lint-ignore-file` flag will be introduced to specify alternative locations for the `.helmlintignore` file, facilitating its use in projects with multiple sub-charts. |
| 12 | +## Motivation |
| 13 | +In large Helm charts, certain files or configurations may deviate from standard linting rules but are accepted by the maintainers. Currently, `helm lint` evaluates all files within a chart, leading to irrelevant warnings or errors. An exclusion option and the ability to specify ignore file locations would allow developers to better manage lint results. |
| 14 | +## Rationale |
| 15 | +This proposal aims to give developers and integrators greater control over the linting process by allowing exclusions for: |
| 16 | +- Files imported or managed by third parties that are not directly editable. |
| 17 | +- Files that may not conform to static linting rules. |
| 18 | +- Files containing intentional deviations from standard practices due to specific deployment scenarios. |
| 19 | +The `.helmlintignore` file will support simple patterns to match files and directories for easy exclusion management. The `--lint-ignore-file` flag enhances this by allowing centralized management of lint exclusions in complex projects. |
| 20 | +## Specification |
| 21 | +### `.helmlintignore` File Format |
| 22 | +The `.helmlintignore` file allows chart developers to specify filenames or glob patterns to exclude from linting. The format is straightforward, with one pattern per line, similar to `.gitignore` files. |
| 23 | +#### Example |
| 24 | + ``` |
| 25 | +# .helmlintignore file example |
| 26 | +template/test/test.sh # Exclude this file from linting |
| 27 | +template/test/test.yaml {{template "fullname" .}} # Exclude this specific line from findings in this specific file (error is still detected but no output is generated) |
| 28 | +``` |
| 29 | +Patterns can be a simple `path/to/my/file` to exclude a whole file, or `path/to/my/file line.triggering.error` to ignore specific error-triggering lines in the error output. |
| 30 | +### Command Behavior |
| 31 | +When `helm lint` is executed, it will first check for the presence of a `.helmlintignore` file in the chart directory or at a specified location using the `--lint-ignore-file` flag. This allows the command to parse the file and exclude any files or directories matching the patterns. Additionally, if a file contains a specific error line that matches a pattern, that error will not be displayed. |
| 32 | +## Backwards Compatibility |
| 33 | +This proposal introduces no breaking changes. Charts without a `.helmlintignore` file or without using the `--lint-ignore-file` flag will function as they currently do. |
| 34 | +## Security Implications |
| 35 | +No significant security implications are expected. The `.helmlintignore` file is processed locally by `helm lint` without modifying chart content or involving network activity. |
| 36 | +## How to Teach This |
| 37 | +Documentation for the `.helmlintignore` file and the `--lint-ignore-file` flag will be included in the official Helm docs under the `helm lint` section. Examples and common patterns will be provided to aid new users. |
| 38 | +## Reference Implementation |
| 39 | +No reference implementation yet. Post-acceptance, an issue will be created in the Helm community GitHub repository to add the HIP |
| 40 | +## Open Issues |
| 41 | +- Finalizing an effective and user-friendly pattern syntax for the `.helmlintignore` file. |
| 42 | +- Potential inclusion of in-file annotations for temporarily excluding specific chart sections from linting. |
| 43 | +## Rejected Ideas |
| 44 | +None at this time. |
| 45 | +## References |
| 46 | +- This proposal is in line with the practices outlined in [HIP-0001](https://github.com/helm/community/blob/master/hips/hip-0001.md). |
0 commit comments