add ProxyModeIPVS in proxy mode validation

This commit is contained in:
Lion-Wei 2017-10-19 14:34:37 +08:00
parent 65d9b4ef0b
commit ee3fbf9c5a
3 changed files with 4 additions and 1 deletions

View File

@ -120,9 +120,10 @@ func validateProxyMode(mode componentconfig.ProxyMode, fldPath *field.Path) fiel
switch mode {
case componentconfig.ProxyModeUserspace:
case componentconfig.ProxyModeIPTables:
case componentconfig.ProxyModeIPVS:
case "":
default:
modes := []string{string(componentconfig.ProxyModeUserspace), string(componentconfig.ProxyModeIPTables)}
modes := []string{string(componentconfig.ProxyModeUserspace), string(componentconfig.ProxyModeIPTables), string(componentconfig.ProxyModeIPVS)}
errMsg := fmt.Sprintf("must be %s or blank (blank means the best-available proxy (currently iptables)", strings.Join(modes, ","))
allErrs = append(allErrs, field.Invalid(fldPath.Child("ProxyMode"), string(mode), errMsg))
}

View File

@ -374,6 +374,7 @@ func TestValidateProxyMode(t *testing.T) {
successCases := []componentconfig.ProxyMode{
componentconfig.ProxyModeUserspace,
componentconfig.ProxyModeIPTables,
componentconfig.ProxyModeIPVS,
componentconfig.ProxyMode(""),
}

View File

@ -158,6 +158,7 @@ type ProxyMode string
const (
ProxyModeUserspace ProxyMode = "userspace"
ProxyModeIPTables ProxyMode = "iptables"
ProxyModeIPVS ProxyMode = "ipvs"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object