Skip to content

Commit 1b17c5f

Browse files
committed
Add comments about ratcheting for IPs
1 parent 1fa3624 commit 1b17c5f

File tree

2 files changed

+6
-0
lines changed
  • pkg/apis/core/validation
  • staging/src/k8s.io/apimachinery/pkg/util/validation

2 files changed

+6
-0
lines changed

pkg/apis/core/validation/validation.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9201,6 +9201,9 @@ func isRestartableInitContainer(initContainer *core.Container) bool {
92019201
// handles setting strictValidation correctly. This is only for fields that use legacy IP
92029202
// address validation; use validation.IsValidIP for new fields.
92039203
func IsValidIPForLegacyField(fldPath *field.Path, value string, validOldIPs []string) field.ErrorList {
9204+
// TODO: once the StrictIPCIDRValidation gate is locked to on, this
9205+
// function can go away and callers can do their own ratchet check, then
9206+
// call validate.IP().
92049207
return validation.IsValidIPForLegacyField(fldPath, value, utilfeature.DefaultFeatureGate.Enabled(features.StrictIPCIDRValidation), validOldIPs)
92059208
}
92069209

staging/src/k8s.io/apimachinery/pkg/util/validation/ip.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ func parseIP(fldPath *field.Path, value string, strictValidation bool) (net.IP,
8282
// historically validated in this way, and strictValidation should be true unless the
8383
// StrictIPCIDRValidation feature gate is disabled. Use IsValidIP for parsing new fields.
8484
func IsValidIPForLegacyField(fldPath *field.Path, value string, strictValidation bool, validOldIPs []string) field.ErrorList {
85+
// TODO: once the StrictIPCIDRValidation gate is locked to on, this can
86+
// simply check the old value (or make callers do it) and call
87+
// validate.IP().
8588
if slices.Contains(validOldIPs, value) {
8689
return nil
8790
}

0 commit comments

Comments
 (0)