Added flag `--notes` to `helm template` command
with default set to `false`. If enabled, it will
print the rendered `NOTES.txt` at the end of the
manifests. If `--render-subchart-notes` (flag
already exists on `template` command as it is part
of `install` command's flags that `template` uses)
is also enabled, the output will include the
subchart's notes also.
Updated the `install` command's
`--render-subchart-notes` flag's description to
include additional information (that it is only
valid when `--notes` flag is enabled) in case of
`template` command. Note: `template` command uses
most of the `install` command's flags, including
`--render-subchart-notes`.
Updated `action.renderResources()` to format root
chart's notes, and subcharts' notes if
`--render-subchart-notes` flag is enabled, and
return as a string based on whether it is:
- Dry run, the notes are prefixed with the source
filename and `---` separator. For helm install/
upgrade commands, the `--dry-run` flag can be
used to enable dry run. The helm template
command is considered a dry run by default.
Note: The `template` command is considered a dry
run by default. For eg:
```
foo NOTES HERE
bar NOTES HERE
baz NOTES HERE
qux NOTES HERE
```
- Not a dry run, render the root chart's notes. If
the `--render-subchart-notes` flag is enabled,
since the subcharts' notes are also included,
separate each note with a newline at the end.
For eg:
```
---
# 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
```
The notes in both cases are sorted based on the
following 2 conditions:
1. Depth
2. Alphabetical (since the notes file's name will
be the same for any chart/subchart, the order
gets applied to the chart/subchart's 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`
Related to #6901
Signed-off-by: Bhargav Ravuri <bhargav.ravuri@infracloud.io>