Skip to content

Commit

Permalink
Add metadataFilters to GlobalForwardingRule
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
Ty Larrabee authored and modular-magician committed Sep 19, 2019
1 parent b254d8c commit c92f77d
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/resources/google_compute_global_forwarding_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ Properties that can be accessed from the `google_compute_global_forwarding_rule`

* `load_balancing_scheme`: This signifies what the GlobalForwardingRule will be used for. The value of INTERNAL_SELF_MANAGED means that this will be used for Internal Global HTTP(S) LB. The value of EXTERNAL means that this will be used for External Global Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) NOTE: Currently global forwarding rules cannot be used for INTERNAL load balancing.

* `metadata_filters`: Opaque filter criteria used by Loadbalancer to restrict routing configuration to a limited set xDS compliant clients. In their xDS requests to Loadbalancer, xDS clients present node metadata. If a match takes place, the relevant routing configuration is made available to those proxies. For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY, at least one of the filterLabels must match the corresponding label provided in the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of its filterLabels must match with corresponding labels in the provided metadata. metadataFilters specified here can be overridden by those specified in the UrlMap that this ForwardingRule references. metadataFilters only applies to Loadbalancers that have their loadBalancingScheme set to INTERNAL_SELF_MANAGED.

* `filter_match_criteria`: Specifies how individual filterLabel matches within the list of filterLabels contribute towards the overall metadataFilter match. MATCH_ANY - At least one of the filterLabels must have a matching label in the provided metadata. MATCH_ALL - All filterLabels must have matching labels in the provided metadata.

* `filter_labels`: The list of label value pairs that must match labels in the provided metadata based on filterMatchCriteria This list must not be empty and can have at the most 64 entries.

* `name`: Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

* `network`: This field is not used for external load balancing. For INTERNAL_SELF_MANAGED load balancing, this field identifies the network that the load balanced IP should belong to for this global forwarding rule. If this field is not specified, the default network will be used.

* `port_range`: This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to ports in the specified range will be forwarded to target. Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port ranges. Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500

* `target`: The URL of the target resource to receive the matched traffic. The forwarded traffic must be of a type appropriate to the target object.
* `target`: The URL of the target resource to receive the matched traffic. The forwarded traffic must be of a type appropriate to the target object. For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets are valid.



Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_compute_global_forwarding_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ See [google_compute_global_forwarding_rule.md](google_compute_global_forwarding_
* `ip_protocols`: an array of `google_compute_global_forwarding_rule` ip_protocol
* `ip_versions`: an array of `google_compute_global_forwarding_rule` ip_version
* `load_balancing_schemes`: an array of `google_compute_global_forwarding_rule` load_balancing_scheme
* `metadata_filters`: an array of `google_compute_global_forwarding_rule` metadata_filters
* `names`: an array of `google_compute_global_forwarding_rule` name
* `networks`: an array of `google_compute_global_forwarding_rule` network
* `port_ranges`: an array of `google_compute_global_forwarding_rule` port_range
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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.
#
# ----------------------------------------------------------------------------
require 'google/compute/property/globalforwardingrule_metadata_filters_filter_labels'
module GoogleInSpec
module Compute
module Property
class GlobalForwardingRuleMetadataFilters
attr_reader :filter_match_criteria

attr_reader :filter_labels

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@filter_match_criteria = args['filterMatchCriteria']
@filter_labels = GoogleInSpec::Compute::Property::GlobalForwardingRuleMetadataFiltersFilterLabelsArray.parse(args['filterLabels'], to_s)
end

def to_s
"#{@parent_identifier} GlobalForwardingRuleMetadataFilters"
end
end

class GlobalForwardingRuleMetadataFiltersArray
def self.parse(value, parent_identifier)
return if value.nil?
return GlobalForwardingRuleMetadataFilters.new(value, parent_identifier) unless value.is_a?(::Array)
value.map { |v| GlobalForwardingRuleMetadataFilters.new(v, parent_identifier) }
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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 GlobalForwardingRuleMetadataFiltersFilterLabels
attr_reader :name

attr_reader :value

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@name = args['name']
@value = args['value']
end

def to_s
"#{@parent_identifier} GlobalForwardingRuleMetadataFiltersFilterLabels"
end
end

class GlobalForwardingRuleMetadataFiltersFilterLabelsArray
def self.parse(value, parent_identifier)
return if value.nil?
return GlobalForwardingRuleMetadataFiltersFilterLabels.new(value, parent_identifier) unless value.is_a?(::Array)
value.map { |v| GlobalForwardingRuleMetadataFiltersFilterLabels.new(v, parent_identifier) }
end
end
end
end
end
3 changes: 3 additions & 0 deletions libraries/google_compute_global_forwarding_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/compute/property/globalforwardingrule_metadata_filters'

# A provider to manage Compute Engine resources.
class GlobalForwardingRule < GcpResourceBase
Expand All @@ -29,6 +30,7 @@ class GlobalForwardingRule < GcpResourceBase
attr_reader :ip_protocol
attr_reader :ip_version
attr_reader :load_balancing_scheme
attr_reader :metadata_filters
attr_reader :name
attr_reader :network
attr_reader :port_range
Expand All @@ -49,6 +51,7 @@ def parse
@ip_protocol = @fetched['IPProtocol']
@ip_version = @fetched['ipVersion']
@load_balancing_scheme = @fetched['loadBalancingScheme']
@metadata_filters = GoogleInSpec::Compute::Property::GlobalForwardingRuleMetadataFiltersArray.parse(@fetched['metadataFilters'], to_s)
@name = @fetched['name']
@network = @fetched['network']
@port_range = @fetched['portRange']
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_compute_global_forwarding_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class GlobalForwardingRules < GcpResourceBase
filter_table_config.add(:ip_protocols, field: :ip_protocol)
filter_table_config.add(:ip_versions, field: :ip_version)
filter_table_config.add(:load_balancing_schemes, field: :load_balancing_scheme)
filter_table_config.add(:metadata_filters, field: :metadata_filters)
filter_table_config.add(:names, field: :name)
filter_table_config.add(:networks, field: :network)
filter_table_config.add(:port_ranges, field: :port_range)
Expand Down Expand Up @@ -80,6 +81,7 @@ def transformers
'IPProtocol' => ->(obj) { return :ip_protocol, obj['IPProtocol'] },
'ipVersion' => ->(obj) { return :ip_version, obj['ipVersion'] },
'loadBalancingScheme' => ->(obj) { return :load_balancing_scheme, obj['loadBalancingScheme'] },
'metadataFilters' => ->(obj) { return :metadata_filters, GoogleInSpec::Compute::Property::GlobalForwardingRuleMetadataFiltersArray.parse(obj['metadataFilters'], to_s) },
'name' => ->(obj) { return :name, obj['name'] },
'network' => ->(obj) { return :network, obj['network'] },
'portRange' => ->(obj) { return :port_range, obj['portRange'] },
Expand Down

0 comments on commit c92f77d

Please sign in to comment.