The completion of charts was using 'helm search repo' which can be
quite slow as it must parse the entire yaml of every repo cache file.
Using completion for a chart name can end up triggering multiple calls
to 'helm search'; this makes the user experience poor, as there is
a delay of over a second at every <TAB> press.
This commit creates a cache file for each repo which contains the list
of charts for that repo. The completion logic then uses this new
cache file directly and obtains the chart names very quickly.
With only the stable repo configured, this optimization makes the
completion of charts about 85 times faster, going from 1.2 seconds to
0.014 seconds; such a difference gives a much better user experience
when completing chart names.
On the other hand, adding the creation of the chart list cache file to
'helm repo update' or 'helm repo add' is pretty much negligible compared
to the downloading of the index file.
It is also worth noting that when more repos are configured,
'helm search repo' only becomes slower, while the completion logic that
uses the new chart list cache file will not be affected as it only looks
for the single relevant repo file.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
* fix(cmd): Fixes logging on action conf init error
Errors relating to initializing the action config cause helm to exit silently,
except when in debug mode. This now emits the useful error.
Closes#6863
Signed-off-by: Jorge Gasca <jorge.ignacio.gasca@gmail.com>
* Remove unnecessary formatting of err struct
Signed-off-by: Jorge Gasca <jorge.ignacio.gasca@gmail.com>
Signed-off-by: EItanya <eitan.yarmush@solo.io>
* fix(cmd): Fixes logging on action conf init error
Errors relating to initializing the action config cause helm to exit silently,
except when in debug mode. This now emits the useful error.
Closes#6863
Signed-off-by: Jorge Gasca <jorge.ignacio.gasca@gmail.com>
* Remove unnecessary formatting of err struct
Signed-off-by: Jorge Gasca <jorge.ignacio.gasca@gmail.com>
* Include requirements.* as Files in APIVersionV1
Fixes#6974.
This ensures that when reading a Chart marked with APIVersion v1, we
maintain the behaviour of Helm v2 and include the requirements.yaml and
requirements.lock in the Files collection, and hence produce charts that
work correctly with Helm v2.
Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
* Write out requirements.lock for APIVersion1 Charts
This keeps the on-disk format consistent after `helm dependency update`
of an APIVersion1 Chart.
Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
* Exclude 'dependencies' from APVersion1 Chart.yaml
This fixes `helm lint` against an APIVersion1 chart packaged with Helm
v3.
Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
* Generate APIVersion v2 charts for dependency tests
As the generated chart contains no requirements.yaml in its files list,
but has dependencies in its metadata, it is not a valid APIVersion v1
chart.
Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
* Generate APIVersion v2 charts for manager tests
Specifically for the charts that have dependencies, the generated chart
contains no requirements.yaml in its files but has dependencies in its
metadata. Hence it is not a valid APIVersion v1 chart.
Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
When enabled, during the rendering process, this feature flag will not validate rendered templates against the Kubernetes OpenAPI Schema.
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
When the unreleased tag was removed, some tests that were added after
the PR was created started failing. This fixes them.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
* fix(helm): add --description flag to 'helm install', 'helm upgrade', and 'helm uninstall'
When added, this flag allow us to add a custom description to the release. E.g. '--description "my custom description"'
Closes#7033
Signed-off-by: Juan Matias Kungfu de la Camara Beovide <juanmatias@gmail.com>
* fix(helm): fixed style issues on top of previous commit (3a43a9a487)
Closes#7033
Signed-off-by: Juan Matias Kungfu de la Camara Beovide <juanmatias@gmail.com>
* fix(helm): fixed wrong test issue on top of previous commit (3a43a9a)
Closes#7033
Signed-off-by: Juan Matias Kungfu de la Camara Beovide <juanmatias@gmail.com>
* docs(install): clarify the --replace flag
The description of the `--replace` flag was unclear, as it can’t be
used to replace active releases.
Signed-off-by: Remco Haszing <remcohaszing@gmail.com>
* docs(install): reword replace flag description
Signed-off-by: Remco Haszing <remcohaszing@gmail.com>
When calling a plugin, if a global flag requiring a parameter was
missing the parameter, helm would crash.
For example:
helm 2to3 --namespace<ENTER>
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Before this change, running 'helm env' multiple times would generate
a different order for the output each time. This is because Go
purposely loops over hash maps in a random order.
This commit sorts the environment variables by alphabetical order before
generating the output.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
After discussing similar changes in #6866, we decided to make sure all
JSON and YAML output uses lower snake case names as is generally standard
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
If a user has aliases commands that we use in the completion script
such as grep, cut, tail, it may cause the script to misbehave.
By escaping the commands, we tell the shell not to use any aliases.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
This is a follow up to discussion in #6663 that clarifies exactly what the
validate flag is doing. It isn't meant to be a generic schema validator, but
rather validates the manifests against the current cluster as if it was
going to be installing them.
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
When 'helm3 lint <chart-name>.tar.gz' is run, this will lint Chart.yaml in the package
Closes#6535
Signed-off-by: Kamalashree N <nagaraj.kamalashree@gmail.com>
- replace `helm repo search` with `helm search repo`
- re-clarify that the --version flag accepts a semver range
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
Fixes the regression in helm-3.0.0-beta.5 that swallows and rounds any non-zero exit status greater than 1 from a helm plugin to `1`.
This, for example, breaks `helm-diff` which relies on helm able to return `2` when `helm-diff` returned `2`.
Closese #6788
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Introduce the `--devel` flag for `helm repo search` command.
`helm repo search` - searches only for stable releases, prerelease versions will be skip
`helm repo search --devel` - searches for releases and prereleases (alpha, beta, and release candidate releases)
`helm repo search --version 1.0.0 - searches for release in version 1.0.0
Signed-off-by: Mateusz Szostok <szostok.mateusz@gmail.com>
This is a v3 port of #6612. There have been significant changes due to the way
Helm 3 refactored things. I chose to add the method for getting logs to the
testing client because it seemed like something that someone using Helm
as an SDK might want. It takes a writer because it is more efficient (less
copying) and can write to any sort of buffer desired
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
Any method that had a function parameter that was a `Time` or returned a
`Time` is now wrapped so you can use our time wrapper without any weird conventions
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
This package mainly exists to workaround an issue in Go
where the serializer doesn't omit an empty value for time:
https://github.com/golang/go/issues/11939. This replaces all
release and hook object time references with the new time package
so things actually marshal correctly
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
Consistenly remove all arguments which are passed as environment
variables.
Get all arguments from environment variables passed to plugins.
Signed-off-by: Jonas Rutishauser <jonas.rutishauser@alumni.ethz.ch>
As part of #6552
The is a break in compatibility because 'helm get' is no longer a
valid command on its own; what it used to do is now achieved with
'helm get all'.
This change avoids confusion between release name and subcommands.
It also allows dynamic shell comnpletion to work for 'helm get all'.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
As part of #6552
The is a break in compatibility because 'helm show' is no longer a
valid command on its own; what it used to do is now achieved with
'helm show all'.
This change avoids confusion between chart reference and subcommands.
It also opens the door to dynamic shell comnpletion.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
The recent init action config switched the order of how variables get bound
and where. This led to the namespace variable not being propagated down into
the calls to kubernetes.
Co-authored-by: Matthew Fisher <matt.fisher@microsoft.com>
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
This greatly simplifies how to obtain the list of output.Format.
It no longer provides a way to list all output.Format, but focuses
on providing a list of string representation of output.Format, as this
is what is actually needed.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
This isolates the listing of the different formats to the output.go
file. It is more future-proof if another format is added.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
This is a port of #5392. It also takes care of the small chore to update the default k8s
version to 1.16, which is the latest supported version
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
* Create file locking directory if it does not exist
As Helm v3 uses lazy creation for configuration then
directories and files are not created until required.
File locking when doing repo add was introduced in
v2 and ported to v3 in #6492. It locks on the config
directory where the repo file resides and therefore
needs the directory to be created if it doesn't exist.
This fix adds the directory if need be,
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
* Add unit test
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
There were two different methods and varying ways to output the status of a release.
This standardizes all of the outputs, but requires a breaking change. Output will
not perfectly match previous v3 output, and we had to break the printing function
in the `action` package, but now things are much more standardized.
Fixes#6238
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
* Kubernetes updated to 1.16.1
* SemVer and Sprig updated to latest releases that leverage go
modules
* Tests and checks updated. These already landed in v2 via PR 6457
Signed-off-by: Matt Farina <matt@mattfarina.com>
Also, it seems that for helm v3, the description of flags all start
with a lowercase, so this commit also does that for the output flag.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
* Port Helm 2 PR 4088 to Helm 3
Not a direct port as is but refactored for Helm 3.
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
* Update unit test to test string retunred for different order
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
As part of this port, I removed some now superfluous code from the `action` package.
This is technically a breaking change, but since the package was introduced in v3, it
is highly unlikely anyone is using it and we are still within the beta window.
Also closes#6437
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
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>
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>
* Add dynamic completion for 'helm repo remove'
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
* fix: --home flag has been removed
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
* Dynamic completion for 'helm plugin remove/update'
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
* Add returns for consitency
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
Have tried to give the output of the lint command a bit of a clean up to
try to make it easier to follow. This splits the output by chart, moves
the summary to the end of the report rather than at the top and fixes
the number of failed charts count.
Signed-off-by: Thomas O'Donnell <andy.tom@gmail.com>
Also:
* add --insecure flag to "registry login"
* fix bug parsing correct tag when port number present
Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>
* allow repository config via cli
* make `helm repo add` create repo config file if it does not exist
* squash a ton of bugs
Signed-off-by: Adam Reese <adam@reese.io>
No more magic separating the metadata from chart tarball - charts are
pushed to registry as a single tarball layer with Chart.yaml in tact.
No more fragile custom symlink chart storage, now following
the OCI Image Layout Specification for chart filesystem cache.
Also:
- Update to ORAS 0.6.0
- Simplify registry client setup with NewClientWithDefaults()
- Remove needless annotations and constants
Fixes#6068Fixes#6141
Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>
These packages are generally used only for logic inside of Helm and
can later be re-exported as needed
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
This command only displays documentation. I think we should remove it
in favor of documentation and add a command later if required.
Signed-off-by: Adam Reese <adam@reese.io>
The adds the -d flag to "helm chart export" to save chart to different
directory.
Also, allow loading with "helm chart save" from both dir and tarball, as
well as make expirimental error more copy-paste friendly.
Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>
This adds a new `gates` package used for interacting with feature gates. It also marks the OCI registry work as experimental, signalling to users that it is not a stable feature of Helm.
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
This updates commands install, upgrade, delete, and test to share the
same implementation for hook execution.
BREAKING CHANGES:
- The `test-failure` hook annotation is removed.
Signed-off-by: Jacob LeGrone <git@jacob.work>
The revision argument that was mandatory to `helm rollback` was being ignored.
The only way to roll back to an older revision was to run `helm rollback RELEASE <insert anything here> --version REVISION`.
This change respects that argument and removes the `--version` flag, which was redundant.
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
The stable repository provides a quick onboarding with a set of
community curated charts. Two problems with the community stable
repository has lead to its need to be removed.
1. The URL is hard coded to a Google Cloud bucket under Google's
control. This was setup when Helm was part of Kubernetes and
Kubernetes was a Google project. The bucket cannot be
transfered to another non-Google controlled project. And,
the bucket is not accessible in some parts of the world
(e.g., China).
2. The number of charts in the stable repository has grown
generally unmaintainable. The repository maintainers cannot
manage the number of PRs coming it cauing delays in response
or no response and PRs are automatically closed. This is
a poor experience.
The alternatice is the Helm Hub that provides a central point of
search for many Helm repositories. Different people and organizations
can maintain their own charts. A central server is not needed as
Helm is setup to be distributed.
Signed-off-by: Matt Farina <matt@mattfarina.com>
Prior to now, helm has been silently ignoring any errors while parsing
the root Persistent flags. This causes an issue when a global flag comes
later on the command line than a localized flag for a subcommand, in
which the value for that global flag is never set. The solution is to
simply tell the Persistent flagset to ignore any unknown flags, since a
later command will process it
Signed-off-by: Ian Howell <ian.howell0@gmail.com>
This feature flag allows `helm template` to be used against a live cluster. Some charts need CRDs to be applied to the cluster before calling `helm install`. This allows users to validate their templates will render with those resources set.
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
If starter template path is an absolute path, it shouldn't
be prefixed with c.home.Starters() but rather be used as is.
Signed-off-by: Tine Jozelj <tine.jozelj@tjo.space>
This fixes an issue where the kubernetes client was being created using
command line flags before those flags had been parsed, causing the
client to always use the default values.
Signed-off-by: Ian Howell <ian.howell0@gmail.com>
This commit replaces usage of github.com/ghodss/yaml with it's forked
version maintained by SIG community. The replaced library has
low-to-none support activity unlike the latter. We believe the new
Helm branch could benefit from using the community-supported version on
a long-term run as yaml parser is a key component of Helm chart rendering
engine.
This commit locks sigs.k8s.io/yaml dependency version on 1.1.0 which
is backwards compatible with ghodss/yaml 1.0.0.
This change also resolves the outdated dependency version lock for
ghodss/yaml (currently 1.0.0) and makes it possible to port changes from
https://github.com/helm/helm/pull/6010 to dev-v3.
Signed-off-by: Oleg Sidorov <oleg.sidorov@booking.com>