-
Notifications
You must be signed in to change notification settings - Fork 150
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
Allow using escaped commas in tag values #1810
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: RomanBednar The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
pkg/common/utils.go
Outdated
for _, r := range s { | ||
switch { | ||
case escaped: | ||
if r == delim { |
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.
Why can't we just do
case escaped:
if r != escape {
buf.WriteRune(r)
escaped = false
}
I think the current code will do the wrong thing on foo,,bar.
also I think both versions of the code do the wrong thing on foo\,bar, usually that would escape the backslash and not escape the comma, but here this is turned into an escaped comma?
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.
@mattcary You're right, it can be simplified as suggested. As for the behavior of escaping, what do you think the correct behavior should be? Or which unit test is wrong specifically?
In case of foo,,bar
input splitWithEscape
will output "foo", "", "bar"
which will later fail validation as it's not a valid format for a tag here:
return nil, fmt.Errorf("tag %q is invalid, correct format: 'parent_id1/key1/value1,parent_id2/key2/value2'", parentIDkeyValueString) |
here this is turned into an escaped comma?
I think you could say that, it's actually the intention of this change to allow users escaping the commas somehow so they can be used in tag value (as documented). Maybe there's a better solution?
afdbb01
to
faf34d8
Compare
faf34d8
to
f92a694
Compare
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Allows using commas in tag values; commas are allowed according to documentation.
Which issue(s) this PR fixes:
Fixes #1809
Special notes for your reviewer:
Tested with unit tests and manually as shown below:
Escaped commas with a backslash (
\
):CSI Driver created volume successfully:
Tag has been added correctly to provisioned disk:
Does this PR introduce a user-facing change?: