-
Notifications
You must be signed in to change notification settings - Fork 802
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
Replace strings.SplitN with strings.Cut #5239
Conversation
@@ -845,23 +838,18 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image | |||
fields := strings.Split(mountFlags, ",") | |||
for _, field := range fields { | |||
if strings.HasPrefix(field, "from=") { | |||
fromField := strings.SplitN(field, "=", 2) | |||
if len(fromField) > 1 { |
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 removed this condition for 2 reasons:
- it can never happen, since we know
=
appears infield
- the error message in the dead else path had an out of bounds access with
formField[1]
@@ -124,23 +124,20 @@ func GetBindMount(ctx *types.SystemContext, args []string, contextDir string, st | |||
return newMount, "", fmt.Errorf("cannot pass 'relabel' option more than once: %w", errBadOptionArg) | |||
} | |||
setRelabel = true | |||
if len(kv) != 2 { |
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 removed this check because the exact same error will be raised by the default
case
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.
Thanks! The changes LGTM. In order to pass CI, the commit message needs magic string [NO NEW TESTS NEEDED]
.
The CI enforces tests which in this case aren't needed.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: serprex, vrothberg The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Sure, I'll take a look. I was looking over code while looking into podman's support for |
Introduced in go 1.18: golang/go#46336 [NO NEW TESTS NEEDED] Signed-off-by: Philip Dubé <philip@peerdb.io>
rebased to clean up commit messages since commit subject was too long |
/lgtm |
LGTM |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
strings.Cut
is a cleaner & more performant api relative tostrings.SplitN(_, _, 2)
added in go 1.18How to verify it
No change in behavior
Which issue(s) this PR fixes:
None
Special notes for your reviewer:
Introduced in go 1.18: golang/go#46336
Does this PR introduce a user-facing change?