mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-21 09:53:04 +02:00
Add support for --insecure-skip-tls-verify flag on helm repo add command (#1990)
Parses a new field in repositories named `skipTLSVerify` and if set to `true`, it appends `--insecure-skip-tls-verify` in `helm repo add` command. This should be useful with internal self-signed repos, mitm proxies etc. Resolves #1871
This commit is contained in:
+3
-2
@@ -173,6 +173,7 @@ type RepositorySpec struct {
|
||||
Managed string `yaml:"managed,omitempty"`
|
||||
OCI bool `yaml:"oci,omitempty"`
|
||||
PassCredentials string `yaml:"passCredentials,omitempty"`
|
||||
SkipTLSVerify string `yaml:"skipTLSVerify,omitempty"`
|
||||
}
|
||||
|
||||
// ReleaseSpec defines the structure of a helm release
|
||||
@@ -393,7 +394,7 @@ func (st *HelmState) ApplyOverrides(spec *ReleaseSpec) {
|
||||
|
||||
type RepoUpdater interface {
|
||||
IsHelm3() bool
|
||||
AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string) error
|
||||
AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error
|
||||
UpdateRepo() error
|
||||
RegistryLogin(name string, username string, password string) error
|
||||
}
|
||||
@@ -412,7 +413,7 @@ func (st *HelmState) SyncRepos(helm RepoUpdater, shouldSkip map[string]bool) ([]
|
||||
err = helm.RegistryLogin(repo.URL, username, password)
|
||||
}
|
||||
} else {
|
||||
err = helm.AddRepo(repo.Name, repo.URL, repo.CaFile, repo.CertFile, repo.KeyFile, repo.Username, repo.Password, repo.Managed, repo.PassCredentials)
|
||||
err = helm.AddRepo(repo.Name, repo.URL, repo.CaFile, repo.CertFile, repo.KeyFile, repo.Username, repo.Password, repo.Managed, repo.PassCredentials, repo.SkipTLSVerify)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
+28
-6
@@ -890,10 +890,11 @@ func TestHelmState_SyncRepos(t *testing.T) {
|
||||
Username: "",
|
||||
Password: "",
|
||||
PassCredentials: "",
|
||||
SkipTLSVerify: "",
|
||||
},
|
||||
},
|
||||
helm: &exectest.Helm{},
|
||||
want: []string{"name", "http://example.com/", "", "", "", "", "", "", ""},
|
||||
want: []string{"name", "http://example.com/", "", "", "", "", "", "", "", ""},
|
||||
},
|
||||
{
|
||||
name: "ACR hosted repository",
|
||||
@@ -904,7 +905,7 @@ func TestHelmState_SyncRepos(t *testing.T) {
|
||||
},
|
||||
},
|
||||
helm: &exectest.Helm{},
|
||||
want: []string{"name", "", "", "", "", "", "", "acr", ""},
|
||||
want: []string{"name", "", "", "", "", "", "", "acr", "", ""},
|
||||
},
|
||||
{
|
||||
name: "repository with cert and key",
|
||||
@@ -917,10 +918,11 @@ func TestHelmState_SyncRepos(t *testing.T) {
|
||||
Username: "",
|
||||
Password: "",
|
||||
PassCredentials: "",
|
||||
SkipTLSVerify: "",
|
||||
},
|
||||
},
|
||||
helm: &exectest.Helm{},
|
||||
want: []string{"name", "http://example.com/", "", "certfile", "keyfile", "", "", "", ""},
|
||||
want: []string{"name", "http://example.com/", "", "certfile", "keyfile", "", "", "", "", ""},
|
||||
},
|
||||
{
|
||||
name: "repository with ca file",
|
||||
@@ -932,10 +934,11 @@ func TestHelmState_SyncRepos(t *testing.T) {
|
||||
Username: "",
|
||||
Password: "",
|
||||
PassCredentials: "",
|
||||
SkipTLSVerify: "",
|
||||
},
|
||||
},
|
||||
helm: &exectest.Helm{},
|
||||
want: []string{"name", "http://example.com/", "cafile", "", "", "", "", "", ""},
|
||||
want: []string{"name", "http://example.com/", "cafile", "", "", "", "", "", "", ""},
|
||||
},
|
||||
{
|
||||
name: "repository with username and password",
|
||||
@@ -948,10 +951,11 @@ func TestHelmState_SyncRepos(t *testing.T) {
|
||||
Username: "example_user",
|
||||
Password: "example_password",
|
||||
PassCredentials: "",
|
||||
SkipTLSVerify: "",
|
||||
},
|
||||
},
|
||||
helm: &exectest.Helm{},
|
||||
want: []string{"name", "http://example.com/", "", "", "", "example_user", "example_password", "", ""},
|
||||
want: []string{"name", "http://example.com/", "", "", "", "example_user", "example_password", "", "", ""},
|
||||
},
|
||||
{
|
||||
name: "repository with username and password and pass-credentials",
|
||||
@@ -964,10 +968,28 @@ func TestHelmState_SyncRepos(t *testing.T) {
|
||||
Username: "example_user",
|
||||
Password: "example_password",
|
||||
PassCredentials: "true",
|
||||
SkipTLSVerify: "",
|
||||
},
|
||||
},
|
||||
helm: &exectest.Helm{},
|
||||
want: []string{"name", "http://example.com/", "", "", "", "example_user", "example_password", "", "true"},
|
||||
want: []string{"name", "http://example.com/", "", "", "", "example_user", "example_password", "", "true", ""},
|
||||
},
|
||||
{
|
||||
name: "repository with skip-tls-verify",
|
||||
repos: []RepositorySpec{
|
||||
{
|
||||
Name: "name",
|
||||
URL: "http://example.com/",
|
||||
CertFile: "",
|
||||
KeyFile: "",
|
||||
Username: "",
|
||||
Password: "",
|
||||
PassCredentials: "",
|
||||
SkipTLSVerify: "true",
|
||||
},
|
||||
},
|
||||
helm: &exectest.Helm{},
|
||||
want: []string{"name", "http://example.com/", "", "", "", "", "", "", "", "true"},
|
||||
},
|
||||
}
|
||||
for i := range tests {
|
||||
|
||||
Reference in New Issue
Block a user