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

IterateForAssignment: Properly handle invalid syntax for exclude range #365

Merged

Conversation

andreaskaris
Copy link
Contributor

Correctly handle errors from parsing exclude ranges to avoid issues with nil pointer exceptions.
Parse single IP addresses such as 192.168.123.10 or fe02::10 by and convert them to CIDRs by appending the correct
prefix.

Fixes #364

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer (optional):

Correctly handle errors from parsing exclude ranges to avoid issues with
nil pointer exceptions.
Parse single IP addresses such as 192.168.123.10 or fe02::10 and
convert them to CIDRs by appending the correct prefix.

Signed-off-by: Andreas Karis <[email protected]>
if ip.To4() != nil {
_, subnet, err = net.ParseCIDR(fmt.Sprintf("%s/32", s))
} else {
_, subnet, err = net.ParseCIDR(fmt.Sprintf("%s/128", s))
Copy link
Member

Choose a reason for hiding this comment

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

Yep, I'm into this approach of adding the suffix if it's a single IP, nice call

@dougbtv dougbtv merged commit 23e6020 into k8snetworkplumbingwg:master Jul 21, 2023
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.

[BUG] exclude range currently does not correctly handle invalid syntax
2 participants