-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Introduce --kubeconfig instead of --config #18806
Conversation
pkg/oc/admin/diagnostics/config.go
Outdated
@@ -32,7 +32,7 @@ func (o DiagnosticsOptions) detectClientConfig() (expected bool, detected bool) | |||
return false, false | |||
} | |||
o.Logger().Notice("CED2011", "Determining if client configuration exists for client/cluster diagnostics") | |||
confFlagName := config.OpenShiftConfigFlagName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks breaking. They're doing odd things and you have to tolerate both right? Add a test that would have caught this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sosiouxme I'll defer to you. We're trying to switch from --config
to --kubeconfig
and deprecated the former, does this fix look right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sosiouxme I'll defer to you. We're trying to switch from --config to --kubeconfig and deprecated the former, does this fix look right?
Does --config
still work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--config
is still accepted but is ignored, aside from deprecation notice. That's a little surprising as this is only looking at the value of the flag, which (since both new and old have the same target) I expected to be the same regardless of which flag was looked up. But apparently flags store the value separately from the target.
So the old flag remains, but has no effect. The code needs to be updated to either look at both flags or look at the shared target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--config is still accepted but is ignored, aside from deprecation notice.
@soltysh that won't work. Deprecated doesn't mean broken. The code needs to accept both.
that means it is probably broken elsewhere too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually not be surprised if this is the only place that looks at the flag itself as opposed to the value it sets. And I'd be happy to have it look at the value instead if I could figure out how to retrieve it... digging.
@@ -245,7 +245,7 @@ func (o *DiagnosticsOptions) bindCommonFlags(flags *flag.FlagSet) { | |||
func (o *DiagnosticsOptions) bindClientFlags(flags *flag.FlagSet) { | |||
o.ClientFlags = flag.NewFlagSet("client", flag.ContinueOnError) // hide the extensive set of client flags | |||
o.Factory = osclientcmd.New(o.ClientFlags) // that would otherwise be added to this command | |||
flags.AddFlag(o.ClientFlags.Lookup(config.OpenShiftConfigFlagName)) | |||
flags.AddFlag(o.ClientFlags.Lookup(kclientcmd.RecommendedConfigPathFlag)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sosiouxme same question
@@ -279,7 +279,7 @@ func (d *NetworkDiagnostic) getKubeConfig() ([]byte, error) { | |||
// 2. Default admin config paths | |||
// 3. Default openshift client config search paths | |||
paths := []string{} | |||
paths = append(paths, d.ClientFlags.Lookup(config.OpenShiftConfigFlagName).Value.String()) | |||
paths = append(paths, d.ClientFlags.Lookup(kclientcmd.RecommendedConfigPathFlag).Value.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sosiouxme same question
pkg/oc/cli/cmd/wrappers.go
Outdated
|
||
GlobalFile: cmdconfig.RecommendedHomeFile, | ||
EnvVar: cmdconfig.OpenShiftConfigPathEnvVar, | ||
ExplicitFileFlag: kclientcmd.RecommendedConfigPathFlag, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks breaking. Patches required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking as in, this will be the default flag asking for kubeconfig. Isn't that what we need to to if we want to deprecate --config
in 3.10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking as in, this will be the default flag asking for kubeconfig. Isn't that what we need to to if we want to deprecate --config in 3.10?
Does it respect --config
at all anymore?
test/integration/login_test.go
Outdated
@@ -149,7 +148,7 @@ func newLoginOptions(server string, username string, password string, insecure b | |||
func defaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig { | |||
loadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: ""} | |||
|
|||
flags.StringVar(&loadingRules.ExplicitPath, config.OpenShiftConfigFlagName, "", "Path to the config file to use for CLI requests.") | |||
flags.StringVar(&loadingRules.ExplicitPath, clientcmd.RecommendedConfigPathFlag, "", "Path to the kubeconfig file to use for CLI requests.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This somehow isn't breaking?
} else { | ||
flags.StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to the kubeconfig file to use for CLI requests.") | ||
} | ||
flags.StringVar(&loadingRules.ExplicitPath, clientcmd.OpenShiftKubeConfigFlagName, "", "Path to the kubeconfig file to use for CLI requests.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be conditional. When running as kubectl
we don't want this flag available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
} else { | ||
flags.StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to the kubeconfig file to use for CLI requests.") | ||
} | ||
flags.StringVar(&loadingRules.ExplicitPath, clientcmd.OpenShiftKubeConfigFlagName, "", "Path to the kubeconfig file to use for CLI requests.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does binding the same flag twice actually work? Which one wins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, multiple flags can bind to the same underlying value. last one parsed wins, just like if you specify the same flag multiple times:
oc --config foo.kubeconfig --config bar.kubeconfig get pods
error: stat bar.kubeconfig: no such file or directory
} | ||
|
||
func NewPathOptionsWithConfig(configPath string) *kclientcmd.PathOptions { | ||
return &kclientcmd.PathOptions{ | ||
GlobalFile: kclientcmd.RecommendedHomeFile, | ||
|
||
EnvVar: kclientcmd.RecommendedConfigPathEnvVar, | ||
ExplicitFileFlag: kclientcmd.OpenShiftKubeConfigFlagName, | ||
ExplicitFileFlag: kclientcmd.RecommendedConfigPathFlag, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks broken. Please explicitly check both flags with oc login
and oc project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added test to login.sh
checking both login and project.
pkg/oc/cli/config/loader.go
Outdated
@@ -8,15 +8,15 @@ import ( | |||
) | |||
|
|||
func NewPathOptions(cmd *cobra.Command) *kclientcmd.PathOptions { | |||
return NewPathOptionsWithConfig(kcmdutil.GetFlagString(cmd, kclientcmd.OpenShiftKubeConfigFlagName)) | |||
return NewPathOptionsWithConfig(kcmdutil.GetFlagString(cmd, kclientcmd.RecommendedConfigPathFlag)) | |||
} | |||
|
|||
func NewPathOptionsWithConfig(configPath string) *kclientcmd.PathOptions { | |||
return &kclientcmd.PathOptions{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was expecting a patch in this type that allowed the specification of two explicit flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/refresh |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: soltysh Assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Ha, my problem was with wrong apostrophes in |
/retest |
@soltysh: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@soltysh: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Closing in favor of #20721. |
/assign @deads2k @juanvallejo