diff --git a/cmd/helm/get_test.go b/cmd/helm/get_test.go index cfcc49968..ff213508a 100644 --- a/cmd/helm/get_test.go +++ b/cmd/helm/get_test.go @@ -17,11 +17,11 @@ limitations under the License. package main import ( + "fmt" "io" "testing" "github.com/spf13/cobra" - "fmt" ) func TestGetCmd(t *testing.T) { @@ -30,7 +30,7 @@ func TestGetCmd(t *testing.T) { name: "get with a release", resp: releaseMock(&releaseOptions{name: "thomas-guide"}), args: []string{"thomas-guide"}, - expected: fmt.Sprintf("REVISION: 1\nRELEASED: (.*)\nRELEASED BY: %s\nCHART: foo-0.1.0-beta.1\nUSER-SUPPLIED VALUES:\nname: \"value\"\nCOMPUTED VALUES:\nname: value\n\nHOOKS:\n---\n# pre-install-hook\n" + mockHookTemplate + "\nMANIFEST:", username), + expected: fmt.Sprintf("REVISION: 1\nRELEASED: (.*)\nRELEASED BY: %s\nCHART: foo-0.1.0-beta.1\nUSER-SUPPLIED VALUES:\nname: \"value\"\nCOMPUTED VALUES:\nname: value\n\nHOOKS:\n---\n# pre-install-hook\n"+mockHookTemplate+"\nMANIFEST:", username), }, { name: "get requires release name arg", diff --git a/cmd/helm/history_test.go b/cmd/helm/history_test.go index 953890037..a99f8c885 100644 --- a/cmd/helm/history_test.go +++ b/cmd/helm/history_test.go @@ -18,11 +18,11 @@ package main import ( "bytes" + "fmt" "regexp" "testing" rpb "k8s.io/helm/pkg/proto/hapi/release" - "fmt" ) func TestHistoryCmd(t *testing.T) { diff --git a/cmd/helm/list_test.go b/cmd/helm/list_test.go index 4c0fc549c..8982e633a 100644 --- a/cmd/helm/list_test.go +++ b/cmd/helm/list_test.go @@ -18,11 +18,11 @@ package main import ( "bytes" + "fmt" "regexp" "testing" "k8s.io/helm/pkg/proto/hapi/release" - "fmt" ) func TestListCmd(t *testing.T) { diff --git a/pkg/helm/option.go b/pkg/helm/option.go index c2b077ea7..8d44a0e92 100644 --- a/pkg/helm/option.go +++ b/pkg/helm/option.go @@ -414,38 +414,38 @@ func extractKubeConfig() map[string]string { // Kube APIServer URL if len(c.Host) != 0 { - configData[K8sServer] = c.Host + configData[string(K8sServer)] = c.Host } if c.AuthProvider != nil { switch c.AuthProvider.Name { case "gcp": - configData[Authorization] = "Bearer " + c.AuthProvider.Config["access_token"] + configData[string(Authorization)] = "Bearer " + c.AuthProvider.Config["access_token"] case "oidc": - configData[Authorization] = "Bearer " + c.AuthProvider.Config["id-token"] + configData[string(Authorization)] = "Bearer " + c.AuthProvider.Config["id-token"] default: panic("Unknown auth provider: " + c.AuthProvider.Name) } } if len(c.BearerToken) != 0 { - configData[Authorization] = "Bearer " + c.BearerToken + configData[string(Authorization)] = "Bearer " + c.BearerToken } if len(c.Username) != 0 && len(c.Password) != 0 { - configData[Authorization] = "Basic " + base64.StdEncoding.EncodeToString([]byte(c.Username+":"+c.Password)) + configData[string(Authorization)] = "Basic " + base64.StdEncoding.EncodeToString([]byte(c.Username+":"+c.Password)) } if len(string(c.CAData)) != 0 { - configData[K8sCertificateAuthority] = base64.StdEncoding.EncodeToString(bytes.TrimSpace(c.CAData)) + configData[string(K8sCertificateAuthority)] = base64.StdEncoding.EncodeToString(bytes.TrimSpace(c.CAData)) } if len(string(c.TLSClientConfig.KeyData)) != 0 { - configData[K8sClientKey] = base64.StdEncoding.EncodeToString(c.TLSClientConfig.KeyData) + configData[string(K8sClientKey)] = base64.StdEncoding.EncodeToString(c.TLSClientConfig.KeyData) } if len(string(c.TLSClientConfig.CertData)) != 0 { - configData[K8sClientCertificate] = base64.StdEncoding.EncodeToString(c.TLSClientConfig.CertData) + configData[string(K8sClientCertificate)] = base64.StdEncoding.EncodeToString(c.TLSClientConfig.CertData) } if len(c.TLSClientConfig.CAFile) != 0 { @@ -453,7 +453,7 @@ func extractKubeConfig() map[string]string { if err != nil { log.Println(err) } else { - configData[K8sCertificateAuthority] = base64.StdEncoding.EncodeToString(b) + configData[string(K8sCertificateAuthority)] = base64.StdEncoding.EncodeToString(b) } } @@ -462,7 +462,7 @@ func extractKubeConfig() map[string]string { if err != nil { log.Println(err) } else { - configData[K8sClientCertificate] = base64.StdEncoding.EncodeToString(b) + configData[string(K8sClientCertificate)] = base64.StdEncoding.EncodeToString(b) } } @@ -472,7 +472,7 @@ func extractKubeConfig() map[string]string { if err != nil { log.Println(err) } else { - configData[K8sClientKey] = base64.StdEncoding.EncodeToString(b) + configData[string(K8sClientKey)] = base64.StdEncoding.EncodeToString(b) } } } diff --git a/pkg/helm/types.go b/pkg/helm/types.go index 9b0b0a32e..8f92aaa6f 100644 --- a/pkg/helm/types.go +++ b/pkg/helm/types.go @@ -1,13 +1,15 @@ package helm +type AuthHeader string + const ( - Authorization = "authorization" - K8sServer = "k8s-server" - K8sClientCertificate = "k8s-client-certificate" - K8sCertificateAuthority = "k8s-certificate-authority" - K8sClientKey = "k8s-client-key" + Authorization AuthHeader = "authorization" + K8sServer AuthHeader = "k8s-server" + K8sClientCertificate AuthHeader = "k8s-client-certificate" + K8sCertificateAuthority AuthHeader = "k8s-certificate-authority" + K8sClientKey AuthHeader = "k8s-client-key" // Generated from input keys above - K8sUser = "k8s-user" - K8sConfig = "k8s-client-config" + K8sUser AuthHeader = "k8s-user" + K8sConfig AuthHeader = "k8s-client-config" ) diff --git a/pkg/tiller/release_server.go b/pkg/tiller/release_server.go index c032852af..d28b6d708 100644 --- a/pkg/tiller/release_server.go +++ b/pkg/tiller/release_server.go @@ -28,8 +28,8 @@ import ( "github.com/technosophos/moniker" ctx "golang.org/x/net/context" "k8s.io/helm/pkg/chartutil" - "k8s.io/helm/pkg/hooks" "k8s.io/helm/pkg/helm" + "k8s.io/helm/pkg/hooks" "k8s.io/helm/pkg/kube" "k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/release" diff --git a/pkg/tiller/server.go b/pkg/tiller/server.go index 2b018ffa0..fc775021f 100644 --- a/pkg/tiller/server.go +++ b/pkg/tiller/server.go @@ -62,7 +62,7 @@ func authenticate(ctx context.Context) (context.Context, error) { var user *authenticationapi.UserInfo var kubeConfig *rest.Config var err error - authHeader, ok := md[helm.Authorization] + authHeader, ok := md[string(helm.Authorization)] if !ok || authHeader[0] == "" { user, kubeConfig, err = checkClientCert(ctx) } else { @@ -123,7 +123,7 @@ func newStreamInterceptor() grpc.StreamServerInterceptor { } newStream := serverStreamWrapper{ - ss: ss, + ss: ss, ctx: ctx, } return handler(srv, newStream) @@ -170,7 +170,7 @@ func checkClientVersion(ctx context.Context) error { func checkBearerAuth(ctx context.Context) (*authenticationapi.UserInfo, *rest.Config, error) { md, _ := metadata.FromContext(ctx) - token := md[helm.Authorization][0][len("Bearer "):] + token := md[string(helm.Authorization)][0][len("Bearer "):] apiServer, err := getServerURL(md) if err != nil { @@ -236,7 +236,7 @@ func checkBearerAuth(ctx context.Context) (*authenticationapi.UserInfo, *rest.Co func checkBasicAuth(ctx context.Context) (*authenticationapi.UserInfo, *rest.Config, error) { md, _ := metadata.FromContext(ctx) - authz := md[helm.Authorization][0] + authz := md[string(helm.Authorization)][0] apiServer, err := getServerURL(md) if err != nil { @@ -335,7 +335,7 @@ func checkClientCert(ctx context.Context) (*authenticationapi.UserInfo, *rest.Co } func getClientCert(md metadata.MD) ([]byte, error) { - cert, ok := md[helm.K8sClientCertificate] + cert, ok := md[string(helm.K8sClientCertificate)] if !ok { return nil, errors.New("Client certificate not found") } @@ -347,7 +347,7 @@ func getClientCert(md metadata.MD) ([]byte, error) { } func getClientKey(md metadata.MD) ([]byte, error) { - key, ok := md[helm.K8sClientKey] + key, ok := md[string(helm.K8sClientKey)] if !ok { return nil, errors.New("Client key not found") } @@ -359,7 +359,7 @@ func getClientKey(md metadata.MD) ([]byte, error) { } func getCertificateAuthority(md metadata.MD) ([]byte, error) { - caData, ok := md[helm.K8sCertificateAuthority] + caData, ok := md[string(helm.K8sCertificateAuthority)] if !ok { return nil, errors.New("CAcert not found") } @@ -371,7 +371,7 @@ func getCertificateAuthority(md metadata.MD) ([]byte, error) { } func getServerURL(md metadata.MD) (string, error) { - apiserver, ok := md[helm.K8sServer] + apiserver, ok := md[string(helm.K8sServer)] if !ok { return "", errors.New("API server url not found") }