This refactor cleans up downloadAll's validation, download, and save
logic:
1. A temporary directory is created, and removed after all references to
the struct have been dropped via `defer`
2. Any local dependencies in the `charts` directory are kept intact and validated
3. Charts that have been updated are moved to the `charts` directory
This refactor has a number of improvements, including:
- tmpCharts is removed after execution
- no remote charts are downloaded to destPath: they are all pulled into
tmpPath, validated, then moved to destPath
- lots of code cleanup/improvements, like the `if` block checking
whether the `charts` directory was actually not a directory. In some
cases it could be checking a `nil` object, causing a runtime panic.
- the cyclomatic complexity of the code was simplified
- extra (and in some cases, dangerous) calls to `os.RemoveAll` have been
refactored, cleaning the code and preventing certain failure cases.
A test has been provided to demonstrate the tmpCharts removal issue has
been fixed.
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
This subcommand will display manifests under `crds/` if some exist.
This also changes the behaviour of `show all` to include CRDs.
Signed-off-by: Mario Valderrama <woldy401@gmail.com>
The templating engine handles errors originating from the `required` and
`fail` template functions specially, cleaning up the error messages to
be more presentable to users. Go's text/template package unfortunately
does not make this straightforward to implement. Despite
template.ExecError implementing Unwrap, the error value returned from
the template function cannot be retrieved using errors.As. The wrapped
error in ExecError is a pre-formatted error string with the template
function's error string interpolated in with the original error value
erased. Helm works around this limitation by delimiting the
template-supplied message and extracting the message out of the
ExecError string with a regex.
Fix the parsing of `required` and `fail` error messages containing
newlines by setting the regex flag to make `.` match newline characters.
Signed-off-by: Cory Snider <csnider@mirantis.com>
Cobra's bash completion V2 has the following benefits:
- aligned with the completion logic for the other shells
- provides completion descriptions as for the other shells
- uses a 300-line shell script (versus 4K lines for V1)
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Cobra provides powershell auto-completion out of the box. This commit
teaches helm how to use it.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
**What*
Without this commit, you can't pipe the password into `helm repo add`:
```
$ echo password | helm repo add repo-name https://repo-url --username username
Password:
Error: inappropriate ioctl for device
```
This commit introduces `--password-stdin`:
```
$ echo password | helm repo add repo-name https://repo-url --username username --password-stdin
"repo-name" has been added to your repositories
```
**Why**
There are two reasons I see for adding this:
* I personally would expect that it's possible to pipe the password into
`helm repo add` but that's currently not the case. If I understand it
correctly, you currently either need to pass the password via a cli
parameter (`--password`) or use a expect/send mechanism.
* Subcommands like `helm registry login` already support
`--password-stdin`. The cli interfaces should be consistent regarding
which options they support.
**Notes**
I basically just copy-pasted code from `cmd/helm/registry_login.go`.
Signed-off-by: André Schröder <andre.schroedr@gmail.com>
Testing that a bad completion directive was being replaced by the
default one was actually testing Cobra's behaviour. This is unnecessary
especially since that behaviour changed in the 1.2.0 release. Helm
tests should focus on testing Helm's behaviour.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>