-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
cmd/operator-sdk/build: fix handling of spaces within quotes #2312
Conversation
6d8048e
to
1b7b18b
Compare
splitArgs, err := shlex.Split(bargs) | ||
if err != nil { | ||
return nil, fmt.Errorf("image-build-args is not parseable (%v)", err) | ||
} | ||
args = append(args, splitArgs...) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
1b7b18b
to
cea92d5
Compare
f5b3c0e
to
f56f217
Compare
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.
f56f217
to
0f477af
Compare
There was a problem hiding this 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!
There was a problem hiding this 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 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Before when running
operator-sdk build
with an--image-build-arg
ofsomething like
--label some.name="First Last"
thenoperator-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 quotesunlike
strings.Fields
which just splits on any spaces regardless ofcontext like quotes.
Switching to
shlex
enablesoperator-sdk build
to now properly handlespaces within quotes.