From c02c3c0c3c817db21a160d84c999e0ce2f0c038c Mon Sep 17 00:00:00 2001 From: Lu Fengqi Date: Thu, 30 Jul 2020 15:43:41 +0800 Subject: [PATCH] Remove deprecated function BuildNameToCertificate() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit eb93c684d40d ("crypto/tls: select only compatible chains from Certificates") has deprecated BuildNameToCertificate, just leave NameToCertificate nil. ``` ➜ helm git:(master) ✗ go version go version go1.14.6 linux/amd64 ➜ helm git:(master) make test GO111MODULE=on go build -tags '' -ldflags '-w -s -X helm.sh/helm/v3/internal/version.metadata=unreleased -X helm.sh/helm/v3/internal/version.gitCommit=94438b67221d4af3c9993945a42275be7ffc6baa -X helm.sh/helm/v3/internal/version.gitTreeState=clean' -o '/data/workspace/helm/bin'/helm ./cmd/helm GO111MODULE=on golangci-lint run pkg/repo/repotest/server.go:162:2: SA1019: tlsConf.BuildNameToCertificate is deprecated: NameToCertificate only allows associating a single certificate with a given name. Leave that field nil to let the library select the first compatible chain from Certificates. (staticcheck) tlsConf.BuildNameToCertificate() ^ pkg/getter/httpgetter.go:102:3: SA1019: tlsConf.BuildNameToCertificate is deprecated: NameToCertificate only allows associating a single certificate with a given name. Leave that field nil to let the library select the first compatible chain from Certificates. (staticcheck) tlsConf.BuildNameToCertificate() ^ pkg/getter/httpgetter_test.go:190:2: SA1019: tlsConf.BuildNameToCertificate is deprecated: NameToCertificate only allows associating a single certificate with a given name. Leave that field nil to let the library select the first compatible chain from Certificates. (staticcheck) tlsConf.BuildNameToCertificate() ^ make: *** [Makefile:92: test-style] Error 1 ``` Signed-off-by: Lu Fengqi --- pkg/getter/httpgetter.go | 1 - pkg/getter/httpgetter_test.go | 1 - pkg/repo/repotest/server.go | 1 - 3 files changed, 3 deletions(-) diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index c100b2cc0..ca4995c8a 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -99,7 +99,6 @@ func (g *HTTPGetter) httpClient() (*http.Client, error) { if err != nil { return nil, errors.Wrap(err, "can't create TLS config for client") } - tlsConf.BuildNameToCertificate() sni, err := urlutil.ExtractHostname(g.opts.url) if err != nil { diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index 90578f7b7..03b8b2e12 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -187,7 +187,6 @@ func TestDownloadTLS(t *testing.T) { if err != nil { t.Fatal(errors.Wrap(err, "can't create TLS config for client")) } - tlsConf.BuildNameToCertificate() tlsConf.ServerName = "helm.sh" tlsSrv.TLS = tlsConf tlsSrv.StartTLS() diff --git a/pkg/repo/repotest/server.go b/pkg/repo/repotest/server.go index b18bce49c..52a720499 100644 --- a/pkg/repo/repotest/server.go +++ b/pkg/repo/repotest/server.go @@ -159,7 +159,6 @@ func (s *Server) StartTLS() { if err != nil { panic(err) } - tlsConf.BuildNameToCertificate() tlsConf.ServerName = "helm.sh" s.srv.TLS = tlsConf s.srv.StartTLS()