From a181943fb810d967943c02e7661158b2cda3b014 Mon Sep 17 00:00:00 2001 From: Anton Galitsyn Date: Mon, 12 Dec 2016 18:18:20 +0700 Subject: [PATCH] split util to specific packages (#2) --- cmd/helm/dependency_build.go | 4 ++-- cmd/helm/dependency_update.go | 4 ++-- cmd/helm/fetch.go | 4 ++-- cmd/helm/repo_add.go | 4 ++-- cmd/helm/repo_update.go | 4 ++-- pkg/{util => httputil}/http.go | 6 ++++-- pkg/{util/crypto.go => tlsutil/tls.go} | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) rename pkg/{util => httputil}/http.go (90%) rename pkg/{util/crypto.go => tlsutil/tls.go} (99%) diff --git a/cmd/helm/dependency_build.go b/cmd/helm/dependency_build.go index 062307611..d85cc5efb 100644 --- a/cmd/helm/dependency_build.go +++ b/cmd/helm/dependency_build.go @@ -23,7 +23,7 @@ import ( "k8s.io/helm/cmd/helm/downloader" "k8s.io/helm/cmd/helm/helmpath" - "k8s.io/helm/pkg/util" + "k8s.io/helm/pkg/httputil" ) const dependencyBuildDesc = ` @@ -84,7 +84,7 @@ func (d *dependencyBuildCmd) run() error { var client *http.Client var err error if d.certFile != "" && d.keyFile != "" && d.caFile != "" { - client, err = util.NewHTTPClientTLS(d.certFile, d.keyFile, d.caFile) + client, err = httputil.NewHTTPClientTLS(d.certFile, d.keyFile, d.caFile) if err != nil { return err } diff --git a/cmd/helm/dependency_update.go b/cmd/helm/dependency_update.go index fbac0b8e5..b4296d54a 100644 --- a/cmd/helm/dependency_update.go +++ b/cmd/helm/dependency_update.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" "k8s.io/helm/cmd/helm/downloader" "k8s.io/helm/cmd/helm/helmpath" - "k8s.io/helm/pkg/util" + "k8s.io/helm/pkg/httputil" ) const dependencyUpDesc = ` @@ -94,7 +94,7 @@ func (d *dependencyUpdateCmd) run() error { var client *http.Client var err error if d.certFile != "" && d.keyFile != "" && d.caFile != "" { - client, err = util.NewHTTPClientTLS(d.certFile, d.keyFile, d.caFile) + client, err = httputil.NewHTTPClientTLS(d.certFile, d.keyFile, d.caFile) if err != nil { return err } diff --git a/cmd/helm/fetch.go b/cmd/helm/fetch.go index 52921628e..eb2c53508 100644 --- a/cmd/helm/fetch.go +++ b/cmd/helm/fetch.go @@ -28,7 +28,7 @@ import ( "k8s.io/helm/cmd/helm/downloader" "k8s.io/helm/cmd/helm/helmpath" "k8s.io/helm/pkg/chartutil" - "k8s.io/helm/pkg/util" + "k8s.io/helm/pkg/httputil" ) const fetchDesc = ` @@ -104,7 +104,7 @@ func (f *fetchCmd) run() error { var client *http.Client var err error if f.certFile != "" && f.keyFile != "" && f.caFile != "" { - client, err = util.NewHTTPClientTLS(f.certFile, f.keyFile, f.caFile) + client, err = httputil.NewHTTPClientTLS(f.certFile, f.keyFile, f.caFile) if err != nil { return err } diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index 42eb1f7df..45a390e58 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -26,8 +26,8 @@ import ( "github.com/spf13/cobra" "k8s.io/helm/cmd/helm/helmpath" + "k8s.io/helm/pkg/httputil" "k8s.io/helm/pkg/repo" - "k8s.io/helm/pkg/util" ) type repoAddCmd struct { @@ -77,7 +77,7 @@ func (a *repoAddCmd) run() error { var client *http.Client var err error if a.certFile != "" && a.keyFile != "" && a.caFile != "" { - client, err = util.NewHTTPClientTLS(a.certFile, a.keyFile, a.caFile) + client, err = httputil.NewHTTPClientTLS(a.certFile, a.keyFile, a.caFile) if err != nil { return err } diff --git a/cmd/helm/repo_update.go b/cmd/helm/repo_update.go index 3b0aa815d..4a2675575 100644 --- a/cmd/helm/repo_update.go +++ b/cmd/helm/repo_update.go @@ -26,8 +26,8 @@ import ( "github.com/spf13/cobra" "k8s.io/helm/cmd/helm/helmpath" + "k8s.io/helm/pkg/httputil" "k8s.io/helm/pkg/repo" - "k8s.io/helm/pkg/util" ) const updateDesc = ` @@ -77,7 +77,7 @@ func (u *repoUpdateCmd) run() error { var client *http.Client var err error if u.certFile != "" && u.keyFile != "" && u.caFile != "" { - client, err = util.NewHTTPClientTLS(u.certFile, u.keyFile, u.caFile) + client, err = httputil.NewHTTPClientTLS(u.certFile, u.keyFile, u.caFile) if err != nil { return err } diff --git a/pkg/util/http.go b/pkg/httputil/http.go similarity index 90% rename from pkg/util/http.go rename to pkg/httputil/http.go index bccf9ca95..8c2144257 100644 --- a/pkg/util/http.go +++ b/pkg/httputil/http.go @@ -14,16 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package httputil import ( "fmt" "net/http" + + "k8s.io/helm/pkg/tlsutil" ) // NewHTTPClientTLS constructs http.Client with configured TLS for http.Transport func NewHTTPClientTLS(certFile, keyFile, caFile string) (*http.Client, error) { - tlsConf, err := NewClientTLS(certFile, keyFile, caFile) + tlsConf, err := tlsutil.NewClientTLS(certFile, keyFile, caFile) if err != nil { return nil, fmt.Errorf("can't create TLS config for client: %s", err.Error()) } diff --git a/pkg/util/crypto.go b/pkg/tlsutil/tls.go similarity index 99% rename from pkg/util/crypto.go rename to pkg/tlsutil/tls.go index f6aa4d97b..05a671211 100644 --- a/pkg/util/crypto.go +++ b/pkg/tlsutil/tls.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package util +package tlsutil import ( "crypto/tls"