Skip to content

Commit ad8bff9

Browse files
author
Michael Henry
committed
Extract integration type validator
1 parent 71b62d8 commit ad8bff9

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

builtin/providers/aws/resource_aws_api_gateway_integration.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,9 @@ func resourceAwsApiGatewayIntegration() *schema.Resource {
4141
},
4242

4343
"type": &schema.Schema{
44-
Type: schema.TypeString,
45-
Required: true,
46-
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
47-
value := v.(string)
48-
if value != "MOCK" && value != "AWS" && value != "HTTP" && value != "AWS_PROXY" && value != "HTTP_PROXY" {
49-
errors = append(errors, fmt.Errorf(
50-
"%q must be one of 'AWS', 'MOCK', 'HTTP', 'AWS_PROXY', 'HTTP_PROXY'", k))
51-
}
52-
return
53-
},
44+
Type: schema.TypeString,
45+
Required: true,
46+
ValidateFunc: validateApiGatewayIntegrationType,
5447
},
5548

5649
"uri": &schema.Schema{

builtin/providers/aws/validators.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,12 @@ func validateJsonString(v interface{}, k string) (ws []string, errors []error) {
467467
}
468468
return
469469
}
470+
471+
func validateApiGatewayIntegrationType(v interface{}, k string) (ws []string, errors []error) {
472+
value := v.(string)
473+
if value != "MOCK" && value != "AWS" && value != "HTTP" && value != "AWS_PROXY" && value != "HTTP_PROXY" {
474+
errors = append(errors, fmt.Errorf(
475+
"%q must be one of 'AWS', 'MOCK', 'HTTP', 'AWS_PROXY', 'HTTP_PROXY'", k))
476+
}
477+
return
478+
}

0 commit comments

Comments
 (0)