If a user renames the helm binary, the shell needs to be told that this
new name corresponds to the helm completion function. For example if
the user decides to rename the helm v3 binary to 'helm3', then the
following command extra command would need be run by the user:
complete -o default -F __start_helm helm3.
This commit automates this by adding this extra command to the generated
shell completion script by looking at what binary was used to call the
helm completion command. For example, if the user renames the binary
to helm3 and then calls
helm3 completion bash
the completion script will include a hook for the binary 'helm3' to
the completion script.
A binary rename is one of the two options recommended when users need to
run both helm2 and helm3.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
This allows that any addition to the bash completion logic be
automatically added to the zsh logic.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
I made a few modifications from the original code to fit in with the new
code layout and to clarify a few things. This is a port of #3758
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
we want to force a cache invalidation to ensure that the Capabilities object always has the latest information from the server (Kubernetes server version, available API versions, etc). `kubectl version` forces a cache invalidation every time it's invoked, so this seems like a safe change that is identical to kubectl's behaviour.
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
This ports the functionality of cleanup on fail to v3 as introduced in #4871. This has been tested manually
and would be a good candidate for a new acceptance test.
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
The binary of Helm to use for dynamic completion should be the same
as the actual Helm binary being used. For example, if PATH points
to a version of helm v2, but the user calls bin/helm to use a local
v3 version, then dynamic completion should also use bin/helm.
If not, in this example, the dynamic completion will use the
information returned by helm v2.
This improvement is particularly useful for users that will run both
helm v2 and helm v3 at the same time.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
* Use `apps/v1` for Deployment
* Reformat comments
* Consistently use `nindent` and indent properly
* Introduce named template for selector labels
* Fix label selector in `NOTES.txt`
Signed-off-by: Reinhard Naegele <unguiculus@gmail.com>
It makes sense to limit the history by default. Setting
it to 10 aligns with the default for a ReplicaSet's
`revisionHistoryLimit`.
Fixes: #5157
Signed-off-by: Reinhard Naegele <unguiculus@gmail.com>
Inspired greatly from kubectl code.
Completion is provided for:
--kube-context - where the available contexts are listed
--namespace - where the namespaces of the cluster are listed
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
This is a bug I ran into when working on Helm completion.
I was surprised that it didn't happen when I was using
kubectl, so I investigated and found a PR that fixed this
bug in kubectl:
https://github.com/kubernetes/kubernetes/pull/48553
I duplicated the code in this commit which:
Removes __helm_declare, which is safe to do since
`declare -F` is already replaced to `whence -w` by
__helm_convert_bash_to_zsh().
The problem was that calling "declare" from inside a function
scopes the declaration to that function only. So "declare"
should not be called through __helm_declare() but instead
directly.
To reproduce:
1- setup helm completion in zsh
2- helm --kubeconfig=$HOME/.kube/config statu<TAB>
you will get the error:
__helm_handle_flag:27: bad math expression: operand expected at end of string
Co-authored-by: Kazuki Suda <kazuki.suda@gmail.com>
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
Cobra provides some out-of-the-box debugging for bash completion.
To use it, one must set the variable BASH_COMP_DEBUG_FILE to
some file where the debug output will be written. Many of the
debug printouts indicate the current method name; they do so
by using bash's ${FUNCNAME[0]} variable. This variable is
different in zsh. To obtain the current method name in zsh
we must use ${funcstack[0]}.
This commit adds the proper sed modification to convert from
bash to zsh.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Have fixed up a non-blocking nitpick change from #6310, this just
switches us to use a regular string rather than a string.Builder for the
summary.
Signed-off-by: Thomas O'Donnell <andy.tom@gmail.com>