Use spf13/cobra for docker commit#23309
Conversation
There was a problem hiding this comment.
double quotes is really weird. is it like things escaped in cobra or what?
There was a problem hiding this comment.
Thanks @LK4D4 for the review. It looks like cobra requires quotes from outside (as there is a space in CMD and []. But then to escape the quotes inside the quotes, a double quotes will be needed.
Therefore the whole argument has to be (single quotes outside and double quotes inside):
"CMD [""/bin/sh""]"
Otherwise it will return error:
invalid argument "CMD [\"/bin/sh\"]" for --change: line 1, column 5: bare " in non-quoted-field
There was a problem hiding this comment.
ping @dnephin
In a shell (zsh), with docker 1.11 : λ docker commit --change 'CMD ["/bin/sh"]' 830 works fine, with current master docker commit --change 'CMD ["/bin/sh"]' ef9 returns "invalid argument "CMD ["/bin/sh"]" for --change: line 1, column 5: bare " in non-quoted-field".
There was a problem hiding this comment.
Maybe related to https://github.com/dnephin/cobra/blob/fork/command.go#L358-L396 ?
I think the error is coming from https://golang.org/pkg/encoding/csv/, which I think is called from opts.ListOpts. I think pflags must have been doing something funky to make this work? Maybe the "add single quotes" patch that we didn't add.
What if you use a StringSliceVar() here instead of ListOps ?
There was a problem hiding this comment.
@dnephin At the moment --change use StringSliceVarP. I searched the web and most of the same error message bare " in non-quoted-field" points to golang's csv package. I don't know enough detail about the implementation in cobra though.
There was a problem hiding this comment.
Oh, sorry I got that backwards. It used to be a ListOpts, so I think that
is the difference. Does it work if you go back to using the list opts, or
is it broken with both types ?
On Jun 8, 2016 11:38 AM, "Yong Tang" [email protected] wrote:
In integration-cli/docker_cli_commit_test.go
#23309 (comment):@@ -116,9 +116,9 @@ func (s *DockerSuite) TestCommitChange(c *check.C) {
"--change", "ENV test 1",
"--change", "ENV PATH /foo",
"--change", "LABEL foo bar",
"--change", "CMD [\"/bin/sh\"]","--change", `"CMD [""/bin/sh""]"`,@dnephin https://github.com/dnephin At the moment --change use
StringSliceVarP. I searched the web and most of the same error message bare
" in non-quoted-field" points to golang's csv package. I don't know
enough detail about the implementation in cobra though.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docker/docker/pull/23309/files/89edc4e36c371d04c5d65ff1d330f13d5d4fdc52#r66279789,
or mute the thread
https://github.com/notifications/unsubscribe/AAa_REm_dIKPUKsYjV_aM_a-4Cnk7IvEks5qJuHogaJpZM4Iu_PI
.
There was a problem hiding this comment.
Ya, StringSliceVar is the one that uses csv, and ListOpts does not. So changing the type back to the old type should fix this issue and you'll be able to revert this change to the test.
There was a problem hiding this comment.
@dnephin I tried with ListOpts and it woks as expected. Thanks for the help!
89edc4e to
7bff3ae
Compare
There was a problem hiding this comment.
RequiresRangeArgs(1, 2) ?
I guess this is already in master
b6a77cc to
4170414
Compare
|
needs a rebase as well now |
4170414 to
e8ba0a1
Compare
|
Thanks @thaJeztah the PR has been rebased. |
This fix is part of the effort to convert commands to spf13/cobra moby#23211. Thif fix coverted command `docker commit` to use spf13/cobra NOTE: `RequiresMinMaxArgs()` has been renamed to `RequiresRangeArgs()`. Signed-off-by: Yong Tang <[email protected]>
e8ba0a1 to
939a142
Compare
|
Thanks @dnephin for the help. The pull request has been updated. Please let me know if there are any issues. |
|
LGTM |
|
LGTM |
Use spf13/cobra for docker commit
This fix is part of the effort to convert commands to spf13/cobra #23211.
Thif fix coverted command
docker committo use spf13/cobraSigned-off-by: Yong Tang [email protected]