From 01452797654cf6e78763470643887442dbf83fd2 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Thu, 15 Oct 2020 15:29:04 +0800 Subject: [PATCH] fix helm dep build/update doesn't inherit --insecure-skip-tls-verify from helm repo add Signed-off-by: yxxhero --- cmd/helm/root_unix_test.go | 3 --- pkg/downloader/manager.go | 6 ++++-- pkg/downloader/manager_test.go | 13 ++++++++----- pkg/downloader/testdata/repositories.yaml | 3 ++- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cmd/helm/root_unix_test.go b/cmd/helm/root_unix_test.go index c62776c2a..57f98850e 100644 --- a/cmd/helm/root_unix_test.go +++ b/cmd/helm/root_unix_test.go @@ -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. diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 0efac37bc..53754ca6d 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -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 } } diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index 9532cca7c..7e0ded00d 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -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) { diff --git a/pkg/downloader/testdata/repositories.yaml b/pkg/downloader/testdata/repositories.yaml index 430865269..fac66fd42 100644 --- a/pkg/downloader/testdata/repositories.yaml +++ b/pkg/downloader/testdata/repositories.yaml @@ -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