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

cli: drop support for passing comma-separated template parameters through --param/--value #11539

Merged

Conversation

mmilata
Copy link
Contributor

@mmilata mmilata commented Oct 24, 2016

Related to #10687, #10952.

TODO:

The bump commit was created manually because I've been unable to make godep restore work for me. The bump is needed in order to have https://godoc.org/github.com/spf13/pflag#StringArray.

@liggitt
Copy link
Contributor

liggitt commented Oct 24, 2016

can we bump to the same level as 1.4 upstream (1560c1005499d61b80f865c04d39ca7505bf7f0b)? https://github.com/kubernetes/kubernetes/blob/release-1.4/Godeps/Godeps.json#L2050-L2053

@liggitt
Copy link
Contributor

liggitt commented Oct 24, 2016

or if this is post-1.4, to whatever is currently in master upstream

@liggitt
Copy link
Contributor

liggitt commented Oct 24, 2016

ah, nevermind... looks like 1.4 didn't have stringarray

@mmilata
Copy link
Contributor Author

mmilata commented Oct 25, 2016

@liggitt kubernetes master has c7e63cf4530bcd3ba943729cee0efeff2ebea63f which has StringArray but is missing a bunch of small fixes

@mmilata
Copy link
Contributor Author

mmilata commented Oct 25, 2016

@bparees @smarterclayton PTAL

Docs update: openshift/openshift-docs#3107.

Does [test] run the cmd tests?

@mmilata mmilata force-pushed the disallow-multiple-template-params branch from 9312063 to 5f0e901 Compare October 25, 2016 13:20
@mmilata
Copy link
Contributor Author

mmilata commented Oct 25, 2016

Does [test] run the cmd tests?

It does. [test] again

@liggitt
Copy link
Contributor

liggitt commented Oct 25, 2016

Please open an upstream PR bumping to the same version then

Copy link
Contributor

@bparees bparees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmilata does this also resolve the issue of the $(cat foo) syntax only capturing the first line? I can't remember if that as just a pflag update or something else.

