Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Remove deprecated "--master" flag #1039

Merged
merged 1 commit into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 4 additions & 9 deletions pkg/client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,14 @@ import (
)

var (
kubeconfig, apiServerURL string
log = logf.RuntimeLog.WithName("client").WithName("config")
kubeconfig 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.")

// 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 API server.
Expand Down Expand Up @@ -105,7 +100,7 @@ func loadConfig(context string) (*rest.Config, error) {

// If a flag is specified with the config location, use that
if len(kubeconfig) > 0 {
return loadConfigWithContext(apiServerURL, &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig}, context)
return loadConfigWithContext("", &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig}, context)
}

// If the recommended kubeconfig env variable is not specified,
Expand Down Expand Up @@ -134,7 +129,7 @@ func loadConfig(context string) (*rest.Config, error) {
loadingRules.Precedence = append(loadingRules.Precedence, path.Join(u.HomeDir, clientcmd.RecommendedHomeDir, clientcmd.RecommendedFileName))
}

return loadConfigWithContext(apiServerURL, loadingRules, context)
return loadConfigWithContext("", loadingRules, context)
}

func loadConfigWithContext(apiServerURL string, loader clientcmd.ClientConfigLoader, context string) (*rest.Config, error) {
Expand Down
11 changes: 0 additions & 11 deletions pkg/client/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (

type testCase struct {
text string
apiServerURL string
context string
kubeconfigFlag string
kubeconfigEnv []string
Expand All @@ -56,7 +55,6 @@ var _ = Describe("Config", func() {
AfterEach(func() {
os.Unsetenv(clientcmd.RecommendedConfigPathEnvVar)
kubeconfig = ""
apiServerURL = ""
clientcmd.RecommendedHomeFile = origRecommendedHomeFile

err := os.RemoveAll(dir)
Expand Down Expand Up @@ -158,12 +156,6 @@ var _ = Describe("Config", func() {
kubeconfigEnv: []string{"kubeconfig-multi-context"},
wantHost: "from-multi-env-1",
},
{
text: "should allow overriding the API server URL",
apiServerURL: "override",
kubeconfigEnv: []string{"kubeconfig-multi-context"},
wantHost: "override",
},
{
text: "should allow overriding the context",
context: "from-multi-env-2",
Expand All @@ -183,9 +175,6 @@ var _ = Describe("Config", func() {
})

func setConfigs(tc testCase, dir string) {
// Set API Server URL
apiServerURL = tc.apiServerURL

// Set kubeconfig flag value
if len(tc.kubeconfigFlag) > 0 {
kubeconfig = filepath.Join(dir, tc.kubeconfigFlag)
Expand Down