Skip to content

Commit

Permalink
Add support for content-based load balancing to google_compute_health…
Browse files Browse the repository at this point in the history
…_check (hashicorp#164)

<!-- This change is generated by MagicModules. -->
/cc @rileykarson
  • Loading branch information
modular-magician authored and rileykarson committed Nov 30, 2018
1 parent edd9667 commit aad258e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
42 changes: 42 additions & 0 deletions google-beta/resource_compute_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func resourceComputeHealthCheck() *schema.Resource {
Optional: true,
Default: "/",
},
"response": {
Type: schema.TypeString,
Optional: true,
},
},
},
ConflictsWith: []string{"https_health_check", "tcp_health_check", "ssl_health_check"},
Expand Down Expand Up @@ -119,6 +123,10 @@ func resourceComputeHealthCheck() *schema.Resource {
Optional: true,
Default: "/",
},
"response": {
Type: schema.TypeString,
Optional: true,
},
},
},
ConflictsWith: []string{"http_health_check", "tcp_health_check", "ssl_health_check"},
Expand Down Expand Up @@ -610,6 +618,8 @@ func flattenComputeHealthCheckHttpHealthCheck(v interface{}, d *schema.ResourceD
flattenComputeHealthCheckHttpHealthCheckHost(original["host"], d)
transformed["request_path"] =
flattenComputeHealthCheckHttpHealthCheckRequestPath(original["requestPath"], d)
transformed["response"] =
flattenComputeHealthCheckHttpHealthCheckResponse(original["response"], d)
transformed["port"] =
flattenComputeHealthCheckHttpHealthCheckPort(original["port"], d)
transformed["proxy_header"] =
Expand All @@ -624,6 +634,10 @@ func flattenComputeHealthCheckHttpHealthCheckRequestPath(v interface{}, d *schem
return v
}

func flattenComputeHealthCheckHttpHealthCheckResponse(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenComputeHealthCheckHttpHealthCheckPort(v interface{}, d *schema.ResourceData) interface{} {
// Handles the string fixed64 format
if strVal, ok := v.(string); ok {
Expand Down Expand Up @@ -651,6 +665,8 @@ func flattenComputeHealthCheckHttpsHealthCheck(v interface{}, d *schema.Resource
flattenComputeHealthCheckHttpsHealthCheckHost(original["host"], d)
transformed["request_path"] =
flattenComputeHealthCheckHttpsHealthCheckRequestPath(original["requestPath"], d)
transformed["response"] =
flattenComputeHealthCheckHttpsHealthCheckResponse(original["response"], d)
transformed["port"] =
flattenComputeHealthCheckHttpsHealthCheckPort(original["port"], d)
transformed["proxy_header"] =
Expand All @@ -665,6 +681,10 @@ func flattenComputeHealthCheckHttpsHealthCheckRequestPath(v interface{}, d *sche
return v
}

func flattenComputeHealthCheckHttpsHealthCheckResponse(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenComputeHealthCheckHttpsHealthCheckPort(v interface{}, d *schema.ResourceData) interface{} {
// Handles the string fixed64 format
if strVal, ok := v.(string); ok {
Expand Down Expand Up @@ -808,6 +828,13 @@ func expandComputeHealthCheckHttpHealthCheck(v interface{}, d *schema.ResourceDa
transformed["requestPath"] = transformedRequestPath
}

transformedResponse, err := expandComputeHealthCheckHttpHealthCheckResponse(original["response"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !isEmptyValue(val) {
transformed["response"] = transformedResponse
}

transformedPort, err := expandComputeHealthCheckHttpHealthCheckPort(original["port"], d, config)
if err != nil {
return nil, err
Expand All @@ -833,6 +860,10 @@ func expandComputeHealthCheckHttpHealthCheckRequestPath(v interface{}, d *schema
return v, nil
}

func expandComputeHealthCheckHttpHealthCheckResponse(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandComputeHealthCheckHttpHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down Expand Up @@ -864,6 +895,13 @@ func expandComputeHealthCheckHttpsHealthCheck(v interface{}, d *schema.ResourceD
transformed["requestPath"] = transformedRequestPath
}

transformedResponse, err := expandComputeHealthCheckHttpsHealthCheckResponse(original["response"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedResponse); val.IsValid() && !isEmptyValue(val) {
transformed["response"] = transformedResponse
}

transformedPort, err := expandComputeHealthCheckHttpsHealthCheckPort(original["port"], d, config)
if err != nil {
return nil, err
Expand All @@ -889,6 +927,10 @@ func expandComputeHealthCheckHttpsHealthCheckRequestPath(v interface{}, d *schem
return v, nil
}

func expandComputeHealthCheckHttpsHealthCheckResponse(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandComputeHealthCheckHttpsHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
12 changes: 12 additions & 0 deletions website/docs/r/compute_health_check.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ The `http_health_check` block supports:
The request path of the HTTP health check request.
The default value is /.

* `response` -
(Optional)
The bytes to match against the beginning of the response data. If left empty
(the default value), any response will indicate health. The response data
can only be ASCII.

* `port` -
(Optional)
The TCP port number for the HTTP health check request.
Expand All @@ -161,6 +167,12 @@ The `https_health_check` block supports:
The request path of the HTTPS health check request.
The default value is /.

* `response` -
(Optional)
The bytes to match against the beginning of the response data. If left empty
(the default value), any response will indicate health. The response data
can only be ASCII.

* `port` -
(Optional)
The TCP port number for the HTTPS health check request.
Expand Down

0 comments on commit aad258e

Please sign in to comment.