Skip to content

Commit e930db5

Browse files
committed
lint fix
1 parent 272143a commit e930db5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cloud/nodeipam/ipam/cloud_allocator.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ type cloudAllocator struct {
7272
disableIPv6NodeCIDRAllocation bool
7373
}
7474

75-
const providerIDPrefix = "linode://"
75+
const (
76+
providerIDPrefix = "linode://"
77+
ipv6BitLen = 128
78+
ipv6PrefixLen64 = 64
79+
)
7680

7781
var _ CIDRAllocator = &cloudAllocator{}
7882

@@ -350,9 +354,9 @@ func getIPv6RangeFromLinodeInterface(iface linodego.LinodeInterface) string {
350354
// computeStableIPv6PodCIDR attempts to compute a stable IPv6 /112 PodCIDR
351355
// within the provided base IPv6 range using the mnemonic subprefix :0:c::/112.
352356
//
353-
// This prefix is degiefined here:
354357
// The mnemonic subprefix :0:c::/112 is constructed by setting hextets 5..7 to 0, c, 0
355358
// (i.e., bytes 8-13 set to 00 00 00 0c 00 00) within the /64 base, as implemented below.
359+
//
356360
// Rules:
357361
// - For a /64 base, return {base64}:0:c::/112
358362
// - Only applies when desiredMask is /112 and the result is fully contained
@@ -363,7 +367,7 @@ func computeStableIPv6PodCIDR(base *net.IPNet, desiredMask int) (*net.IPNet, boo
363367
}
364368

365369
ones, bits := base.Mask.Size()
366-
if bits != 128 {
370+
if bits != ipv6BitLen {
367371
return nil, false
368372
}
369373

@@ -373,7 +377,7 @@ func computeStableIPv6PodCIDR(base *net.IPNet, desiredMask int) (*net.IPNet, boo
373377
}
374378

375379
// Safety: only handle /64 base ranges
376-
if ones != 64 {
380+
if ones != ipv6PrefixLen64 {
377381
return nil, false
378382
}
379383

@@ -389,7 +393,7 @@ func computeStableIPv6PodCIDR(base *net.IPNet, desiredMask int) (*net.IPNet, boo
389393
out[12], out[13] = 0x00, 0x00 // :0
390394
// last hextet (bytes 14..15) will be zeroed by mask below
391395

392-
mask := net.CIDRMask(desiredMask, 128)
396+
mask := net.CIDRMask(desiredMask, ipv6BitLen)
393397
// Ensure the address is the network address for the desired mask
394398
out = out.Mask(mask)
395399
pod := &net.IPNet{IP: out, Mask: mask}

0 commit comments

Comments
 (0)