Fix up detect-local-mode validation
Validate the --detect-local-mode value in the API object validation rather than doing it separately later. Also, remove runtime checks and unit tests for cases that would be blocked by validation
This commit is contained in:
@@ -95,6 +95,8 @@ func Validate(config *kubeproxyconfig.KubeProxyConfiguration) field.ErrorList {
|
||||
|
||||
allErrs = append(allErrs, validateKubeProxyNodePortAddress(config.NodePortAddresses, newPath.Child("NodePortAddresses"))...)
|
||||
allErrs = append(allErrs, validateShowHiddenMetricsVersion(config.ShowHiddenMetricsForVersion, newPath.Child("ShowHiddenMetricsForVersion"))...)
|
||||
|
||||
allErrs = append(allErrs, validateDetectLocalMode(config.DetectLocalMode, newPath.Child("DetectLocalMode"))...)
|
||||
if config.DetectLocalMode == kubeproxyconfig.LocalModeBridgeInterface {
|
||||
allErrs = append(allErrs, validateInterface(config.DetectLocal.BridgeInterface, newPath.Child("InterfaceName"))...)
|
||||
}
|
||||
@@ -205,6 +207,22 @@ func validateProxyModeWindows(mode kubeproxyconfig.ProxyMode, fldPath *field.Pat
|
||||
return field.ErrorList{field.Invalid(fldPath.Child("ProxyMode"), string(mode), errMsg)}
|
||||
}
|
||||
|
||||
func validateDetectLocalMode(mode kubeproxyconfig.LocalMode, fldPath *field.Path) field.ErrorList {
|
||||
validModes := []string{
|
||||
string(kubeproxyconfig.LocalModeClusterCIDR),
|
||||
string(kubeproxyconfig.LocalModeNodeCIDR),
|
||||
string(kubeproxyconfig.LocalModeBridgeInterface),
|
||||
string(kubeproxyconfig.LocalModeInterfaceNamePrefix),
|
||||
"",
|
||||
}
|
||||
|
||||
if sets.New(validModes...).Has(string(mode)) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return field.ErrorList{field.NotSupported(fldPath, string(mode), validModes)}
|
||||
}
|
||||
|
||||
func validateClientConnectionConfiguration(config componentbaseconfig.ClientConnectionConfiguration, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(config.Burst), fldPath.Child("Burst"))...)
|
||||
|
Reference in New Issue
Block a user