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

cmd/operator-sdk/build: fix handling of spaces within quotes #2312

Merged

Conversation

dustinspecker
Copy link
Contributor

Before when running operator-sdk build with an --image-build-arg of
something like --label some.name="First Last" then operator-sdk
would invoke the builder with ["--label", "some.name=First", "Last"],
when it was actually desired to be ["--label", "some.name=First Last"].

Using shlex handles all the appropriate parsing of spaces within quotes
unlike strings.Fields which just splits on any spaces regardless of
context like quotes.

Switching to shlex enables operator-sdk build to now properly handle
spaces within quotes.

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 10, 2019
splitArgs, err := shlex.Split(bargs)
if err != nil {
return nil, fmt.Errorf("image-build-args is not parseable (%v)", err)
}
args = append(args, splitArgs...)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have not a test for this option.
WDYT about add it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that idea a lot. Was wondering where a good place for a test would be.

@openshift-ci-robot openshift-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 11, 2019
@dustinspecker dustinspecker reopened this Dec 11, 2019
@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 11, 2019
@dustinspecker dustinspecker force-pushed the fix-image-build-args branch 3 times, most recently from f5b3c0e to f56f217 Compare December 11, 2019 12:48
Before when running `operator-sdk build` with an `--image-build-arg` of
something like `--label some.name="First Last"` then `operator-sdk`
would invoke the builder with ["--label", "some.name=First", "Last"],
when it was actually desired to be ["--label", "some.name=First Last"].

Using `shlex` handles all the appropriate parsing of spaces within quotes
unlike `strings.Fields` which just splits on any spaces regardless of
context like quotes.

Switching to `shlex` enables `operator-sdk build` to now properly handle
spaces within quotes.
Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@dustinspecker thanks for submitting this PR!

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 11, 2019
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

The code shows fine.
Since it has a test + changelog + it is ok for @estroz

/lgtm
/approved as well 🥇

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@estroz estroz merged commit b50f059 into operator-framework:master Dec 12, 2019
@dustinspecker dustinspecker deleted the fix-image-build-args branch December 12, 2019 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants