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

Fix retrieval of pflag stringArray #398

Closed
wants to merge 1 commit into from

Conversation

databus23
Copy link

pflag.StringArray suffers from the same problems as StringSlice did described in this issue #112

`pflag.StringArray` suffers from the same problems as `StringSlice` did described in this issue spf13#112
@CLAassistant
Copy link

CLAassistant commented Oct 17, 2017

CLA assistant check
All committers have signed the CLA.

@carolynvs
Copy link
Contributor

I have run into this same bug in cobra+viper and just tried out your patch. I'm still getting an empty string in the array, instead of an empty array when the flag was not specified.

([]string) (len=1 cap=1) {
 (string) ""
}

When I change my declaration of the flag from cmd.Flags().StringArrayVarP to cmd.Flags().StringSliceVarP, then I'm finally getting what I expected, an zero length slice/array.

([]string) {
}

I think fix this is close, because it is stripping out the extra square brackets, but it may need a bit more to remove the empty entry too.

carolynvs pushed a commit to carolynvs/service-catalog that referenced this pull request Jan 26, 2018
Switching from StringArray to StringSlice to workaround
spf13/viper#398.
jpeeler pushed a commit to kubernetes-retired/service-catalog that referenced this pull request Feb 6, 2018
* Workaround StringArray bug in Viper

Switching from StringArray to StringSlice to workaround
spf13/viper#398.

* Add failing test for viper bug

Split up validation and command execution so that we can test them
separately

* Test remaining svcat command validation
@denouche
Copy link

Hello, could we merge this bugfix?
Thanks!

@nickgerace
Copy link

nickgerace commented Mar 2, 2021

This would be extremely helpful for k3d-io/k3d#506 to be fixed. I'd be happy to help, if needed.

@bukowa
Copy link

bukowa commented Mar 8, 2021

I believe some tests may push it forward

iwilltry42 added a commit to iwilltry42/viper that referenced this pull request Mar 30, 2021
rancherio-gh-m pushed a commit to k3d-io/k3d that referenced this pull request Mar 30, 2021
Author: iwilltry42 <iwilltry42@gmail.com>
Date:   Tue Mar 30 15:26:37 2021 +0200

    [hotfix] use viper fork with fixed stringArray handling from spf13/viper#398
stoobmmelier pushed a commit to stoobmmelier/kubetap that referenced this pull request Jul 20, 2021
New flags added for
- customProxyPort
- disableReadinessProbe
- customProxyReadinessPath
- env vars

Also updated viper to include bug fix for StringArrayP
spf13/viper#398
stoobmmelier pushed a commit to stoobmmelier/kubetap that referenced this pull request Jul 20, 2021
New flags added for
- customProxyPort
- disableReadinessProbe
- customProxyReadinessPath
- env vars

Also updated viper to include bug fix for StringArrayP
spf13/viper#398

Signed-off-by: stoobmmelier <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants