From 3f3760a14a0f063cb608c8ff58357819f01739b5 Mon Sep 17 00:00:00 2001 From: Jeff Lowdermilk Date: Wed, 13 May 2015 13:54:02 -0700 Subject: [PATCH] Cleanup some todos for gke + rip out dead AuthConfig code --- cluster/kubectl.sh | 9 --------- cmd/e2e/e2e.go | 1 - hack/ginkgo-e2e.sh | 22 +++++++++------------- test/e2e/util.go | 22 +--------------------- 4 files changed, 10 insertions(+), 44 deletions(-) diff --git a/cluster/kubectl.sh b/cluster/kubectl.sh index f52c6abc630..10ccd4f83fa 100755 --- a/cluster/kubectl.sh +++ b/cluster/kubectl.sh @@ -105,15 +105,6 @@ if [[ "$KUBERNETES_PROVIDER" == "gke" ]]; then config=( "--context=gke_${PROJECT}_${ZONE}_${CLUSTER_NAME}" ) - # In gcloud versions prior to 0.9.59, GKE stores its kubeconfig - # in a separate location. If the file doesn't exist, then use - # the default kubeconfig file. - # TODO(roberthbailey): Remove this once gcloud 0.9.59 or above is released. - if [[ -e "${HOME}/.config/gcloud/kubernetes/kubeconfig" ]]; then - config+=( - "--kubeconfig=${HOME}/.config/gcloud/kubernetes/kubeconfig" - ) - fi elif [[ "$KUBERNETES_PROVIDER" == "ubuntu" ]]; then detect-master > /dev/null config=( diff --git a/cmd/e2e/e2e.go b/cmd/e2e/e2e.go index 9cd7e0f264d..da7b3616503 100644 --- a/cmd/e2e/e2e.go +++ b/cmd/e2e/e2e.go @@ -45,7 +45,6 @@ func init() { flag.StringVar(&context.KubeConfig, clientcmd.RecommendedConfigPathFlag, "", "Path to kubeconfig containing embeded authinfo.") flag.StringVar(&context.KubeContext, clientcmd.FlagContext, "", "kubeconfig context to use/override. If unset, will use value from 'current-context'") - flag.StringVar(&context.AuthConfig, "auth-config", "", "Path to the auth info file.") flag.StringVar(&context.CertDir, "cert-dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.") flag.StringVar(&context.Host, "host", "", "The host, or apiserver, to connect to") flag.StringVar(&context.RepoRoot, "repo-root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root") diff --git a/hack/ginkgo-e2e.sh b/hack/ginkgo-e2e.sh index 776294fe750..627a09d978d 100755 --- a/hack/ginkgo-e2e.sh +++ b/hack/ginkgo-e2e.sh @@ -87,18 +87,7 @@ if [[ -z "${AUTH_CONFIG:-}" ]]; then detect-master >/dev/null - # In gcloud versions < 0.9.59, GKE stores its kubeconfig in a separate - # location. - # TODO: Remove this once gcloud 0.9.59 or above is released. - if [[ "${KUBERNETES_PROVIDER}" == "gke" && -e "${GCLOUD_CONFIG_DIR}/kubeconfig" ]]; then - # GKE stores its own kubeconfig in gcloud's config directory. - detect-project &> /dev/null - auth_config=( - "--kubeconfig=${GCLOUD_CONFIG_DIR}/kubeconfig" - # gcloud doesn't set the current-context, so we have to set it - "--context=gke_${PROJECT}_${ZONE}_${CLUSTER_NAME}" - ) - elif [[ "${KUBERNETES_PROVIDER}" == "conformance_test" ]]; then + if [[ "${KUBERNETES_PROVIDER}" == "conformance_test" ]]; then auth_config=( "--auth_config=${KUBERNETES_CONFORMANCE_TEST_AUTH_CONFIG:-}" "--cert_dir=${KUBERNETES_CONFORMANCE_TEST_CERT_DIR:-}" @@ -106,7 +95,14 @@ if [[ -z "${AUTH_CONFIG:-}" ]]; then else auth_config=( "--kubeconfig=${KUBECONFIG:-$DEFAULT_KUBECONFIG}" - ) + ) + if [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then + # gcloud doesn't override the current-context, so we explicitly set it + detect-project &> /dev/null + auth_config+=( + "--context=gke_${PROJECT}_${ZONE}_${CLUSTER_NAME}" + ) + fi fi else echo "Conformance Test. No cloud-provider-specific preparation." diff --git a/test/e2e/util.go b/test/e2e/util.go index 29b08e8e726..a6b717c3fb9 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -34,7 +34,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd" - "github.com/GoogleCloudPlatform/kubernetes/pkg/clientauth" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -55,7 +54,6 @@ const ( type TestContextType struct { KubeConfig string KubeContext string - AuthConfig string CertDir string Host string RepoRoot string @@ -180,26 +178,8 @@ func loadConfig() (*client.Config, error) { c.CurrentContext = testContext.KubeContext } return clientcmd.NewDefaultClientConfig(*c, &clientcmd.ConfigOverrides{}).ClientConfig() - case testContext.AuthConfig != "": - fmt.Printf(">>> testContext.AuthConfig: %s\n", testContext.AuthConfig) - config := &client.Config{ - Host: testContext.Host, - } - info, err := clientauth.LoadFromFile(testContext.AuthConfig) - if err != nil { - return nil, fmt.Errorf("error loading AuthConfig: %v", err.Error()) - } - // If the certificate directory is provided, set the cert paths to be there. - if testContext.CertDir != "" { - Logf("Expecting certs in %v.", testContext.CertDir) - info.CAFile = filepath.Join(testContext.CertDir, "ca.crt") - info.CertFile = filepath.Join(testContext.CertDir, "kubecfg.crt") - info.KeyFile = filepath.Join(testContext.CertDir, "kubecfg.key") - } - mergedConfig, err := info.MergeWithConfig(*config) - return &mergedConfig, err default: - return nil, fmt.Errorf("either KubeConfig or AuthConfig must be specified to load client config") + return nil, fmt.Errorf("KubeConfig must be specified to load client config") } }