prow/cmd/mkbuild-cluster/main.go
func getCredentials(o options) error {
	if !o.changeContext {
		cur, err := currentContext(o)
		if err != nil {
			return fmt.Errorf("read current-context: %v", err)
		}
		defer useContext(o, cur)
	}

	// TODO(fejta): we ought to update kube.Client to support modern auth methods.
	// More info: https://github.com/kubernetes/kubernetes/issues/30617
	old, set := os.LookupEnv(useClientCertEnv)
	if set {
		defer os.Setenv(useClientCertEnv, old)
	}
	if err := os.Setenv("CLOUDSDK_CONTAINER_USE_CLIENT_CERTIFICATE", "True"); err != nil {
		return fmt.Errorf("failed to set %s: %v", useClientCertEnv, err)
	}
	args, cmd := command(
		"gcloud", "container", "clusters", "get-credentials", o.cluster,
		"--project", o.project,
		"--zone", o.zone,
	)
	if err := cmd.Run(); err != nil {
		return fmt.Errorf("%s: %v", strings.Join(args, " "), err)
	}
	return nil
}
func getCredentials(o options) error {
	if !o.changeContext {
		cur, err := currentContext(o)
		if err != nil {
			return fmt.Errorf("read current-context: %v", err)
		}
		defer useContext(o, cur)
	}

	// TODO(fejta): we ought to update kube.Client to support modern auth methods.
	// More info: https://github.com/kubernetes/kubernetes/issues/30617
	old, set := os.LookupEnv(useClientCertEnv)
	if set {
		defer os.Setenv(useClientCertEnv, old)
	}
	if err := os.Setenv("CLOUDSDK_CONTAINER_USE_CLIENT_CERTIFICATE", "True"); err != nil {
		return fmt.Errorf("failed to set %s: %v", useClientCertEnv, err)
	}
	args, cmd := command(
		"gcloud", "container", "clusters", "get-credentials", o.cluster,
		"--project", o.project,
		"--zone", o.zone,
	)
	if err := cmd.Run(); err != nil {
		return fmt.Errorf("%s: %v", strings.Join(args, " "), err)
	}
	return nil
}
func getCredentials ( o options ) error { if ! o . changeContext { cur , err := currentContext ( o ) if err != nil { return fmt . Errorf ( " " , err ) } defer useContext ( o , cur ) } // TODO(fejta): we ought to update kube.Client to support modern auth methods. // More info: https://github.com/kubernetes/kubernetes/issues/30617 old , set := os . LookupEnv ( useClientCertEnv ) if set { defer os . Setenv ( useClientCertEnv , old ) } if err := os . Setenv ( " " , " " ) ; err != nil { return fmt . Errorf ( " " , useClientCertEnv , err ) } args , cmd := command ( " " , " " , " " , " " , o . cluster , " " , o . project , " " , o . zone , ) if err := cmd . Run ( ) ; err != nil { return fmt . Errorf ( " " , strings . Join ( args , " " ) , err ) } return nil }
// getCredentials calls gcloud container clusters get-credentials, usually preserving currentContext()
getCredentials calls gcloud container clusters get - credentials usually preserving currentContext ()