Changed HTTPGetAction to allow user-defined schemes
This commit is contained in:
@@ -762,6 +762,10 @@ func validateHTTPGetAction(http *api.HTTPGetAction) errs.ValidationErrorList {
|
||||
} else if http.Port.Kind == util.IntstrString && len(http.Port.StrVal) == 0 {
|
||||
allErrors = append(allErrors, errs.NewFieldRequired("port"))
|
||||
}
|
||||
supportedSchemes := util.NewStringSet(string(api.URISchemeHTTP), string(api.URISchemeHTTPS))
|
||||
if !supportedSchemes.Has(string(http.Scheme)) {
|
||||
allErrors = append(allErrors, errs.NewFieldInvalid("scheme", http.Scheme, fmt.Sprintf("must be one of %v", supportedSchemes.List())))
|
||||
}
|
||||
return allErrors
|
||||
}
|
||||
|
||||
|
@@ -712,9 +712,9 @@ func TestValidateProbe(t *testing.T) {
|
||||
func TestValidateHandler(t *testing.T) {
|
||||
successCases := []api.Handler{
|
||||
{Exec: &api.ExecAction{Command: []string{"echo"}}},
|
||||
{HTTPGet: &api.HTTPGetAction{Path: "/", Port: util.NewIntOrStringFromInt(1), Host: ""}},
|
||||
{HTTPGet: &api.HTTPGetAction{Path: "/foo", Port: util.NewIntOrStringFromInt(65535), Host: "host"}},
|
||||
{HTTPGet: &api.HTTPGetAction{Path: "/", Port: util.NewIntOrStringFromString("port"), Host: ""}},
|
||||
{HTTPGet: &api.HTTPGetAction{Path: "/", Port: util.NewIntOrStringFromInt(1), Host: "", Scheme: "HTTP"}},
|
||||
{HTTPGet: &api.HTTPGetAction{Path: "/foo", Port: util.NewIntOrStringFromInt(65535), Host: "host", Scheme: "HTTP"}},
|
||||
{HTTPGet: &api.HTTPGetAction{Path: "/", Port: util.NewIntOrStringFromString("port"), Host: "", Scheme: "HTTP"}},
|
||||
}
|
||||
for _, h := range successCases {
|
||||
if errs := validateHandler(&h); len(errs) != 0 {
|
||||
|
Reference in New Issue
Block a user