rings: RingThreePrefix()
Ring 3 corresponds to the pods of the kubernetes cluster of a region Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package rings
|
||||
|
||||
import "net/netip"
|
||||
|
||||
// RingThreePrefix returns the subnet corresponding to
|
||||
// the pods of a cluster.
|
||||
//
|
||||
// Ring 3 is a `10.(region_id << 4).0.0/12` network
|
||||
func RingThreePrefix(region RegionID) (subnet netip.Prefix, err error) {
|
||||
switch {
|
||||
case !region.Valid():
|
||||
err = ErrOutOfRange(region, "region")
|
||||
default:
|
||||
addr := AddrFrom4(10, uint(region)<<4, 0, 0)
|
||||
subnet = netip.PrefixFrom(addr, RingThreeBits)
|
||||
}
|
||||
return subnet, err
|
||||
}
|
||||
Reference in New Issue
Block a user