Skip to content

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

Merged
openshift-bot merged 2 commits into
openshift:masterfrom
mmilata:disallow-multiple-template-params
Nov 1, 2016
Merged

openshift-bot merged 2 commits into
openshift:masterfrom
mmilata:disallow-multiple-template-params

Conversation

@mmilata

@mmilata mmilata commented Oct 24, 2016 •

Copy link
Copy Markdown
Contributor

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

liggitt commented Oct 24, 2016

Copy link
Copy Markdown
Contributor

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

liggitt commented Oct 24, 2016

Copy link
Copy Markdown
Contributor

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

@liggitt

liggitt commented Oct 24, 2016

Copy link
Copy Markdown
Contributor

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

@mmilata

mmilata commented Oct 25, 2016

Copy link
Copy Markdown
Contributor Author

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

@mmilata

mmilata commented Oct 25, 2016

Copy link
Copy Markdown
Contributor Author

@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

mmilata commented Oct 25, 2016 •

Copy link
Copy Markdown
Contributor Author

Does [test] run the cmd tests?

It does. [test] again

@liggitt

liggitt commented Oct 25, 2016

Copy link
Copy Markdown
Contributor

Please open an upstream PR bumping to the same version then

@bparees bparees left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread pkg/cmd/cli/cmd/newapp.go Outdated
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
Copy Markdown
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"

Comment thread pkg/cmd/cli/cmd/process.go Outdated
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
Copy Markdown
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"

Comment thread pkg/cmd/cli/cmd/newapp.go Outdated
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
Copy Markdown
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

mmilata commented Oct 27, 2016

Copy link
Copy Markdown
Contributor Author

@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.

Comment thread pkg/bootstrap/docker/up.go Outdated
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
Copy Markdown
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"

Comment thread pkg/cmd/cli/cmd/newapp.go Outdated
cmd.Flags().StringArrayVarP(&config.TemplateParameters, "param", "p", config.TemplateParameters, "Specify a key-value pair (e.g., -p FOO=BAR) to set/override a 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.")
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
Copy Markdown
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

Comment thread pkg/cmd/cli/cmd/newbuild.go Outdated
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
Copy Markdown
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

Comment thread pkg/cmd/cli/cmd/set/env.go Outdated
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
Copy Markdown
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

Comment thread pkg/cmd/cli/cmd/startbuild.go Outdated
}
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread pkg/cmd/util/cmd.go Outdated
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
Copy Markdown
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
Copy Markdown
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

bparees commented Oct 27, 2016

Copy link
Copy Markdown
Contributor

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

@mmilata

mmilata commented Oct 27, 2016

Copy link
Copy Markdown
Contributor Author

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

@bparees bparees left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread test/cmd/newapp.sh Outdated
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
Copy Markdown
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.

Comment thread test/cmd/newapp.sh
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
Copy Markdown
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.

Comment thread test/cmd/process.sh
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
Copy Markdown
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.

Comment thread test/cmd/templates.sh
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
Copy Markdown
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

mmilata commented Oct 28, 2016

Copy link
Copy Markdown
Contributor Author

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

danmcp commented Oct 28, 2016

Copy link
Copy Markdown

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

mmilata commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

[test]

@mmilata

mmilata commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

mmilata commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

Filed #11671

@mmilata

mmilata commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

Flake #11406

@mmilata

mmilata commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

[test]

@mmilata

mmilata commented Nov 1, 2016

Copy link
Copy Markdown
Contributor Author

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

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to d3df274

@openshift-bot

Copy link
Copy Markdown
Contributor

@mmilata

mmilata commented Nov 1, 2016

Copy link
Copy Markdown
Contributor Author

@bparees, modified the tests as you suggested, PTAL

@bparees

bparees commented Nov 1, 2016

Copy link
Copy Markdown
Contributor

lgtm [merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to d3df274

@openshift-bot

openshift-bot commented Nov 1, 2016 •

Copy link
Copy Markdown
Contributor

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

mmilata commented Nov 3, 2016

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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
.

mhan8796 pushed a commit to mhan8796/kubernetes that referenced this pull request Jun 26, 2026
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
```
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