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

generate: fix annotations parse #296

Merged
merged 1 commit into from
Jan 17, 2017

Conversation

Mashimiao
Copy link

It's valid for values to start with '=' .

Signed-off-by: Ma Shimiao mashimiao.fnst@cn.fujitsu.com

pair := strings.Split(s, "=")
if len(pair) != 2 {
pair := strings.SplitN(s, "=", 2)
if len(pair) != 2 || pair[0] == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing from SplitSplitN makes sense (allowing = to occur in the value). But I'm not clear on this empty-string comparison here. My understanding is that the spec allows empty-string keys for annotations, and that matches your f2c88e2 commit message. But this line will lead to “incorrectly specified…” errors when the argument starts with an equals sign. The SplitSplitN change may be all we need.

@Mashimiao
Copy link
Author

Mashimiao commented Dec 28, 2016 via email

@wking
Copy link
Contributor

wking commented Dec 28, 2016 via email

@Mashimiao
Copy link
Author

I try to use ':=' as separator. I think it's specially designed, then keys/values can contain '=' or backslash escapes or some others.

@wking
Copy link
Contributor

wking commented Jan 3, 2017 via email

@Mashimiao
Copy link
Author

I'm not sure how you test foo\=bar=baz. But I don't think it can work, because \= also contains an equals sign.
If you really think all kinds of specific defined strings could be part of key and restrict the possible key strings, I don't have a good solution to solve this.
In this PR, I will just make values contain equals sign supported, and clearly tell users keys contain equals sign are not supported.
@wking If you have any other good solutions to fix it, you can submit a separate PR. I look forward to it

@wking
Copy link
Contributor

wking commented Jan 4, 2017 via email

@Mashimiao
Copy link
Author

According to runtime-spec/#645, updated PR to add empty-string key comparison.

@wking
Copy link
Contributor

wking commented Jan 13, 2017

With the spec change, 75be481 looks good to me.

@@ -96,6 +96,7 @@ read the configuration from `config.json`.

**--label**=[]
Add annotations to the configuration e.g. key=value.
Currently, key contains equals sign is not supported.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: contains -> containing

Copy link
Author

Choose a reason for hiding this comment

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

fixed, thanks

It's valid for values to contain '='.

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

@mrunalp @liangchenye @hqhq PTAL

@hqhq
Copy link
Contributor

hqhq commented Jan 17, 2017

LGTM

Approved with PullApprove

1 similar comment
@liangchenye
Copy link
Member

liangchenye commented Jan 17, 2017

LGTM

Approved with PullApprove

@Mashimiao Mashimiao merged commit 1a4a299 into opencontainers:master Jan 17, 2017
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.

5 participants