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>
Add a unit test that proves the digest of the received content being
checked. The check should ensure that the digest of the received content
is identical to the digest provided by the manifest in the layers[0]
descriptor. This check is currently implemented in containerd, so the
unit test ensures security in the case a breaking change is made in
containerd.
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
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>
With a large list of charts, `helm chart list` will crash with the
following message:
```
$ helm chart list --debug
Error: open
/home/me/.cache/helm/registry/cache/blobs/sha256/109971e44d63f7fd11fff60d19db41c2429a136943be2e3f8fd3e4c165156536:
too many open files
helm.go:75: [debug] open
/home/me/.cache/helm/registry/cache/blobs/sha256/109971e44d63f7fd11fff60d19db41c2429a136943be2e3f8fd3e4c165156536:
too many open files
```
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
If stat returns an error other than the directory not existing
it was unhandled. When IsDir is called in one of these situations
it causes a panic.
Closes#8181
Signed-off-by: Matt Farina <matt@mattfarina.com>
This file was previously used for shell completions but is
no longer in use as there is a new completions system in place
and there has been for some time.
The contents of this file were out of date and reflect Helm v2.
Closes#8186
Signed-off-by: Matt Farina <matt@mattfarina.com>
Persistent flags are available on subcommands. Status does not
need the persistent nature.
Closes#8149
Signed-off-by: Matt Farina <matt@mattfarina.com>
Since Tiller is no longer part of Helm v3, internal documentation
language about Tiller can be removed
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>
Since we've moved to Go 1.14, golangci-lint has been silently failing.
This commit updates to a compatible version.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>