@@ -166,7 +166,7 @@ func NewCmdNewApplication(name, baseName string, f *clientcmd.Factory, out, erro
cmd.Flags().StringSliceVar(&config.Templates, "template", config.Templates, "Name of a stored template to use in the app.")
cmd.Flags().StringSliceVarP(&config.TemplateFiles, "file", "f", config.TemplateFiles, "Path to a template file to use for the app.")
cmd.MarkFlagFilename("file", "yaml", "yml", "json")
cmd.Flags().StringSliceVarP(&config.TemplateParameters, "param", "p", config.TemplateParameters, "Specify a list of key value pairs (e.g., -p FOO=BAR,BAR=FOO) to set/override parameter values in the template.")
cmd.Flags().StringArrayVarP(&config.TemplateParameters, "param", "p", config.TemplateParameters, "Specify a key-value pair (e.g., -p FOO=BAR) to set/override parameter value in the template.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to set/override a parameter value"

kcmdutil.CheckErr(err)
},
}
cmd.Flags().StringP("filename", "f", "", "Filename or URL to file to read a template")
cmd.MarkFlagFilename("filename", "yaml", "yml", "json")
cmd.Flags().StringSliceP("value", "v", nil, "Specify a list of key-value pairs (eg. -v FOO=BAR,BAR=FOO) to set/override parameter values")
cmd.Flags().StringArrayP("value", "v", nil, "Specify a key-value pair (eg. -v FOO=BAR) to set/override parameter value in the template.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to set/override a parameter value"

@@ -166,7 +166,7 @@ func NewCmdNewApplication(name, baseName string, f *clientcmd.Factory, out, erro
cmd.Flags().StringSliceVar(&config.Templates, "template", config.Templates, "Name of a stored template to use in the app.")
cmd.Flags().StringSliceVarP(&config.TemplateFiles, "file", "f", config.TemplateFiles, "Path to a template file to use for the app.")
cmd.MarkFlagFilename("file", "yaml", "yml", "json")
cmd.Flags().StringSliceVarP(&config.TemplateParameters, "param", "p", config.TemplateParameters, "Specify a list of key value pairs (e.g., -p FOO=BAR,BAR=FOO) to set/override parameter values in the template.")
cmd.Flags().StringArrayVarP(&config.TemplateParameters, "param", "p", config.TemplateParameters, "Specify a key-value pair (e.g., -p FOO=BAR) to set/override parameter value in the template.")
cmd.Flags().StringSliceVar(&config.Groups, "group", config.Groups, "Indicate components that should be grouped together as <comp1>+<comp2>.")
cmd.Flags().StringSliceVarP(&config.Environment, "env", "e", config.Environment, "Specify key-value pairs of environment variables to set into each container. This doesn't apply to objects created from a template, use parameters instead.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should do the same thing for env (drop comma support, add a warning)

@bparees bparees self-assigned this Oct 25, 2016
@mmilata mmilata force-pushed the disallow-multiple-template-params branch 2 times, most recently from 2ef8bd0 to 7618ef3 Compare October 27, 2016 11:38
@mmilata
Copy link
Contributor Author

mmilata commented Oct 27, 2016

@bparees updated to handle --env arguments as well. Multiline values shouldn't be a problem, StringArray should handle them fine, StringSlice does not. There's a [test] case for this in test/cmd/process.sh.

@@ -139,7 +139,7 @@ func NewCmdUp(name, fullName string, f *osclientcmd.Factory, out io.Writer) *cob
cmd.Flags().StringVar(&config.HostDataDir, "host-data-dir", "", "Directory on Docker host for OpenShift data. If not specified, etcd data will not be persisted on the host.")
cmd.Flags().BoolVar(&config.PortForwarding, "forward-ports", config.PortForwarding, "Use Docker port-forwarding to communicate with origin container. Requires 'socat' locally.")
cmd.Flags().IntVar(&config.ServerLogLevel, "server-loglevel", 0, "Log level for OpenShift server")
cmd.Flags().StringSliceVarP(&config.Environment, "env", "e", config.Environment, "Specify key value pairs of environment variables to set on OpenShift container")
cmd.Flags().StringArrayVarP(&config.Environment, "env", "e", config.Environment, "Specify a key value pair of environment variable to set on OpenShift container")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Specify a key value pair of environment variable"->"Specify a key value pair for an environment variable"

cmd.Flags().StringSliceVar(&config.Groups, "group", config.Groups, "Indicate components that should be grouped together as <comp1>+<comp2>.")
cmd.Flags().StringSliceVarP(&config.Environment, "env", "e", config.Environment, "Specify key-value pairs of environment variables to set into each container. This doesn't apply to objects created from a template, use parameters instead.")
cmd.Flags().StringArrayVarP(&config.Environment, "env", "e", config.Environment, "Specify a key-value pair of environment variable to set into each container. This doesn't apply to objects created from a template, use parameters instead.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a key value pair of environment variable -> Specify a key value pair for an environment variable

@@ -128,7 +128,7 @@ func NewCmdNewBuild(name, baseName string, f *clientcmd.Factory, in io.Reader, o
cmd.Flags().StringVar(&config.Name, "name", "", "Set name to use for generated build artifacts.")
cmd.Flags().StringVar(&config.To, "to", "", "Push built images to this image stream tag (or Docker image repository if --to-docker is set).")
cmd.Flags().BoolVar(&config.OutputDocker, "to-docker", false, "Have the build output push to a Docker repository.")
cmd.Flags().StringSliceVarP(&config.Environment, "env", "e", config.Environment, "Specify key value pairs of environment variables to set into resulting image.")
cmd.Flags().StringArrayVarP(&config.Environment, "env", "e", config.Environment, "Specify a key value pair of environment variable to set into resulting image.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a key value pair of environment variable -> Specify a key value pair for an environment variable

@@ -93,7 +93,7 @@ func NewCmdEnv(fullName string, f *clientcmd.Factory, in io.Reader, out, errout
cmd.Flags().StringP("containers", "c", "*", "The names of containers in the selected pod templates to change - may use wildcards")
cmd.Flags().StringP("from", "", "", "The name of a resource from which to inject enviroment variables")
cmd.Flags().StringP("prefix", "", "", "Prefix to append to variable names")
cmd.Flags().StringSliceVarP(&env, "env", "e", env, "Specify key value pairs of environment variables to set into each container.")
cmd.Flags().StringArrayVarP(&env, "env", "e", env, "Specify a key value pair of environment variable to set into each container.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a key value pair of environment variable -> Specify a key value pair for an environment variable

@@ -90,7 +90,7 @@ func NewCmdStartBuild(fullName string, f *clientcmd.Factory, in io.Reader, out,
},
}
cmd.Flags().StringVar(&o.LogLevel, "build-loglevel", o.LogLevel, "Specify the log level for the build log output")
cmd.Flags().StringSliceVarP(&o.Env, "env", "e", o.Env, "Specify key value pairs of environment variables to set for the build container.")
cmd.Flags().StringArrayVarP(&o.Env, "env", "e", o.Env, "Specify a key value pair of environment variable to set for the build container.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a key value pair of environment variable -> Specify a key value pair for an environment variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that sounds better. BTW some of the descriptions say key value pair while others have key-value pair, I suppose it would be nice to be consistent. Which one is correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like key-value

func WarnAboutCommaSeparation(errout io.Writer, values []string, flag string) {
for _, value := range values {
if strings.ContainsRune(value, ',') {
fmt.Fprintf(errout, "warning: %s no longer accepts comma-separated list of values. %q will be treated as a single key-value pair.\n", flag, value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/list/lists/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should only warn if the value looks like "key1=value1,key2=value2". In other words, we have to see both a command and an equal after key1= for it to be a problem. There's nothing wrong with "key1=a,b,c"

@bparees
Copy link
Contributor

bparees commented Oct 27, 2016

@mfojtik you will need to review this also since it's changing oc set for deploymentconfigs.

@mmilata
Copy link
Contributor Author

mmilata commented Oct 27, 2016

@bparees fixed the descriptions, changed the warning functions to match against .*=.*,.*=.*.

Copy link
Contributor

@bparees bparees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple more test requests and then lgtm.

os::cmd::expect_success_and_not_text 'oc new-app ruby-helloworld-sample --param MYSQL_PASSWORD=com,ma -o yaml' 'no longer accepts comma-separated list'
# check that warning is not printed when parameters/env are passed positionally
os::cmd::expect_success_and_not_text 'oc new-app php PASS=one,two=three -o yaml' 'no longer accepts comma-separated list'
os::cmd::expect_success_and_not_text 'oc new-app ruby-helloworld-sample MYSQL_PASSWORD=one,two=three -o yaml' 'no longer accepts comma-separated list'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two tests should also confirm that the parameter/env is not split.

os::cmd::expect_success_and_text 'oc new-build --binary php --env X=Y,Z=W -o yaml' 'no longer accepts comma-separated list'
os::cmd::expect_success_and_not_text 'oc new-build --binary php --env X=Y,Z,W -o yaml' 'no longer accepts comma-separated list'
os::cmd::expect_success_and_not_text 'oc new-build --binary php --env X=Y -o yaml' 'no longer accepts comma-separated list'
os::cmd::expect_success_and_not_text 'oc new-build --binary php X=Y,Z=W -o yaml' 'no longer accepts comma-separated list'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirm this test does not split the env into two.

os::cmd::expect_success_and_not_text "oc process -f '${required_params}' --value=required_param=a_b_c_d" 'no longer accepts comma-separated list'
os::cmd::expect_success_and_not_text "oc process -f '${required_params}' --value=required_param=a,b,c,d" 'no longer accepts comma-separated list'
# warning is not printed for template values passed as positional arguments
os::cmd::expect_success_and_not_text "oc process -f '${required_params}' required_param=a,b=c,d" 'no longer accepts comma-separated list'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirm argument is not split.

os::cmd::expect_success_and_text 'oc process ruby-helloworld-sample MYSQL_USER=myself MYSQL_PASSWORD=my,1%pass' '"myself"'
os::cmd::expect_success_and_text 'oc process MYSQL_USER=myself MYSQL_PASSWORD=my,1%pass ruby-helloworld-sample' '"my,1%pass"'
os::cmd::expect_success_and_text 'oc process ruby-helloworld-sample MYSQL_USER=myself MYSQL_PASSWORD=my,1%pa=s' '"myself"'
os::cmd::expect_success_and_text 'oc process MYSQL_USER=myself MYSQL_PASSWORD=my,1%pa=s ruby-helloworld-sample' '"my,1%pa=s"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this covers at least one of the test suggestions i made above.

I wonder if cmd/templates.sh and cmd/process.sh should be combined into a single test script so we can do some de-duping.

Not for this PR though.

@mmilata mmilata force-pushed the disallow-multiple-template-params branch from 145dcb7 to b39d554 Compare October 28, 2016 00:19
@mmilata mmilata force-pushed the disallow-multiple-template-params branch from b39d554 to d3df274 Compare October 28, 2016 12:09
@mmilata
Copy link
Contributor Author

mmilata commented Oct 28, 2016

Following assertion failed because oc new-app never supported template parameters as positional arguments (unlike oc process):

os::cmd::expect_success_and_text 'oc new-app ruby-helloworld-sample MYSQL_PASSWORD=one,two=three -o yaml' 'value: one,two=three'

Pushed new version with the test removed.

@danmcp
Copy link

danmcp commented Oct 28, 2016

Flaked on #10988

k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request Oct 30, 2016
Automatic merge from submit-queue

Update github.com/spf13/pflag to latest version

<!--  Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md
2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md
3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes
-->

**What this PR does / why we need it**:
This PR updates `github.com/spf13/pflag` to the latest version.

* OpenShift needs pflag bump in order to use [`StringArray`](spf13/pflag#89), and
* Latest revision contains couple of bugfixes that I'd like to have there, and
* Kubernetes should have the same version, which is the reason for this PR

**Which issue this PR fixes**:
None, related to openshift/origin#11539.

**Special notes for your reviewer**:
`hack/verify-godeps.sh` fails with following output even though I haven't touched that package: https://gist.github.com/mmilata/3cb84b754f9b9e7ff371a7b6c5131b09

Am I using the wrong golang/godep version perhaps? Any hint what am I doing wrong?
**Release note**:
<!--  Steps to write your release note:
1. Use the release-note-* labels to set the release note state (if you have access) 
2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`. 
-->
```release-note
NONE
```
@mmilata
Copy link
Contributor Author

mmilata commented Oct 31, 2016

[test]

@mmilata
Copy link
Contributor Author

mmilata commented Oct 31, 2016

The test got stuck on

[k8s.io] EmptyDir volumes
/data/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/test/e2e/framework/framework.go:793
  should support (root,0644,default) [Conformance]
  /data/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/test/e2e/common/empty_dir.go:97

Should be reported as a flake?

[test] again?

@smarterclayton
Copy link
Contributor

report the test run as a flake in an issue (might be a new docker failure
mode)

[test]

On Mon, Oct 31, 2016 at 1:29 PM, OpenShift Bot [email protected]
wrote:

The Origin test job could not be run again for this pull request.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#11539 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p7K0PydX0ObkOSHDQDT95gCGOcpGks5q5iVygaJpZM4KfPRX
.

@mmilata
Copy link
Contributor Author

mmilata commented Oct 31, 2016

Filed #11671

@mmilata
Copy link
Contributor Author

mmilata commented Oct 31, 2016

Flake #11406

@mmilata
Copy link
Contributor Author

mmilata commented Oct 31, 2016

[test]

@mmilata
Copy link
Contributor Author

mmilata commented Nov 1, 2016

Flake #10988 or #10773 or both. [test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to d3df274

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10904/) (Base Commit: 76dc98f)

@mmilata
Copy link
Contributor Author

mmilata commented Nov 1, 2016

@bparees, modified the tests as you suggested, PTAL

@bparees
Copy link
Contributor

bparees commented Nov 1, 2016

lgtm [merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to d3df274

@openshift-bot
Copy link
Contributor

openshift-bot commented Nov 1, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10904/) (Base Commit: 16306a6) (Image: devenv-rhel7_5291)

@openshift-bot openshift-bot merged commit d7c6243 into openshift:master Nov 1, 2016
@mmilata
Copy link
Contributor Author

mmilata commented Nov 3, 2016

@smarterclayton you requested a public notification for this change in #10952 (comment)

Where do I add a release note? I'm planning to send an email to users@ list as well.

@smarterclayton
Copy link
Contributor

In openshift-docs (there should be a 3.4 release note list)

On Thu, Nov 3, 2016 at 11:10 AM, Martin Milata [email protected]
wrote:

@smarterclayton https://github.com/smarterclayton you requested a
public notification for this change in #10952 (comment)
#10952 (comment)

Where do I add a release note? I'm planning to send an email to users@
list as well.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#11539 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p8u1mWMz_GHDWPM5_nVhZf7eWFyHks5q6flUgaJpZM4KfPRX
.

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.

6 participants