Skip to content

Commit

Permalink
Merge pull request #298 from vincepri/master-to-controlplane-yay
Browse files Browse the repository at this point in the history
✨ Master -> Control Plane
  • Loading branch information
k8s-ci-robot committed Jan 30, 2019
2 parents 6ada5f3 + 6cdc349 commit ff9beb8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,22 @@ import (
)

var (
kubeconfig, masterURL string
log = logf.RuntimeLog.WithName("client").WithName("config")
kubeconfig, apiServerURL string
log = logf.RuntimeLog.WithName("client").WithName("config")
)

func init() {
// TODO: Fix this to allow double vendoring this library but still register flags on behalf of users
flag.StringVar(&kubeconfig, "kubeconfig", "",
"Paths to a kubeconfig. Only required if out-of-cluster.")

flag.StringVar(&masterURL, "master", "",
"The address of the Kubernetes API server. Overrides any value in kubeconfig. "+
// This flag is deprecated, it'll be removed in a future iteration, please switch to --kubeconfig.
flag.StringVar(&apiServerURL, "master", "",
"(Deprecated: switch to `--kubeconfig`) The address of the Kubernetes API server. Overrides any value in kubeconfig. "+
"Only required if out-of-cluster.")
}

// GetConfig creates a *rest.Config for talking to a Kubernetes apiserver.
// GetConfig creates a *rest.Config for talking to a Kubernetes API server.
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
// in cluster and use the cluster provided kubeconfig.
//
Expand All @@ -59,11 +60,11 @@ func init() {
func GetConfig() (*rest.Config, error) {
// If a flag is specified with the config location, use that
if len(kubeconfig) > 0 {
return clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
return clientcmd.BuildConfigFromFlags(apiServerURL, kubeconfig)
}
// If an env variable is specified with the config locaiton, use that
if len(os.Getenv("KUBECONFIG")) > 0 {
return clientcmd.BuildConfigFromFlags(masterURL, os.Getenv("KUBECONFIG"))
return clientcmd.BuildConfigFromFlags(apiServerURL, os.Getenv("KUBECONFIG"))
}
// If no explicit location, try the in-cluster config
if c, err := rest.InClusterConfig(); err == nil {
Expand Down

0 comments on commit ff9beb8

Please sign in to comment.