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>
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>
A chart being installed which only contains CRDs and not
any templates tries to install the resources by default.
The resourceList which is used in this case does not check
if there are resources present in it or not. This commit
adds checks to those particular places where we need to check
if the size of resourceList > 0 during installation and deletion.
Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
Helm had been exposing XDG based variables to end users. This lead
to confusion. For example, if a user wanted to change the cache
location Helm used should they change the XDG variable? Since this
would be like changing the HOME environment variable the answer
is no.
This change adds HELM_*_HOME environment variables to be used
in addition to XDG ones of the same name. Helm will now look
for the Helm specific variable. If not set, Helm will fall
back to XDG locations. If those are not set a default location
will be used. This keeps XDG in use as a default when present,
provides users with the ability to set the location, and removes
XDG from being exposed to end users to avoid confusion.
Closes#7919
Signed-off-by: Matt Farina <matt@mattfarina.com>
* Prints empty repolist in json/yaml if there are no repos and output format is given as json/yaml rather that printing the error msg "no repositories to show"
Signed-off-by: Anshul Verma <anshulvermapatel@gmail.com>
* Prints empty repolist in json/yaml if there are no repos and output format is given as json/yaml rather that printing the error msg "no repositories to show"
Signed-off-by: Anshul Verma <anshulvermapatel@gmail.com>
After the introduction of lazy loading of the Kubernetes client as part
of PR #7831, there is no longer a need to protect against an incomplete
--kube-context value when doing completion.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Upgrade Kubernetes libraries to v0.18.0
Add new lazy load KubernetesClientSet to avoid missing kubeconfig error
In kubernetes v1.18 kubeconfig validation was added. Minikube and Kind
both remove kubeconfig when stopping clusters. This causes and error
when running any helm commands because we initialize the client before
executing the command.
Signed-off-by: Adam Reese <adam@reese.io>
* fix: fixed bug in Dependency.List()
A bug in Dependency.List() caused all compressed charts to flag their dependencies as "missing".
Closes#4431
Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
* removed some files from test fixtures
Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>