Skip to content

Commit

Permalink
Merge e03aa07 into 0da0832
Browse files Browse the repository at this point in the history
  • Loading branch information
rileykarson authored Aug 27, 2018
2 parents 0da0832 + e03aa07 commit 2d26717
Show file tree
Hide file tree
Showing 6 changed files with 487 additions and 7 deletions.
27 changes: 23 additions & 4 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1258,10 +1258,25 @@ objects:
name: 'HealthCheck'
kind: 'compute#healthCheck'
base_url: projects/{{project}}/global/healthChecks
description:
An HealthCheck resource. This resource defines a template for how
individual virtual machines should be checked for health, via one of the
supported protocols.
exports:
- !ruby/object:Api::Type::SelfLink
name: 'selfLink'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation': 'https://cloud.google.com/load-balancing/docs/health-checks'
api: 'https://cloud.google.com/compute/docs/reference/rest/latest/healthChecks'
description: |
Health Checks determine whether instances are responsive and able to do work.
They are an important part of a comprehensive load balancing configuration,
as they enable monitoring instances behind load balancers.
Health Checks poll instances at a specified interval. Instances that
do not respond successfully to some number of probes in a row are marked
as unhealthy. No new connections are sent to unhealthy instances,
though existing connections will continue. The health check will
continue to poll unhealthy instances. If an instance later responds
successfully to some number of consecutive probes, it is marked
healthy again and can receive new connections.
<%= indent(compile_file({}, 'templates/global_async.yaml.erb'), 4) %>
properties:
- !ruby/object:Api::Type::Integer
Expand All @@ -1284,6 +1299,7 @@ objects:
description: |
A so-far unhealthy instance will be marked healthy after this many
consecutive successes. The default value is 2.
default_value: 2
- !ruby/object:Api::Type::Integer
name: 'id'
description: |
Expand All @@ -1292,6 +1308,8 @@ objects:
output: true
- !ruby/object:Api::Type::String
name: 'name'
required: true
input: true
description: |
Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
Expand Down Expand Up @@ -1324,6 +1342,7 @@ objects:
- :TCP
- :SSL
- :HTTP
- :HTTPS
- !ruby/object:Api::Type::NestedObject
name: 'httpHealthCheck'
properties:
Expand Down
2 changes: 2 additions & 0 deletions products/compute/healthcheck_protocol_props.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
description: |
The request path of the <%= protocol -%> health check request.
The default value is /.
default_value: "/"
<% elsif ['SSL', 'TCP'].include?(protocol) -%>
- !ruby/object:Api::Type::String
name: 'request'
Expand Down Expand Up @@ -47,3 +48,4 @@
values:
- :NONE
- :PROXY_V1
default_value: :NONE
60 changes: 59 additions & 1 deletion products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,63 @@ overrides: !ruby/object:Provider::ResourceOverrides
unhealthyThreshold: !ruby/object:Provider::Terraform::PropertyOverride
default_value: 2
HealthCheck: !ruby/object:Provider::Terraform::ResourceOverride
exclude: true
examples: |
```hcl
resource "google_compute_health_check" "internal-health-check" {
name = "internal-service-health-check"
timeout_sec = 1
check_interval_sec = 1
tcp_health_check {
port = "80"
}
}
```
custom_code: !ruby/object:Provider::Terraform::CustomCode
encoder: templates/terraform/encoders/health_check_type.erb
properties:
id: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
type: !ruby/object:Provider::Terraform::PropertyOverride
output: true
description: The type of the health check. One of HTTP, HTTPS, TCP, or SSL.
httpHealthCheck: !ruby/object:Provider::Terraform::PropertyOverride
conflicts_with:
- 'https_health_check'
- 'tcp_health_check'
- 'ssl_health_check'
httpHealthCheck.portName: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
httpHealthCheck.port: !ruby/object:Provider::Terraform::PropertyOverride
default_value: 80
httpsHealthCheck: !ruby/object:Provider::Terraform::PropertyOverride
conflicts_with:
- 'http_health_check'
- 'tcp_health_check'
- 'ssl_health_check'
httpsHealthCheck.portName: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
httpsHealthCheck.port: !ruby/object:Provider::Terraform::PropertyOverride
default_value: 443
tcpHealthCheck: !ruby/object:Provider::Terraform::PropertyOverride
conflicts_with:
- 'http_health_check'
- 'https_health_check'
- 'ssl_health_check'
tcpHealthCheck.portName: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
tcpHealthCheck.port: !ruby/object:Provider::Terraform::PropertyOverride
default_value: 80
sslHealthCheck: !ruby/object:Provider::Terraform::PropertyOverride
conflicts_with:
- 'http_health_check'
- 'https_health_check'
- 'tcp_health_check'
sslHealthCheck.portName: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
sslHealthCheck.port: !ruby/object:Provider::Terraform::PropertyOverride
default_value: 443
Image: !ruby/object:Provider::Terraform::ResourceOverride
exclude: true
properties:
Expand Down Expand Up @@ -1231,6 +1287,8 @@ files: !ruby/object:Provider::Config::Files
'templates/terraform/tests/resource_compute_autoscaler_test.go'
'google/resource_compute_global_address_test.go':
'templates/terraform/tests/resource_compute_global_address_test.go'
'google/resource_compute_health_check_test.go':
'templates/terraform/tests/resource_compute_health_check_test.go'
'google/resource_compute_region_autoscaler_test.go':
'templates/terraform/tests/resource_compute_region_autoscaler_test.go'
'google/resource_compute_region_disk_test.go':
Expand Down
18 changes: 18 additions & 0 deletions templates/terraform/encoders/health_check_type.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if _, ok := d.GetOk("http_health_check"); ok {
obj["type"] = "HTTP"
return obj, nil
}
if _, ok := d.GetOk("https_health_check"); ok {
obj["type"] = "HTTPS"
return obj, nil
}
if _, ok := d.GetOk("tcp_health_check"); ok {
obj["type"] = "TCP"
return obj, nil
}
if _, ok := d.GetOk("ssl_health_check"); ok {
obj["type"] = "SSL"
return obj, nil
}

return nil, fmt.Errorf("error in HealthCheck %s: No health check block specified.", d.Get("name").(string))
4 changes: 2 additions & 2 deletions templates/terraform/schema_property.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
<% if force_new?(property, object) -%>
ForceNew: true,
<% end -%>
<% unless property.validation.nil? -%>
<% unless property.validation.nil? || property.output -%>
<% if !property.validation.regex.nil? -%>
ValidateFunc: validateRegexp(`<%= property.validation.regex -%>`),
<% elsif !property.validation.function.nil? -%>
ValidateFunc: <%= property.validation.function -%>,
<% end # property.validation.nil? -%>
<% end # property.validation.nil? -%>
<% if property.is_a?(Api::Type::Enum) && property.validation.nil? -%>
<% if property.is_a?(Api::Type::Enum) && property.validation.nil? && !property.output -%>
<%
enum_values = property.values
enum_values.push "" unless property.required
Expand Down
Loading

0 comments on commit 2d26717

Please sign in to comment.