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

New CIDR functions not working as expected #1857

Open
maulik13 opened this issue Feb 12, 2025 · 2 comments
Open

New CIDR functions not working as expected #1857

maulik13 opened this issue Feb 12, 2025 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@maulik13
Copy link

maulik13 commented Feb 12, 2025

Bug Report

1. Minimal reproduce step (Required)

I downloaded the latest release v0.11.1 and I copied the kcl file from test and I two CIDR functions, hosts_in_CIDR and subnets_from_CIDR, are not working.

I ran kcl run main.k on the following configuration,

import net

cidr0 = net.parse_CIDR("192.168.1.0/24")
cidr1 = net.hosts_in_CIDR("192.168.1.0/24")
cidr2 = net.subnets_from_CIDR("192.168.1.0/24")
cidr3 = net.is_IP_in_CIDR("192.168.1.1", "192.168.1.0/24")
cidr4 = net.is_IP_in_CIDR("192.168.0.1", "192.168.1.0/24")

And here is my output.

cidr0:
  ip: '192.168.1.0'
  mask: 24
cidr1: []
cidr2: []
cidr3: true
cidr4: false                                                                                                                                                                                                                                                                             

2. What did you expect to see? (Required)

I should see cidr1 and cidr2 not to be empty. I am not sure what will be the exact values since that is what I was trying to figure out.

3. What did you see instead (Required)

Empty values for cidr1 and cidr2

4. What is your KCL components version? (Required)

Downloaded the binary from GitHub release v0.11.1

Version: 0.11.1-c020ab3eb4b9179219d6837a57f5d323
Platform: aarch64-apple-darwin
GitCommit: d8964b29170ba28c98a31b561a2d9525112d1f30
@Peefy Peefy added bug Something isn't working good first issue Good for newcomers labels Mar 1, 2025
@Rohanraj123
Copy link

I am picking this issue!

@maulik13
Copy link
Author

maulik13 commented Mar 4, 2025

We are looking for functionality that is already found in Terraform network functions.

Example, cidrsubnet

> cidrsubnet("172.16.0.0/12", 4, 2)
172.18.0.0/16

Another useful function would be to generate multiple subnets.

Example, cidrsubnets

> cidrsubnets("10.1.0.0/16", 4, 4, 8, 4)
[
  "10.1.0.0/20",
  "10.1.16.0/20",
  "10.1.32.0/24",
  "10.1.48.0/20",
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants