Skip to content

Commit fea39ac

Browse files
committed
Add comments about ratcheting for IPs
1 parent 170e3e6 commit fea39ac

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
@@ -9187,6 +9187,9 @@ func isRestartableInitContainer(initContainer *core.Container) bool {
91879187
// handles setting strictValidation correctly. This is only for fields that use legacy IP
91889188
// address validation; use validation.IsValidIP for new fields.
91899189
func IsValidIPForLegacyField(fldPath *field.Path, value string, validOldIPs []string) field.ErrorList {
9190+
// TODO: once the StrictIPCIDRValidation gate is locked to on, this
9191+
// function can go away and callers can do their own ratchet check, then
9192+
// call validate.IP().
91909193
return validation.IsValidIPForLegacyField(fldPath, value, utilfeature.DefaultFeatureGate.Enabled(features.StrictIPCIDRValidation), validOldIPs)
91919194
}
91929195

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)