From d6d3bfadc7f0ef4c47d1317278250da321b33cfd Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 16 Sep 2019 16:04:47 -0700 Subject: [PATCH] Add RegionHealthCheck to compute (#185) Signed-off-by: Modular Magician --- docs/resources/google_compute_health_check.md | 16 ++++++ .../resources/google_compute_health_checks.md | 1 + .../healthcheck_http2_health_check.rb | 52 +++++++++++++++++++ libraries/google_compute_health_check.rb | 3 ++ libraries/google_compute_health_checks.rb | 2 + 5 files changed, 74 insertions(+) create mode 100644 libraries/google/compute/property/healthcheck_http2_health_check.rb diff --git a/docs/resources/google_compute_health_check.md b/docs/resources/google_compute_health_check.md index 23618e7d7..800d57210 100644 --- a/docs/resources/google_compute_health_check.md +++ b/docs/resources/google_compute_health_check.md @@ -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 diff --git a/docs/resources/google_compute_health_checks.md b/docs/resources/google_compute_health_checks.md index b9bbf6c73..c943fcba1 100644 --- a/docs/resources/google_compute_health_checks.md +++ b/docs/resources/google_compute_health_checks.md @@ -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 diff --git a/libraries/google/compute/property/healthcheck_http2_health_check.rb b/libraries/google/compute/property/healthcheck_http2_health_check.rb new file mode 100644 index 000000000..d2074c094 --- /dev/null +++ b/libraries/google/compute/property/healthcheck_http2_health_check.rb @@ -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 diff --git a/libraries/google_compute_health_check.rb b/libraries/google_compute_health_check.rb index b72cc5962..14aa3346e 100644 --- a/libraries/google_compute_health_check.rb +++ b/libraries/google_compute_health_check.rb @@ -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' @@ -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 })) @@ -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 diff --git a/libraries/google_compute_health_checks.rb b/libraries/google_compute_health_checks.rb index 7e6509402..9b2da2416 100644 --- a/libraries/google_compute_health_checks.rb +++ b/libraries/google_compute_health_checks.rb @@ -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) @@ -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