upbound / function-cidr

Composition Function that transforms CIDRs
Apache License 2.0
6 stars 4 forks source link

Add functionality to parse multiple prefixes #35

Closed mproffitt closed 1 month ago

mproffitt commented 3 months ago

This change introduces a new function multiprefixloop as a convenience function for splitting multiple cidr prefixes govorned by the number of bits and required offset inside each prefix.

This function might be used in instances such as dividing additional VPC cidrs into subnets without requiring multiple instances of the funtion to be declared in a given composition.

Additionally this PR:

Description of your changes

Fixes #

I have:

How has this code been tested

By introducing tests that contribute towards ensuring stability of the function

go test -timeout 30s -run ^TestRunFunction$ github.com/upbound/function-cidr -v -count=1 -timeout=30s -parallel=4 -cover
=== RUN   TestRunFunction
=== RUN   TestRunFunction/cidr-host
=== RUN   TestRunFunction/cidr-subnet
=== RUN   TestRunFunction/cidr-netmask
=== RUN   TestRunFunction/cidr-subnets
=== RUN   TestRunFunction/cidr-subnetloop
=== RUN   TestRunFunction/multi-prefix-loop
--- PASS: TestRunFunction (0.00s)
    --- PASS: TestRunFunction/cidr-host (0.00s)
    --- PASS: TestRunFunction/cidr-subnet (0.00s)
    --- PASS: TestRunFunction/cidr-netmask (0.00s)
    --- PASS: TestRunFunction/cidr-subnets (0.00s)
    --- PASS: TestRunFunction/cidr-subnetloop (0.00s)
    --- PASS: TestRunFunction/multi-prefix-loop (0.00s)
PASS
coverage: 52.4% of statements
ok      github.com/upbound/function-cidr        0.015s  coverage: 52.4% of statements

Additionally by validating that there is no change to execution through crossplane beta render using make debug and make render commands