From 7d61553463fc42e26680a4615c841511089f39bf Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Wed, 2 Mar 2022 17:58:15 +0000 Subject: [PATCH] Remove dependency to helm v2 Signed-off-by: Paulo Gomes --- go.mod | 1 - go.sum | 2 -- internal/helm/getter/getter.go | 11 ++++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 491ea3045..efd379e2a 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,6 @@ require ( k8s.io/api v0.23.3 k8s.io/apimachinery v0.23.3 k8s.io/client-go v0.23.3 - k8s.io/helm v2.17.0+incompatible k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 sigs.k8s.io/cli-utils v0.28.0 sigs.k8s.io/controller-runtime v0.11.1 diff --git a/go.sum b/go.sum index 73ecc77ed..acdb7bbd7 100644 --- a/go.sum +++ b/go.sum @@ -1759,8 +1759,6 @@ k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8 k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/helm v2.17.0+incompatible h1:Bpn6o1wKLYqKM3+Osh8e+1/K2g/GsQJ4F4yNF2+deao= -k8s.io/helm v2.17.0+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= diff --git a/internal/helm/getter/getter.go b/internal/helm/getter/getter.go index 4412700bb..0b45f0101 100644 --- a/internal/helm/getter/getter.go +++ b/internal/helm/getter/getter.go @@ -20,10 +20,10 @@ import ( "crypto/tls" "crypto/x509" "fmt" + "net/url" "helm.sh/helm/v3/pkg/getter" corev1 "k8s.io/api/core/v1" - "k8s.io/helm/pkg/urlutil" ) // ClientOptionsFromSecret constructs a getter.Option slice for the given secret. @@ -61,7 +61,7 @@ func BasicAuthFromSecret(secret corev1.Secret) (getter.Option, error) { // // Secrets with no certFile, keyFile, AND caFile are ignored, if only a // certBytes OR keyBytes is defined it returns an error. -func TLSClientConfigFromSecret(secret corev1.Secret, url string) (*tls.Config, error) { +func TLSClientConfigFromSecret(secret corev1.Secret, repositoryUrl string) (*tls.Config, error) { certBytes, keyBytes, caBytes := secret.Data["certFile"], secret.Data["keyFile"], secret.Data["caFile"] switch { case len(certBytes)+len(keyBytes)+len(caBytes) == 0: @@ -91,11 +91,12 @@ func TLSClientConfigFromSecret(secret corev1.Secret, url string) (*tls.Config, e tlsConf.BuildNameToCertificate() - sni, err := urlutil.ExtractHostname(url) + u, err := url.Parse(repositoryUrl) if err != nil { - return nil, err + return nil, fmt.Errorf("cannot parse repository URL: %w", err) } - tlsConf.ServerName = sni + + tlsConf.ServerName = u.Hostname() return tlsConf, nil }