Skip to content

Commit

Permalink
Add RegionHealthCheck to compute (inspec#185)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and Ty Larrabee committed Sep 16, 2019
1 parent c85fccb commit d6d3bfa
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/resources/google_compute_health_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ Properties that can be accessed from the `google_compute_health_check` resource:

* `port_specification`: Specifies how port is selected for health checking, can be one of the following values: * `USE_FIXED_PORT`: The port number in `port` is used for health checking. * `USE_NAMED_PORT`: The `portName` is used for health checking. * `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each network endpoint is used for health checking. For other backends, the port or named port specified in the Backend Service is used for health checking. If not specified, SSL health check follows behavior specified in `port` and `portName` fields.

* `http2_health_check`: A nested object resource

* `host`: The value of the host header in the HTTP2 health check request. If left empty (default value), the public IP on behalf of which this health check is performed will be used.

* `request_path`: The request path of the HTTP2 health check request. The default value is /.

* `response`: 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`: The TCP port number for the HTTP2 health check request. The default value is 443.

* `port_name`: Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence.

* `proxy_header`: Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE.

* `port_specification`: Specifies how port is selected for health checking, can be one of the following values: * `USE_FIXED_PORT`: The port number in `port` is used for health checking. * `USE_NAMED_PORT`: The `portName` is used for health checking. * `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each network endpoint is used for health checking. For other backends, the port or named port specified in the Backend Service is used for health checking. If not specified, HTTP2 health check follows behavior specified in `port` and `portName` fields.



## GCP Permissions
Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_compute_health_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ See [google_compute_health_check.md](google_compute_health_check.md) for more de
* `https_health_checks`: an array of `google_compute_health_check` https_health_check
* `tcp_health_checks`: an array of `google_compute_health_check` tcp_health_check
* `ssl_health_checks`: an array of `google_compute_health_check` ssl_health_check
* `http2_health_checks`: an array of `google_compute_health_check` http2_health_check

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module Compute
module Property
class HealthCheckHttp2HealthCheck
attr_reader :host

attr_reader :request_path

attr_reader :response

attr_reader :port

attr_reader :port_name

attr_reader :proxy_header

attr_reader :port_specification

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@host = args['host']
@request_path = args['requestPath']
@response = args['response']
@port = args['port']
@port_name = args['portName']
@proxy_header = args['proxyHeader']
@port_specification = args['portSpecification']
end

def to_s
"#{@parent_identifier} HealthCheckHttp2HealthCheck"
end
end
end
end
end
3 changes: 3 additions & 0 deletions libraries/google_compute_health_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/compute/property/healthcheck_http2_health_check'
require 'google/compute/property/healthcheck_http_health_check'
require 'google/compute/property/healthcheck_https_health_check'
require 'google/compute/property/healthcheck_ssl_health_check'
Expand All @@ -39,6 +40,7 @@ class HealthCheck < GcpResourceBase
attr_reader :https_health_check
attr_reader :tcp_health_check
attr_reader :ssl_health_check
attr_reader :http2_health_check

def initialize(params)
super(params.merge({ use_http_transport: true }))
Expand All @@ -61,6 +63,7 @@ def parse
@https_health_check = GoogleInSpec::Compute::Property::HealthCheckHttpsHealthCheck.new(@fetched['httpsHealthCheck'], to_s)
@tcp_health_check = GoogleInSpec::Compute::Property::HealthCheckTcpHealthCheck.new(@fetched['tcpHealthCheck'], to_s)
@ssl_health_check = GoogleInSpec::Compute::Property::HealthCheckSslHealthCheck.new(@fetched['sslHealthCheck'], to_s)
@http2_health_check = GoogleInSpec::Compute::Property::HealthCheckHttp2HealthCheck.new(@fetched['http2HealthCheck'], to_s)
end

# Handles parsing RFC3339 time string
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_compute_health_checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class HealthChecks < GcpResourceBase
filter_table_config.add(:https_health_checks, field: :https_health_check)
filter_table_config.add(:tcp_health_checks, field: :tcp_health_check)
filter_table_config.add(:ssl_health_checks, field: :ssl_health_check)
filter_table_config.add(:http2_health_checks, field: :http2_health_check)

filter_table_config.connect(self, :table)

Expand Down Expand Up @@ -88,6 +89,7 @@ def transformers
'httpsHealthCheck' => ->(obj) { return :https_health_check, GoogleInSpec::Compute::Property::HealthCheckHttpsHealthCheck.new(obj['httpsHealthCheck'], to_s) },
'tcpHealthCheck' => ->(obj) { return :tcp_health_check, GoogleInSpec::Compute::Property::HealthCheckTcpHealthCheck.new(obj['tcpHealthCheck'], to_s) },
'sslHealthCheck' => ->(obj) { return :ssl_health_check, GoogleInSpec::Compute::Property::HealthCheckSslHealthCheck.new(obj['sslHealthCheck'], to_s) },
'http2HealthCheck' => ->(obj) { return :http2_health_check, GoogleInSpec::Compute::Property::HealthCheckHttp2HealthCheck.new(obj['http2HealthCheck'], to_s) },
}
end

Expand Down

0 comments on commit d6d3bfa

Please sign in to comment.