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:
Babis K
2021-12-21 09:18:57 +09:00
committed by GitHub
parent 1986cb37aa
commit d34dc7bb64
9 changed files with 60 additions and 24 deletions
+28 -6
View File
@@ -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 {