When #8156 was merged it had the side effect that all hooks were
run all the time. All the hooks were put in the flow of the
content rendered and sent to Kubernetes on every command.
For example, if you ran the following 2 commands the test hooks
would run:
helm create foo
helm install foo ./foo
This should not run any hooks. But, the generated test hook is run.
The change in this commit moves the writing of the hooks to output
or disk back into the template command rather than in a private
function within the actions. This is where it was for v3.2.
One side effect is that post renderers will not work on hooks. This
was the case in v3.2. Since this bug is blocking the release of v3.3.0
it is being rolled back. A refactor effort is underway for this section
of code. post renderer for hooks should be added back as part of that
work. Since post renderer hooks did not make it into a release it
is ok to roll it back for now.
There is code in the cmd/helm package that has been duplicated from
pkg/action. This is a temporary measure to fix the immediate bug
with plans to correct the situation as part of a refactor
of renderResources.
Signed-off-by: Matt Farina <matt@mattfarina.com>
* fix(sdk): Polish the downloader/manager package error return
Close#8471
Signed-off-by: Dong Gang <dong.gang@daocloud.io>
* Modify the repositories validation function `resloveRepoNames` and add a
unit test.
Signed-off-by: Dong Gang <dong.gang@daocloud.io>
* Remove wrong commit
Signed-off-by: Dong Gang <dong.gang@daocloud.io>
No longer using the 'syscall' package, as further reading into this
issue has shown that 'syscall' is deprecated/locked down. Additional
issues posted on Golang's github indicates that the newer preferred
mechanism to get the file descriptor for stdin is: int(os.Stdin.Fd())
Signed-off-by: Jack Weldon <jack.weldon.scm@gmail.com>
Previously in Helm 2, 'helm repo add' would prompt for your password if
you only provided the --username flag. This helps prevent someone's
credentials from being logged in their shell's history, from showing
up in process lists, and from being seen by others nearby.
Closes#7174
Signed-off-by: Jack Weldon <jack.weldon.scm@gmail.com>
* fix(template):Issue:helm template with --output-dir doesn't write template with a hook to file
Close#7836
Signed-off-by: Dong Gang <dong.gang@daocloud.io>
* fix go file style
Signed-off-by: Dong Gang <dong.gang@daocloud.io>
* fix go file style
Signed-off-by: Dong Gang <dong.gang@daocloud.io>
The warnings introduced when a chart has been deprecated is displayed on standard out. This is a regression for users piping the output of `helm template` from a deprecated chart to `kubectl`. This changes the error message to display on standard error instead.
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
This commit allows to use shell completion to obtain the list of
available versions of a chart referenced in a 'repo/chart' format.
It applies to:
- helm install
- helm template
- helm upgrade
- helm show
- helm pull
The 'repo/chart' argument must be present for completion to be triggered
(or else we don't yet know which chart to fetch the versions for).
The completion can be slow for the 'stable' repo because its index
file takes some time to parse.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Making each shell a subcommand of the 'completion' has multiple
advantages:
- simplifies the code,
- allows to have different flags for each shell,
for example, a future `--no-descriptions` flag for fish only,
- allows to tailor the help text per shell.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Cobra 1.0 introduces custom Go completions. This commit replaces Helm's
own solution to use Cobra's solution.
This allows to completely remove Helm's internal "completion" package.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
The flags added by addChartPathOptionsFlags() are used for
`helm install` and `helm upgrade` but also for `helm template`,
`helm show` and `helm pull`. Because of the latter three, we should not
use the word 'install' in the description of the --version and --verify
flags.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Having both the `showCmd` and the `subCmd` passed to `addShowFlags()`
can easily lead to mistakes in using the wrong command.
Instead, `addShowFlags()` should only focus on the `subCmd`
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Persistent flags are available on subcommands. Status does not
need the persistent nature.
Closes#8149
Signed-off-by: Matt Farina <matt@mattfarina.com>
Fix `repo add` and `repo update` to use a repository cache set
using `--repository-cache` flag
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Signed-off-by: Trond Hindenes <trond@hindenes.com>
Cobra 1.0.0 introduces support for Custom Go Completions. However,
there is a small difference compared to helm's existing solution.
The difference is that Cobra will not complete sub-commands if there
are any dynamic completion functions registered.
The way helm implemented plugin completions had the dynamic completion
function associated with the root plugin command (e.g. 2to3); with
Cobra, this prevents any of the sub-commands of the plugin to be
completed (i.e., 2to3 <TAB> will not show the static sub-commands).
The solution is to only register the dynamic completion function for a
plugin command that doesn't have any further sub-commands. This allows
all sub-commands to be completed properly, and when there are no more
levels of sub-commands, the dynamic completion is called.
This commit had to make two changes to achieve this:
1- refactor the load_plugins.go file to extract the logic to call
the plugin.complete executable (for dynamic completions), so that
it could be added to each final sub-command.
2- load the static completion not only for the "completion" command like
before, but also for the "__complete" command, so that when the
__complete command is called for dynamic completion of a sub-command,
it is aware of the sub-command in question.
The second change is also valuable for the future support of completion
for the Fish shell. Completion for the fish shell uses the __complete
command not only for dynamic completions but also for basic command and
flag completion. This implies that the __complete command must be aware
of the plugins sub-commands, and therefore that the plugin's static
completion be loaded.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>