From 95fbadbc6008daf21788cdb2ec2c266199891a26 Mon Sep 17 00:00:00 2001 From: Balazs Toth Date: Thu, 3 Jun 2021 17:02:17 +0200 Subject: [PATCH 1/2] Read password from stdin if not provided --- .gitignore | 1 + cmd/helm-cm-push/main.go | 11 +++++++++++ go.mod | 2 ++ 3 files changed, 14 insertions(+) diff --git a/.gitignore b/.gitignore index d3a50ad..41748cd 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ releases/ testbin/ testdata/**/tmp vendor/ +.project diff --git a/cmd/helm-cm-push/main.go b/cmd/helm-cm-push/main.go index a1ff0e7..bd40c8a 100644 --- a/cmd/helm-cm-push/main.go +++ b/cmd/helm-cm-push/main.go @@ -27,6 +27,8 @@ import ( v2downloader "k8s.io/helm/pkg/downloader" v2getter "k8s.io/helm/pkg/getter" v2environment "k8s.io/helm/pkg/helm/environment" + + "golang.org/x/crypto/ssh/terminal" ) type ( @@ -280,6 +282,15 @@ func (p *pushCmd) push() error { if p.password != "" { password = p.password } + + if username != "" && password == "" { + fmt.Printf("Enter password for %s: ", username) + bytePassword, err := terminal.ReadPassword(0) + if err == nil { + fmt.Println() + password = strings.TrimSpace(string(bytePassword)) + } + } // unset accessToken if repo credentials are provided if username != "" && password != "" { diff --git a/go.mod b/go.mod index 5bb76fd..08850d3 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,8 @@ go 1.17 require ( github.com/ghodss/yaml v1.0.0 github.com/spf13/cobra v1.2.1 + golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 + golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect helm.sh/helm/v3 v3.7.0 k8s.io/helm v2.17.0+incompatible ) From 0bca8140ea330c0a6d60d74db747cdd04f5d37ac Mon Sep 17 00:00:00 2001 From: Balazs Toth Date: Mon, 4 Oct 2021 20:53:16 +0200 Subject: [PATCH 2/2] rebase on chartmuseum main and update dependencies --- go.mod | 6 ++---- go.sum | 7 +++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 08850d3..cb2445e 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.17 require ( github.com/ghodss/yaml v1.0.0 github.com/spf13/cobra v1.2.1 - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 - golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 + golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef // indirect helm.sh/helm/v3 v3.7.0 k8s.io/helm v2.17.0+incompatible ) @@ -83,11 +83,9 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect - golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 // indirect golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect - golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect golang.org/x/text v0.3.6 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect diff --git a/go.sum b/go.sum index 2147e08..531644c 100644 --- a/go.sum +++ b/go.sum @@ -936,8 +936,9 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1135,8 +1136,10 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef h1:fPxZ3Umkct3LZ8gK9nbk+DWDJ9fstZa2grBn+lWVKPs= +golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=