Extract integration type validator

This commit is contained in:
Michael Henry 2016-10-04 12:51:18 -04:00
parent 71b62d83b2
commit ad8bff98bb
2 changed files with 12 additions and 10 deletions

View File

@ -43,14 +43,7 @@ func resourceAwsApiGatewayIntegration() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Required: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if value != "MOCK" && value != "AWS" && value != "HTTP" && value != "AWS_PROXY" && value != "HTTP_PROXY" {
errors = append(errors, fmt.Errorf(
"%q must be one of 'AWS', 'MOCK', 'HTTP', 'AWS_PROXY', 'HTTP_PROXY'", k))
}
return
},
ValidateFunc: validateApiGatewayIntegrationType,
},
"uri": &schema.Schema{

View File

@ -467,3 +467,12 @@ func validateJsonString(v interface{}, k string) (ws []string, errors []error) {
}
return
}
func validateApiGatewayIntegrationType(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if value != "MOCK" && value != "AWS" && value != "HTTP" && value != "AWS_PROXY" && value != "HTTP_PROXY" {
errors = append(errors, fmt.Errorf(
"%q must be one of 'AWS', 'MOCK', 'HTTP', 'AWS_PROXY', 'HTTP_PROXY'", k))
}
return
}