mirror of
https://github.com/helm/chart-testing.git
synced 2026-02-05 09:45:14 +01:00
Add support for providing credentials when adding chart-repositories (#67)
Signed-off-by: Markus Maga <markus@nadilus.com>
This commit is contained in:
committed by
Reinhard Nägele
parent
7b167f8fe0
commit
9084cf16d0
17
README.md
17
README.md
@@ -95,6 +95,23 @@ build-id: pr-42
|
||||
Notice that if no config file is specified, then `ct.yaml` (or any of the supported formats) is loaded from the current directory, `$HOME/.ct`, or `/etc/ct`, in that order, if found.
|
||||
|
||||
|
||||
#### Using private chart repositories
|
||||
|
||||
When adding chart-repos you can specify additional arguments for the `helm repo add` command using `helm-repo-extra-args` on a per-repo basis. This could for example be used to authenticate a private chart repository.
|
||||
|
||||
`config.yaml`:
|
||||
|
||||
```yaml
|
||||
chart-repos:
|
||||
- incubator=https://incubator.io
|
||||
- basic-auth=https://private.com
|
||||
- ssl-repo=https://self-signed.ca
|
||||
helm-repo-extra-args:
|
||||
- ssl-repo=--ca-file ./my-ca.crt
|
||||
```
|
||||
|
||||
ct install --config config.yaml --helm-repo-extra-args "basic-auth=--username user --password secret"
|
||||
|
||||
## Building from Source
|
||||
|
||||
`ct` is built using Go 1.11. Older versions may work but have not been tested.
|
||||
|
||||
@@ -77,6 +77,11 @@ func addCommonLintAndInstallFlags(flags *pflag.FlagSet) {
|
||||
flags.StringSlice("chart-repos", []string{}, heredoc.Doc(`
|
||||
Additional chart repos to add so dependencies can be resolved. May be
|
||||
specified multiple times or separate values with commas`))
|
||||
flags.StringSlice("helm-repo-extra-args", []string{}, heredoc.Doc(`
|
||||
Additional arguments for the 'helm repo add' command to be
|
||||
specified on a per-repo basis with an equals sign as delimiter
|
||||
(e.g. 'myrepo=--username test --password secret'). May be specified
|
||||
multiple times or separate values with commas`))
|
||||
flags.StringSlice("excluded-charts", []string{}, heredoc.Doc(`
|
||||
Charts that should be skipped. May be specified multiple times
|
||||
or separate values with commas`))
|
||||
@@ -95,6 +100,6 @@ func bindFlags(options []string, flagSet *flag.FlagSet, v *viper.Viper) error {
|
||||
}
|
||||
|
||||
func bindRootFlags(flagSet *flag.FlagSet, v *viper.Viper) error {
|
||||
options := []string{"remote", "target-branch", "all", "charts", "chart-dirs", "chart-repos", "excluded-charts", "debug"}
|
||||
options := []string{"remote", "target-branch", "all", "charts", "chart-dirs", "chart-repos", "helm-repo-extra-args", "excluded-charts", "debug"}
|
||||
return bindFlags(options, flagSet, v)
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ in given chart directories.
|
||||
* [ct lint-and-install](ct_lint-and-install.md) - Lint, install, and test a chart
|
||||
* [ct version](ct_version.md) - Print version information
|
||||
|
||||
###### Auto generated by spf13/cobra on 19-Dec-2018
|
||||
###### Auto generated by spf13/cobra on 22-Dec-2018
|
||||
|
||||
@@ -25,36 +25,40 @@ ct install [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
--all Process all charts except those explicitly excluded.
|
||||
Disables changed charts detection and version increment checking
|
||||
--build-id string An optional, arbitrary identifier that is added to the name of the namespace a
|
||||
chart is installed into. In a CI environment, this could be the build number or
|
||||
the ID of a pull request. If not specified, the name of the chart is used
|
||||
--chart-dirs strings Directories containing Helm charts. May be specified multiple times
|
||||
or separate values with commas (default [charts])
|
||||
--chart-repos strings Additional chart repos to add so dependencies can be resolved. May be
|
||||
specified multiple times or separate values with commas
|
||||
--charts strings Specific charts to test. Disables changed charts detection and
|
||||
version increment checking. May be specified multiple times
|
||||
or separate values with commas
|
||||
--config string Config file
|
||||
--debug Print CLI calls of external tools to stdout (Note: depending on helm-extra-args
|
||||
passed, this may reveal sensitive data)
|
||||
--excluded-charts strings Charts that should be skipped. May be specified multiple times
|
||||
or separate values with commas
|
||||
--helm-extra-args string Additional arguments for Helm. Must be passed as a single quoted string
|
||||
(e.g. "--timeout 500 --tiller-namespace tiller"
|
||||
-h, --help help for install
|
||||
--namespace string Namespace to install the release(s) into. If not specified, each release will be
|
||||
installed in its own randomly generated namespace.
|
||||
--release-label string The label to be used as a selector when inspecting resources created by charts.
|
||||
This is only used if namespace is specified. (default "app.kubernetes.io/instance")
|
||||
--remote string The name of the Git remote used to identify changed charts (default "origin")
|
||||
--target-branch string The name of the target branch used to identify changed charts (default "master")
|
||||
--all Process all charts except those explicitly excluded.
|
||||
Disables changed charts detection and version increment checking
|
||||
--build-id string An optional, arbitrary identifier that is added to the name of the namespace a
|
||||
chart is installed into. In a CI environment, this could be the build number or
|
||||
the ID of a pull request. If not specified, the name of the chart is used
|
||||
--chart-dirs strings Directories containing Helm charts. May be specified multiple times
|
||||
or separate values with commas (default [charts])
|
||||
--chart-repos strings Additional chart repos to add so dependencies can be resolved. May be
|
||||
specified multiple times or separate values with commas
|
||||
--charts strings Specific charts to test. Disables changed charts detection and
|
||||
version increment checking. May be specified multiple times
|
||||
or separate values with commas
|
||||
--config string Config file
|
||||
--debug Print CLI calls of external tools to stdout (Note: depending on helm-extra-args
|
||||
passed, this may reveal sensitive data)
|
||||
--excluded-charts strings Charts that should be skipped. May be specified multiple times
|
||||
or separate values with commas
|
||||
--helm-extra-args string Additional arguments for Helm. Must be passed as a single quoted string
|
||||
(e.g. "--timeout 500 --tiller-namespace tiller"
|
||||
--helm-repo-extra-args strings Additional arguments for the 'helm repo add' command to be
|
||||
specified on a per-repo basis with an equals sign as delimiter
|
||||
(e.g. 'myrepo=--username test --password secret'). May be specified
|
||||
multiple times or separate values with commas
|
||||
-h, --help help for install
|
||||
--namespace string Namespace to install the release(s) into. If not specified, each release will be
|
||||
installed in its own randomly generated namespace.
|
||||
--release-label string The label to be used as a selector when inspecting resources created by charts.
|
||||
This is only used if namespace is specified. (default "app.kubernetes.io/instance")
|
||||
--remote string The name of the Git remote used to identify changed charts (default "origin")
|
||||
--target-branch string The name of the target branch used to identify changed charts (default "master")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [ct](ct.md) - The Helm chart testing tool
|
||||
|
||||
###### Auto generated by spf13/cobra on 19-Dec-2018
|
||||
###### Auto generated by spf13/cobra on 22-Dec-2018
|
||||
|
||||
@@ -13,47 +13,51 @@ ct lint-and-install [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
--all Process all charts except those explicitly excluded.
|
||||
Disables changed charts detection and version increment checking
|
||||
--build-id string An optional, arbitrary identifier that is added to the name of the namespace a
|
||||
chart is installed into. In a CI environment, this could be the build number or
|
||||
the ID of a pull request. If not specified, the name of the chart is used
|
||||
--chart-dirs strings Directories containing Helm charts. May be specified multiple times
|
||||
or separate values with commas (default [charts])
|
||||
--chart-repos strings Additional chart repos to add so dependencies can be resolved. May be
|
||||
specified multiple times or separate values with commas
|
||||
--chart-yaml-schema string The schema for chart.yml validation. If not specified, 'chart_schema.yaml'
|
||||
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
|
||||
that order.
|
||||
--charts strings Specific charts to test. Disables changed charts detection and
|
||||
version increment checking. May be specified multiple times
|
||||
or separate values with commas
|
||||
--check-version-increment Activates a check for chart version increments (default: true) (default true)
|
||||
--config string Config file
|
||||
--debug Print CLI calls of external tools to stdout (Note: depending on helm-extra-args
|
||||
passed, this may reveal sensitive data)
|
||||
--excluded-charts strings Charts that should be skipped. May be specified multiple times
|
||||
or separate values with commas
|
||||
--helm-extra-args string Additional arguments for Helm. Must be passed as a single quoted string
|
||||
(e.g. "--timeout 500 --tiller-namespace tiller"
|
||||
-h, --help help for lint-and-install
|
||||
--lint-conf string The config file for YAML linting. If not specified, 'lintconf.yaml'
|
||||
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
|
||||
that order
|
||||
--namespace string Namespace to install the release(s) into. If not specified, each release will be
|
||||
installed in its own randomly generated namespace.
|
||||
--release-label string The label to be used as a selector when inspecting resources created by charts.
|
||||
This is only used if namespace is specified. (default "app.kubernetes.io/instance")
|
||||
--remote string The name of the Git remote used to identify changed charts (default "origin")
|
||||
--target-branch string The name of the target branch used to identify changed charts (default "master")
|
||||
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default: true) (default true)
|
||||
--validate-maintainers Enable validation of maintainer account names in chart.yml (default: true).
|
||||
Works for GitHub, GitLab, and Bitbucket (default true)
|
||||
--validate-yaml Enable linting of 'Chart.yaml' and values files (default: true) (default true)
|
||||
--all Process all charts except those explicitly excluded.
|
||||
Disables changed charts detection and version increment checking
|
||||
--build-id string An optional, arbitrary identifier that is added to the name of the namespace a
|
||||
chart is installed into. In a CI environment, this could be the build number or
|
||||
the ID of a pull request. If not specified, the name of the chart is used
|
||||
--chart-dirs strings Directories containing Helm charts. May be specified multiple times
|
||||
or separate values with commas (default [charts])
|
||||
--chart-repos strings Additional chart repos to add so dependencies can be resolved. May be
|
||||
specified multiple times or separate values with commas
|
||||
--chart-yaml-schema string The schema for chart.yml validation. If not specified, 'chart_schema.yaml'
|
||||
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
|
||||
that order.
|
||||
--charts strings Specific charts to test. Disables changed charts detection and
|
||||
version increment checking. May be specified multiple times
|
||||
or separate values with commas
|
||||
--check-version-increment Activates a check for chart version increments (default: true) (default true)
|
||||
--config string Config file
|
||||
--debug Print CLI calls of external tools to stdout (Note: depending on helm-extra-args
|
||||
passed, this may reveal sensitive data)
|
||||
--excluded-charts strings Charts that should be skipped. May be specified multiple times
|
||||
or separate values with commas
|
||||
--helm-extra-args string Additional arguments for Helm. Must be passed as a single quoted string
|
||||
(e.g. "--timeout 500 --tiller-namespace tiller"
|
||||
--helm-repo-extra-args strings Additional arguments for the 'helm repo add' command to be
|
||||
specified on a per-repo basis with an equals sign as delimiter
|
||||
(e.g. 'myrepo=--username test --password secret'). May be specified
|
||||
multiple times or separate values with commas
|
||||
-h, --help help for lint-and-install
|
||||
--lint-conf string The config file for YAML linting. If not specified, 'lintconf.yaml'
|
||||
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
|
||||
that order
|
||||
--namespace string Namespace to install the release(s) into. If not specified, each release will be
|
||||
installed in its own randomly generated namespace.
|
||||
--release-label string The label to be used as a selector when inspecting resources created by charts.
|
||||
This is only used if namespace is specified. (default "app.kubernetes.io/instance")
|
||||
--remote string The name of the Git remote used to identify changed charts (default "origin")
|
||||
--target-branch string The name of the target branch used to identify changed charts (default "master")
|
||||
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default: true) (default true)
|
||||
--validate-maintainers Enable validation of maintainer account names in chart.yml (default: true).
|
||||
Works for GitHub, GitLab, and Bitbucket (default true)
|
||||
--validate-yaml Enable linting of 'Chart.yaml' and values files (default: true) (default true)
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [ct](ct.md) - The Helm chart testing tool
|
||||
|
||||
###### Auto generated by spf13/cobra on 19-Dec-2018
|
||||
###### Auto generated by spf13/cobra on 22-Dec-2018
|
||||
|
||||
@@ -26,38 +26,42 @@ ct lint [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
--all Process all charts except those explicitly excluded.
|
||||
Disables changed charts detection and version increment checking
|
||||
--chart-dirs strings Directories containing Helm charts. May be specified multiple times
|
||||
or separate values with commas (default [charts])
|
||||
--chart-repos strings Additional chart repos to add so dependencies can be resolved. May be
|
||||
specified multiple times or separate values with commas
|
||||
--chart-yaml-schema string The schema for chart.yml validation. If not specified, 'chart_schema.yaml'
|
||||
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
|
||||
that order.
|
||||
--charts strings Specific charts to test. Disables changed charts detection and
|
||||
version increment checking. May be specified multiple times
|
||||
or separate values with commas
|
||||
--check-version-increment Activates a check for chart version increments (default: true) (default true)
|
||||
--config string Config file
|
||||
--debug Print CLI calls of external tools to stdout (Note: depending on helm-extra-args
|
||||
passed, this may reveal sensitive data)
|
||||
--excluded-charts strings Charts that should be skipped. May be specified multiple times
|
||||
or separate values with commas
|
||||
-h, --help help for lint
|
||||
--lint-conf string The config file for YAML linting. If not specified, 'lintconf.yaml'
|
||||
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
|
||||
that order
|
||||
--remote string The name of the Git remote used to identify changed charts (default "origin")
|
||||
--target-branch string The name of the target branch used to identify changed charts (default "master")
|
||||
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default: true) (default true)
|
||||
--validate-maintainers Enable validation of maintainer account names in chart.yml (default: true).
|
||||
Works for GitHub, GitLab, and Bitbucket (default true)
|
||||
--validate-yaml Enable linting of 'Chart.yaml' and values files (default: true) (default true)
|
||||
--all Process all charts except those explicitly excluded.
|
||||
Disables changed charts detection and version increment checking
|
||||
--chart-dirs strings Directories containing Helm charts. May be specified multiple times
|
||||
or separate values with commas (default [charts])
|
||||
--chart-repos strings Additional chart repos to add so dependencies can be resolved. May be
|
||||
specified multiple times or separate values with commas
|
||||
--chart-yaml-schema string The schema for chart.yml validation. If not specified, 'chart_schema.yaml'
|
||||
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
|
||||
that order.
|
||||
--charts strings Specific charts to test. Disables changed charts detection and
|
||||
version increment checking. May be specified multiple times
|
||||
or separate values with commas
|
||||
--check-version-increment Activates a check for chart version increments (default: true) (default true)
|
||||
--config string Config file
|
||||
--debug Print CLI calls of external tools to stdout (Note: depending on helm-extra-args
|
||||
passed, this may reveal sensitive data)
|
||||
--excluded-charts strings Charts that should be skipped. May be specified multiple times
|
||||
or separate values with commas
|
||||
--helm-repo-extra-args strings Additional arguments for the 'helm repo add' command to be
|
||||
specified on a per-repo basis with an equals sign as delimiter
|
||||
(e.g. 'myrepo=--username test --password secret'). May be specified
|
||||
multiple times or separate values with commas
|
||||
-h, --help help for lint
|
||||
--lint-conf string The config file for YAML linting. If not specified, 'lintconf.yaml'
|
||||
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
|
||||
that order
|
||||
--remote string The name of the Git remote used to identify changed charts (default "origin")
|
||||
--target-branch string The name of the target branch used to identify changed charts (default "master")
|
||||
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default: true) (default true)
|
||||
--validate-maintainers Enable validation of maintainer account names in chart.yml (default: true).
|
||||
Works for GitHub, GitLab, and Bitbucket (default true)
|
||||
--validate-yaml Enable linting of 'Chart.yaml' and values files (default: true) (default true)
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [ct](ct.md) - The Helm chart testing tool
|
||||
|
||||
###### Auto generated by spf13/cobra on 19-Dec-2018
|
||||
###### Auto generated by spf13/cobra on 22-Dec-2018
|
||||
|
||||
@@ -20,4 +20,4 @@ ct version [flags]
|
||||
|
||||
* [ct](ct.md) - The Helm chart testing tool
|
||||
|
||||
###### Auto generated by spf13/cobra on 19-Dec-2018
|
||||
###### Auto generated by spf13/cobra on 22-Dec-2018
|
||||
|
||||
@@ -64,7 +64,7 @@ type Git interface {
|
||||
// DeleteRelease purges the specified Helm release.
|
||||
type Helm interface {
|
||||
Init() error
|
||||
AddRepo(name string, url string) error
|
||||
AddRepo(name string, url string, extraArgs []string) error
|
||||
BuildDependencies(chart string) error
|
||||
LintWithValues(chart string, valuesFile string) error
|
||||
InstallWithValues(chart string, valuesFile string, namespace string, release string) error
|
||||
@@ -197,11 +197,22 @@ func (t *Testing) processCharts(action func(chart string, valuesFiles []string)
|
||||
return nil, errors.Wrap(err, "Error initializing Helm")
|
||||
}
|
||||
|
||||
repoArgs := map[string][]string{}
|
||||
|
||||
for _, repo := range t.config.HelmRepoExtraArgs {
|
||||
repoSlice := strings.SplitN(repo, "=", 2)
|
||||
name := repoSlice[0]
|
||||
repoExtraArgs := strings.Fields(repoSlice[1])
|
||||
repoArgs[name] = repoExtraArgs
|
||||
}
|
||||
|
||||
for _, repo := range t.config.ChartRepos {
|
||||
repoSlice := strings.SplitN(repo, "=", 2)
|
||||
name := repoSlice[0]
|
||||
url := repoSlice[1]
|
||||
if err := t.helm.AddRepo(name, url); err != nil {
|
||||
|
||||
repoExtraArgs := repoArgs[name]
|
||||
if err := t.helm.AddRepo(name, url, repoExtraArgs); err != nil {
|
||||
return nil, errors.Wrapf(err, "Error adding repo: %s=%s", name, url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func (l *fakeLinter) Yamale(yamlFile, schemaFile string) error {
|
||||
type fakeHelm struct{}
|
||||
|
||||
func (h fakeHelm) Init() error { return nil }
|
||||
func (h fakeHelm) AddRepo(name, url string) error { return nil }
|
||||
func (h fakeHelm) AddRepo(name, url string, extraArgs []string) error { return nil }
|
||||
func (h fakeHelm) BuildDependencies(chart string) error { return nil }
|
||||
func (h fakeHelm) LintWithValues(chart string, valuesFile string) error { return nil }
|
||||
func (h fakeHelm) InstallWithValues(chart string, valuesFile string, namespace string, release string) error {
|
||||
|
||||
@@ -54,6 +54,7 @@ type Configuration struct {
|
||||
ChartDirs []string `mapstructure:"chart-dirs"`
|
||||
ExcludedCharts []string `mapstructure:"excluded-charts"`
|
||||
HelmExtraArgs string `mapstructure:"helm-extra-args"`
|
||||
HelmRepoExtraArgs []string `mapstructure:"helm-repo-extra-args"`
|
||||
Debug bool `mapstructure:"debug"`
|
||||
Namespace string `mapstructure:"namespace"`
|
||||
ReleaseLabel string `mapstructure:"release-label"`
|
||||
|
||||
@@ -43,6 +43,7 @@ func loadAndAssertConfigFromFile(t *testing.T, configFile string) {
|
||||
require.Equal(t, true, cfg.CheckVersionIncrement)
|
||||
require.Equal(t, false, cfg.ProcessAllCharts)
|
||||
require.Equal(t, []string{"incubator=https://incubator"}, cfg.ChartRepos)
|
||||
require.Equal(t, []string{"incubator=--username test"}, cfg.HelmRepoExtraArgs)
|
||||
require.Equal(t, []string{"stable", "incubator"}, cfg.ChartDirs)
|
||||
require.Equal(t, []string{"common"}, cfg.ExcludedCharts)
|
||||
require.Equal(t, "--timeout 300", cfg.HelmExtraArgs)
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
"chart-repos": [
|
||||
"incubator=https://incubator"
|
||||
],
|
||||
"helm-repo-extra-args": [
|
||||
"incubator=--username test"
|
||||
],
|
||||
"chart-dirs": [
|
||||
"stable",
|
||||
"incubator"
|
||||
|
||||
@@ -11,6 +11,8 @@ check-version-increment: true
|
||||
all: false
|
||||
chart-repos:
|
||||
- incubator=https://incubator
|
||||
helm-repo-extra-args:
|
||||
- incubator=--username test
|
||||
chart-dirs:
|
||||
- stable
|
||||
- incubator
|
||||
|
||||
@@ -36,8 +36,8 @@ func (h Helm) Init() error {
|
||||
return h.exec.RunProcess("helm", "init", "--client-only")
|
||||
}
|
||||
|
||||
func (h Helm) AddRepo(name string, url string) error {
|
||||
return h.exec.RunProcess("helm", "repo", "add", name, url)
|
||||
func (h Helm) AddRepo(name string, url string, extraArgs []string) error {
|
||||
return h.exec.RunProcess("helm", "repo", "add", name, url, extraArgs)
|
||||
}
|
||||
|
||||
func (h Helm) BuildDependencies(chart string) error {
|
||||
|
||||
Reference in New Issue
Block a user