Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instance helpers, managed zone helpers #259

Merged
merged 6 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/resources/google_compute_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe google_compute_instance(project: 'chef-gcp-inspec', zone: 'zone', name:
its('tags.items') { should include 'bar' }
its('tag_count') { should cmp 2 }
its('service_account_scopes') { should include 'https://www.googleapis.com/auth/compute.readonly' }
its('metadata_keys') { should include '123' }
its('metadata_values') { should include 'asdf' }
end

describe google_compute_instance(project: 'chef-gcp-inspec', zone: 'zone', name: 'nonexistent') do
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/google_compute_region_backend_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ Properties that can be accessed from the `google_compute_region_backend_service`

* `success_rate_stdev_factor`: This factor is used to determine the ejection threshold for success rate outlier ejection. The ejection threshold is the difference between the mean success rate, and the product of this factor and the standard deviation of the mean success rate: mean - (stdev * success_rate_stdev_factor). This factor is divided by a thousand to get a double. That is, if the desired factor is 1.9, the runtime value should be 1900. Defaults to 1900.

* `port_name`: A named port on a backend instance group representing the port for communication to the backend VMs in that group. Required when the loadBalancingScheme is EXTERNAL, INTERNAL_MANAGED, or INTERNAL_SELF_MANAGED and the backends are instance groups. The named port must be defined on each backend instance group. This parameter has no meaning if the backends are NEGs. API sets a default of "http" if not given. Must be omitted when the loadBalancingScheme is INTERNAL (Internal TCP/UDP Load Balancing).

* `protocol`: The protocol this RegionBackendService uses to communicate with backends. The default is HTTP. **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and may result in errors if used with the GA API.
Possible values:
* HTTP
Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_compute_region_backend_services.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ See [google_compute_region_backend_service.md](google_compute_region_backend_ser
* `locality_lb_policies`: an array of `google_compute_region_backend_service` locality_lb_policy
* `names`: an array of `google_compute_region_backend_service` name
* `outlier_detections`: an array of `google_compute_region_backend_service` outlier_detection
* `port_names`: an array of `google_compute_region_backend_service` port_name
* `protocols`: an array of `google_compute_region_backend_service` protocol
* `session_affinities`: an array of `google_compute_region_backend_service` session_affinity
* `timeout_secs`: an array of `google_compute_region_backend_service` timeout_sec
Expand Down
5 changes: 4 additions & 1 deletion docs/resources/google_dataproc_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ Properties that can be accessed from the `google_dataproc_cluster` resource:

* `properties`: The properties to set on daemon config files. Property keys are specified in the prefix:property format, for example `core:hadoop.tmp.dir`

* `optional_components`: The set of optional components to activate on the cluster. Possible values include: COMPONENT_UNSPECIFIED, ANACONDA, HIVE_WEBHCAT, JUPYTER, ZEPPELIN
* `optional_components`: The set of optional components to activate on the cluster. Possible values include: COMPONENT_UNSPECIFIED, ANACONDA, HIVE_WEBHCAT, JUPYTER, ZEPPELIN, HBASE, SOLR, and RANGER
Possible values:
* COMPONENT_UNSPECIFIED
* ANACONDA
* HBASE
* RANGER
* SOLR
* HIVE_WEBHCAT
* JUPYTER
* ZEPPELIN
Expand Down
10 changes: 5 additions & 5 deletions libraries/google_compute_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,19 @@ def label_value_by_key(label_key)

def metadata_keys
return [] if !defined?(@metadata) || @metadata.nil?
@metadata.item[:items].map { |m| m[:key] }
@metadata['items']&.map { |m| m['key'] }
end

def metadata_values
return [] if !defined?(@metadata) || @metadata.nil?
@metadata.item[:items].map { |m| m[:value] }
@metadata['items']&.map { |m| m['value'] }
end

def metadata_value_by_key(metadata_key)
return [] if !defined?(@metadata) || @metadata.nil?
@metadata.item[:items].each do |item|
if item[:key] == metadata_key
return item[:value]
@metadata['items']&.each do |item|
if item['key'] == metadata_key
return item['value']
end
end
[]
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_compute_region_backend_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ComputeRegionBackendService < GcpResourceBase
attr_reader :locality_lb_policy
attr_reader :name
attr_reader :outlier_detection
attr_reader :port_name
attr_reader :protocol
attr_reader :session_affinity
attr_reader :timeout_sec
Expand Down Expand Up @@ -79,6 +80,7 @@ def parse
@locality_lb_policy = @fetched['localityLbPolicy']
@name = @fetched['name']
@outlier_detection = GoogleInSpec::Compute::Property::RegionBackendServiceOutlierDetection.new(@fetched['outlierDetection'], to_s)
@port_name = @fetched['portName']
@protocol = @fetched['protocol']
@session_affinity = @fetched['sessionAffinity']
@timeout_sec = @fetched['timeoutSec']
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_compute_region_backend_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ComputeRegionBackendServices < GcpResourceBase
filter_table_config.add(:locality_lb_policies, field: :locality_lb_policy)
filter_table_config.add(:names, field: :name)
filter_table_config.add(:outlier_detections, field: :outlier_detection)
filter_table_config.add(:port_names, field: :port_name)
filter_table_config.add(:protocols, field: :protocol)
filter_table_config.add(:session_affinities, field: :session_affinity)
filter_table_config.add(:timeout_secs, field: :timeout_sec)
Expand Down Expand Up @@ -98,6 +99,7 @@ def transformers
'localityLbPolicy' => ->(obj) { return :locality_lb_policy, obj['localityLbPolicy'] },
'name' => ->(obj) { return :name, obj['name'] },
'outlierDetection' => ->(obj) { return :outlier_detection, GoogleInSpec::Compute::Property::RegionBackendServiceOutlierDetection.new(obj['outlierDetection'], to_s) },
'portName' => ->(obj) { return :port_name, obj['portName'] },
'protocol' => ->(obj) { return :protocol, obj['protocol'] },
'sessionAffinity' => ->(obj) { return :session_affinity, obj['sessionAffinity'] },
'timeoutSec' => ->(obj) { return :timeout_sec, obj['timeoutSec'] },
Expand Down
4 changes: 2 additions & 2 deletions libraries/google_dns_managed_zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ def to_s
end

def key_signing_key_algorithm
specs = @dnssec_config&.default_key_specs | []
specs = @dnssec_config&.default_key_specs
specs.each do |spec|
return spec.algorithm if spec.key_type == 'keySigning'
end
end

def zone_signing_key_algorithm
specs = @dnssec_config&.default_key_specs | []
specs = @dnssec_config&.default_key_specs
specs.each do |spec|
return spec.algorithm if spec.key_type == 'zoneSigning'
end
Expand Down
2 changes: 2 additions & 0 deletions test/integration/verify/controls/google_compute_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
its('tags.items') { should include instance['tag_2'] }
its('tag_count') { should cmp 2 }
its('service_account_scopes') { should include instance['sa_scope'] }
its('metadata_keys') { should include instance['metadata_key'] }
its('metadata_values') { should include instance['metadata_value'] }
end

describe google_compute_instance(project: gcp_project_id, zone: gcp_zone, name: 'nonexistent') do
Expand Down