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

Unable to escape colons in option lists #470

Closed
gfiedler opened this issue Sep 10, 2017 · 18 comments
Closed

Unable to escape colons in option lists #470

gfiedler opened this issue Sep 10, 2017 · 18 comments

Comments

@gfiedler
Copy link

I want to create a hook like this

"hooks": {
  "prestart": [ {
    "path": "cmd",
    "args": [ "cmd", "foo:bar" ]
 } ] }

but I'm unable to do this, because colons have a special semantics and there is no posibility to escape colons in option lists:

oci-runtime-tool generate --hooks-prestart=cmd:foo:bar

results in

"args": [ "cmd", "foo", "bar" ]

The problem is in generate.go in func parseHook.

But maybe options with path arguments like --mount-bind are related to this effect too?

@wking
Copy link
Contributor

wking commented Sep 11, 2017

+1 to extending the option syntax to allow for escaping. And for things the runtime-tools doesn't (yet) support, there's always jq ;).

@Mashimiao
Copy link

I‘m focusing on this problem recently.
Do you think comma works for you, as --hooks-prestart=cmd,foo:bar? @gfiedler @wking
It's really not easy to set separator, almost all characters can be used in path

@wking
Copy link
Contributor

wking commented Oct 18, 2017

jq expects you to provide the value as JSON, which covers the general case. You could also cover the general case with a shell lexer or a custom escape syntax. But I think trading colons for commas just punts until we have someone who needs a literal comma.

@gfiedler
Copy link
Author

I think we should leave the --hooks-prestart as it is and introduce a new option --hooks-prestart-args which works just like --args.

@wking
Copy link
Contributor

wking commented Oct 18, 2017

I'm fine with --hooks-*-args too.

@Mashimiao
Copy link

Well, --hooks-*-args may can works for your case. But what if the name of hooks path contains colon?
I hope we can work out a general way to solve the problem.

@wking
Copy link
Contributor

wking commented Oct 19, 2017 via email

@Mashimiao
Copy link

I think we need generate, because we want to help users write json file. If users know how to wirte config json file. I think generate does not make any sense to him and he will no need it.

@wking
Copy link
Contributor

wking commented Oct 25, 2017

I think we need generate, because we want to help users write json file.

That's fine, but we also need a sytax that allows setting each propery in an array of hooks. If you prefer a non-JSON syntax, that'a no problem, but I think leaving properties out will mean we cycle back around to this when, for example, someone wants to set both args and timeout. JSON is an easy choice for generic updates, but I'm sure there are others too.

@liangchenye
Copy link
Member

liangchenye commented Oct 25, 2017

  • We need a separator to differentiate path, args and timeout.
    It is , in json format.
  • We need a special char to escape the separator if it is used in path, args or timeout.
    It is " in json format.
  • We need a separator to tell an array item.
    It is [] in json format.
  • We need a separator to differentiate args in args.
    It is , in json format.
  • We need a special char to escape the separator if it is used in on of args.
    It is " in json format.

So even we define our syntax, it seems that there will not be much differences comparing to json format.
Maybe we will have something like this:

oci-runtime-tool generate --hooks-prestart '"cmd", ["cmd", "foo:bar"], 5'

But the users need to learn a new syntax, so I think a raw json format here is a rational solution.

@Mashimiao
Copy link

If we decide to use json format, I think there is no base to keep generate.
If user can use and know what the json object should contain, they must can be easy to write config.json file.
From I can see, no matter json, xml or something else, they all select a symbol as a separator.
comma is nearly not used in path name, I think can select it as the separator in options and warn users it should not be used in path name when using runtime-tools.

@wking
Copy link
Contributor

wking commented Nov 24, 2017 via email

@Mashimiao
Copy link

Hmm, we can reform generate to replace current options with json supporting. That would be a huge project....

@wking
Copy link
Contributor

wking commented Nov 25, 2017 via email

@Mashimiao
Copy link

among the three options, I prefer c, but not very satisfied with that. Because it make args format not unified.
We make changes like that first, whether to make huge changes depends on whether we need it or not in the future.

@wking
Copy link
Contributor

wking commented Nov 27, 2017

among the three options...

I'd listed four, but GitHub decided to hide a bunch of my comment behind an ellipsis :p. I've edited the comment to remove a blank line, and now GitHub shows the whole thing. My (d) isn't particularly exciting, but towards the end I have some notes on other arrays of objects which may be interesting.

@Mashimiao
Copy link

anyway, I will try to modify hooks first. If really works well, then consider other options

Mashimiao pushed a commit to Mashimiao/ocitools that referenced this issue Nov 28, 2017
As discussed in opencontainers#470, there is not suitable separators for hooks.
Because of path may contains them.
So, decide to support json value for hooks.

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
Mashimiao pushed a commit to Mashimiao/ocitools that referenced this issue Nov 28, 2017
As discussed in opencontainers#470, there is not suitable separators for hooks.
Because of path may contains them.
So, decide to support json value for hooks.

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
@liangchenye
Copy link
Member

fixed by #525
close

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

No branches or pull requests

4 participants