fix helm dep build/update doesn't inherit --insecure-skip-tls-verify from helm repo add

Signed-off-by: yxxhero <aiopsclub@163.com>
pull/8896/head
yxxhero 5 years ago
parent 1e1854f8d0
commit 0145279765

@ -2,13 +2,10 @@
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

@ -307,7 +307,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
// Any failure to resolve/download a chart should fail:
// https://github.com/helm/helm/issues/1439
churl, username, password, err := m.findChartURL(dep.Name, dep.Version, dep.Repository, repos)
churl, username, password, insecureskiptlsverify, err := m.findChartURL(dep.Name, dep.Version, dep.Repository, repos)
if err != nil {
saveError = errors.Wrapf(err, "could not find %s", churl)
break
@ -329,6 +329,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
Getters: m.Getters,
Options: []getter.Option{
getter.WithBasicAuth(username, password),
getter.WithInsecureSkipVerifyTLS(insecureskiptlsverify),
},
}
@ -641,7 +642,7 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error {
// repoURL is the repository to search
//
// If it finds a URL that is "relative", it will prepend the repoURL.
func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*repo.ChartRepository) (url, username, password string, err error) {
func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*repo.ChartRepository) (url, username, password string, insecureskiptlsverify bool, err error) {
for _, cr := range repos {
if urlutil.Equal(repoURL, cr.Config.URL) {
var entry repo.ChartVersions
@ -660,6 +661,7 @@ func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*
}
username = cr.Config.Username
password = cr.Config.Password
insecureskiptlsverify = cr.Config.InsecureSkipTLSverify
return
}
}

@ -77,15 +77,15 @@ func TestFindChartURL(t *testing.T) {
t.Fatal(err)
}
name := "alpine"
version := "0.1.0"
repoURL := "http://example.com/charts"
name := "foo"
version := "1.2.3"
repoURL := "https://testing-https.example.com"
churl, username, password, err := m.findChartURL(name, version, repoURL, repos)
churl, username, password, insecureSkipTLSVerify, err := m.findChartURL(name, version, repoURL, repos)
if err != nil {
t.Fatal(err)
}
if churl != "https://kubernetes-charts.storage.googleapis.com/alpine-0.1.0.tgz" {
if churl != "https://example.com/foo-1.2.3.tgz" {
t.Errorf("Unexpected URL %q", churl)
}
if username != "" {
@ -94,6 +94,9 @@ func TestFindChartURL(t *testing.T) {
if password != "" {
t.Errorf("Unexpected password %q", password)
}
if !insecureSkipTLSVerify {
t.Errorf("Unexpected insecureSkipTLSVerify %v", insecureSkipTLSVerify)
}
}
func TestGetRepoNames(t *testing.T) {

@ -3,7 +3,8 @@ repositories:
- name: testing
url: "http://example.com"
- name: testing-https
url: "https://example.com"
url: "https://testing-https.example.com"
insecure_skip_tls_verify: true
- name: testing-basicauth
url: "http://username:password@example.com"
- name: kubernetes-charts

Loading…
Cancel
Save