-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Add Terraform CIDR based functions #1342
Conversation
Thanks for taking the time to submit this, @bartoszj! For the future, it's a good idea to file an issue before spending time sending a PR (see I'm curious about why the current |
Hello. Sorry for that missing issue ticket :( Regarding If you want I can remove |
Thanks for the extra detail. Can you explain in concrete terms what you're planning on using the A bit of a tangent: It's a bit unfortunate that neither Also - I looked a bit more at the difference between |
Hello. Regarding
The first and second subnet is later divided into 4 or 8 smaller subnets.
Sometimes there is also a need to get the 10th host IP from a given subnet like:
I don't have yet usage for I'll try to find a method to convert |
I've removed |
net
package IP parsing and Terraform CIDR based functions
Thanks @bartoszj, and sorry for the delay... I'm going to merge this, though I think the names should be I'll take care of changing these though - I might do this in this PR, or I might merge it first and then make the change in a followup... |
…functions which are working similar to Terraform IP network functions
…ype parsing. Convert return types to use `inet.af/netaddr` types.
I've reworked this a bit to move to using |
Signed-off-by: Dave Henderson <[email protected]>
I've added a few more functions to the
net
namespace:net.CidrHost
to calculate host IP address from CIDR and host number, based on Terraformcidrhost
functionnet.CidrNetmask
to return CIDR netmask in dotted-decimal IPv4 address syntax, based on Terraformcidrnetmask
functionnet.CidrSubnets
to return a list of subnets from give CIDR and new netmask bits, based on Terraformcidrsubnet
functionnet.CidrSubnetSizes
to calculate a sequence of consecutive IP address ranges within a particular CIDR prefix, based on Terraformcidrsubnets
function