Added a new flag `--notes` to the `helm template`
command, with the default set to `false`.
If enabled, it will print the rendered `NOTES.txt`
at the end of the manifests.
If `--render-subchart-notes` (this flag already
exists on the `template` command, as it is
inherited from the `install` command) is also
enabled, the output will include the subcharts'
notes as well.
Updated the `install` command's
`--render-subchart-notes` flag description to
clarify that, in the case of the `template`
command, it is only valid when the `--notes` flag
is enabled.
Note: the `template` command uses most of the
`install` command's flags, including
`--render-subchart-notes`.
Updated `action.renderResources()` to format the
root chart's notes, and the subcharts' notes if
the `--render-subchart-notes` flag is enabled, and
return them as a string. The output depends on
whether it is:
- **Dry run**
- Notes are prefixed with the source filename
and separated with `---`.
- For `helm install` / `helm upgrade`, the
`--dry-run` flag enables this behavior.
- The `helm template` command is considered a
dry run by default.
- Example:
```
foo NOTES HERE
bar NOTES HERE
baz NOTES HERE
qux NOTES HERE
```
- **Not a dry run**
- Only the root chart's notes are rendered by
default.
- If the `--render-subchart-notes` flag is
enabled, the subcharts' notes are also
included.
- Each note is prefixed with the source filename
and separated with `---`.
- Example:
```
---
# Source: foo/templates/NOTES.txt
foo NOTES HERE
---
# Source: foo/charts/bar/templates/NOTES.txt
bar NOTES HERE
---
# Source: foo/charts/baz/templates/NOTES.txt
baz NOTES HERE
---
# Source: foo/charts/bar/charts/qux/templates/NOTES.txt
qux NOTES HERE
```
In both cases, the notes are sorted based on the
following conditions:
1. Depth
2. Alphabetical order (since the notes file name
is always the same, the sorting applies to the
chart/subchart name).
Added tests for the following scenarios:
- helm template:
1. On the chart without notes or subcharts
2. `--notes` on chart without notes or
subcharts
3. `--render-subchart-notes` on chart without
notes or subcharts
4. `--notes --render-subchart-notes` on chart
without notes or subcharts
5. On the chart with notes without subcharts
6. `--notes` on chart with notes without
subcharts
7. `--render-subchart-notes` on chart with
notes without subcharts
8. `--notes --render-subchart-notes` on chart
with notes without subcharts
9. On the chart with notes and subchart
10. `--notes` on chart with notes and subchart
11. `--render-subchart-notes` on the chart with
notes and subchart
12. `--notes --render-subchart-notes` on chart
with notes and subchart
13. `--help`
- helm install:
1. On the chart without notes or subcharts
2. `--dry-run` on chart without notes or
subcharts
3. `--render-subchart-notes` on chart without
notes or subcharts
4. `--dry-run --render-subchart-notes` on chart
without notes or subcharts
5. On the chart with notes without subcharts
6. `--dry-run` on chart with notes without
subcharts
7. `--render-subchart-notes` on chart with
notes without subcharts
8. `--dry-run --render-subchart-notes` on chart
with notes without subcharts
9. On a chart with notes and subcharts
10. `--dry-run` on chart with notes and
subcharts
11. `--render-subchart-notes` on chart with
notes and subcharts
12. `--dry-run --render-subchart-notes` on
chart with notes and subcharts
13. `--help`
- helm upgrade:
1. On the chart without notes or subcharts
2. `--dry-run` on chart without notes or
subcharts
3. `--render-subchart-notes` on chart without
notes or subcharts
4. `--dry-run --render-subchart-notes` on chart
without notes or subcharts
5. On the chart with notes without subcharts
6. `--dry-run` on chart with notes without
subcharts
7. `--render-subchart-notes` on chart with
notes without subcharts
8. `--dry-run --render-subchart-notes` on chart
with notes without subcharts
9. On the chart with notes and subcharts
10. `--dry-run` on chart with notes and
subcharts
11. `--render-subchart-notes` on chart with
notes and subcharts
12. `--dry-run --render-subchart-notes` on
chart with notes and subcharts
13. `--help`
Closes#6901
Signed-off-by: Bhargav Ravuri <bhargav.ravuri@infracloud.io>