forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inspec project_metric (GoogleCloudPlatform#3010)
Merged PR GoogleCloudPlatform#3010.
- Loading branch information
Showing
20 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
Submodule ansible
updated
from 44e07e to 4661cd
Submodule inspec
updated
27 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
templates/inspec/examples/google_compute_zone/google_compute_zone.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
describe google_compute_zone(project: <%= gcp_project_id -%>, "us-central1-a") do | ||
describe google_compute_zone(project: <%= gcp_project_id -%>, name: "us-central1-a") do | ||
it { should exist } | ||
it { should be_up } | ||
end |
2 changes: 1 addition & 1 deletion
2
templates/inspec/examples/google_compute_zone/google_compute_zones.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
templates/inspec/examples/google_project_metric/google_project_metric.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
<% logging_metric = grab_attributes['logging_metric'] -%> | ||
describe google_project_metric(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{logging_metric['name']}'" : "logging_metric['name']" -%>) do | ||
it { should exist } | ||
its('filter') { should cmp <%= doc_generation ? "'#{logging_metric['filter']}'" : "logging_metric['filter']" -%> } | ||
its('metric_descriptor.metric_kind') { should cmp <%= doc_generation ? "'#{logging_metric['metric_kind']}'" : "logging_metric['metric_kind']" -%> } | ||
its('metric_descriptor.value_type') { should cmp <%= doc_generation ? "'#{logging_metric['value_type']}'" : "logging_metric['value_type']" -%> } | ||
end | ||
|
||
describe google_project_metric(project: <%= gcp_project_id -%>, name: 'nonexistent') do | ||
it { should_not exist } | ||
end |
2 changes: 2 additions & 0 deletions
2
templates/inspec/examples/google_project_metric/google_project_metric_attributes.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') | ||
logging_metric = attribute('logging_metric', default: <%= JSON.pretty_generate(grab_attributes['logging_metric']) -%>, description: 'Logging metric definition') |
15 changes: 15 additions & 0 deletions
15
templates/inspec/examples/google_project_metric/google_project_metrics.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
<% logging_metric = grab_attributes['logging_metric'] -%> | ||
describe google_project_metrics(project: <%= gcp_project_id -%>) do | ||
it { should exist } | ||
its('metric_filters') { should include <%= doc_generation ? "'#{logging_metric['filter']}'" : "logging_metric['filter']" -%> } | ||
its('metric_names') { should include <%= doc_generation ? "'#{logging_metric['name']}'" : "logging_metric['name']" -%> } | ||
end | ||
|
||
describe.one do | ||
google_project_metrics(project: <%= gcp_project_id -%>).metric_types.each do |metric_type| | ||
describe metric_type do | ||
it { should match <%= doc_generation ? "'#{logging_metric['name']}'" : "logging_metric['name']" -%> } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
hash_with_symbols[:dnssec_config_state] = hash['dnssecConfig']&.['state']&.downcase == 'on' | ||
hash_with_symbols[:dnssec_config_state] = hash.dig('dnssecConfig', 'state')&.downcase == 'on' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ def project_name | |
@name | ||
end | ||
|
||
def project_number | ||
@number&.to_i | ||
end | ||
|
||
def label_value_by_key(label_key) | ||
return nil if @labels.nil? || [email protected]_key(label_key) | ||
@labels[label_key] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hash_with_symbols[:metric_type] = hash.dig('metricDescriptor', 'type') |