Cleanup some todos for gke + rip out dead AuthConfig code

pull/6/head
Jeff Lowdermilk 2015-05-13 13:54:02 -07:00
parent ad83197c63
commit 3f3760a14a
4 changed files with 10 additions and 44 deletions

View File

@ -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=(

View File

@ -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")

View File

@ -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."

View File

@ -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")
}
}