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

[plugin] kubectl plugin env variable is not incorrect #337

Closed
tamalsaha opened this issue Mar 5, 2018 · 10 comments
Closed

[plugin] kubectl plugin env variable is not incorrect #337

tamalsaha opened this issue Mar 5, 2018 · 10 comments
Assignees
Labels
area/kubectl help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/P2 sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@tamalsaha
Copy link
Member

I am experimenting with writing plugins for kubectl. One issue I found is that KUBECTL_PLUGINS_GLOBAL_FLAG_AS_GROUP flag is set to [] when this flag is not set.

KUBECTL_PLUGINS_GLOBAL_FLAG_AS_GROUP=[]

When I try to set this env value back via pflag.Set(), it is considered as []string{"[]"}. .This causes DefaultClientConfig(flags) to throw error. You can find my demo code here: https://github.com/tamalsaha/kubectl-plugin-demo/blob/master/root.go#L79

The real problem seems to be that String() and Set(val string) methods of stringArrayValue in pflag library does not properly handle "empty" value for flags.

@mengqiy mengqiy added kind/bug Categorizes issue or PR as related to a bug. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Mar 5, 2018
@tamalsaha tamalsaha changed the title kubectl plugin env variable is not incorrect [plugin] kubectl plugin env variable is not incorrect Mar 8, 2018
@carolynvs
Copy link

I hit a similar (maybe the same?) bug in spf13/viper. Here's a related open PR: spf13/viper#398.

I was able to work around the problem by switching to StringSlice instead of StringArray. https://github.com/kubernetes-incubator/service-catalog/pull/1700/files#diff-bac754e10d86591646bb672b9577e16bR74

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 6, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 6, 2018
@nikhita
Copy link
Member

nikhita commented Jul 18, 2018

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jul 18, 2018
@seans3
Copy link
Contributor

seans3 commented Sep 25, 2018

/sig cli
/kind kubectl
/assign @juanvallejo

@k8s-ci-robot k8s-ci-robot added the sig/cli Categorizes an issue or PR as relevant to SIG CLI. label Sep 25, 2018
@seans3
Copy link
Contributor

seans3 commented Sep 25, 2018

/area kubectl

@seans3
Copy link
Contributor

seans3 commented Sep 25, 2018

/priority P2

@seans3
Copy link
Contributor

seans3 commented Sep 25, 2018

Is this still relevant with the new plugin mechanism? Please close if this is obsolete.

@juanvallejo
Copy link

This should no longer be an issue with the updated plugin mechanism. Environment variables are now passed as-is, and user-defined command flags and parameters are now passed straight through to a plugin executable.

/close

@k8s-ci-robot
Copy link
Contributor

@juanvallejo: Closing this issue.

In response to this:

This should no longer be an issue with the updated plugin mechanism. Environment variables are now passed as-is, and user-defined command flags and parameters are now passed straight through to a plugin executable.

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/P2 sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

No branches or pull requests

8 participants