Skip to content

Commit

Permalink
inspec changes for cloud spanner instance only
Browse files Browse the repository at this point in the history
  • Loading branch information
Patel, Prakash P committed Oct 16, 2019
1 parent cc0dc86 commit f87a2a2
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 1 deletion.
22 changes: 22 additions & 0 deletions products/spanner/inspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Provider::Inspec::Config
overrides: !ruby/object:Overrides::ResourceOverrides
InstanceConfig: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
Instance: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: false
Database: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% spannerinstance = grab_attributes['spannerinstance'] -%>

describe google_spanner_instance(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{spannerinstance['name']}'" : "spannerinstance['name']" -%>, config: <%= doc_generation ? "'#{spannerinstance['config']}'" : "spannerinstance['config']" -%>) do
it { should exist }
its('config') { should eq <%= doc_generation ? "'projects/#{gcp_project_id}/instanceConfigs/#{spannerinstance['config']}'" : "projects/#{gcp_project_id}/instanceConfigs/spannerinstance['config']" -%> }
its('name') { should eq <%= doc_generation ? "'#{spannerinstance['name']}'" : "spannerinstance['name']" -%> }
its('display_name') { should eq <%= doc_generation ? "'#{spannerinstance['display_name']}'" : "spannerinstance['display_name']" -%> }
its('node_count') { should eq <%= doc_generation ? "'#{spannerinstance['node_count']}'" : "spannerinstance['node_count']" -%> }
its('labels') { should eq <%= doc_generation ? "'#{spannerinstance['labels']}'" : "spannerinstance['labels']" -%> }
end
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.')
spannerinstance = attribute('spannerinstance', default: <%= JSON.pretty_generate(grab_attributes['spannerinstance']) -%>, description: 'Cloud Spanner definition')
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% spannerinstance = grab_attributes['spannerinstance'] -%>

describe google_spanner_instances(project: <%= gcp_project_id -%>, config: <%= doc_generation ? "'#{spannerinstance['config']}'" : "spannerinstance['config']" -%>) do
its('config') { should eq <%= doc_generation ? "'#{spannerinstance['config']}'" : "spannerinstance['config']" -%> }
end
11 changes: 11 additions & 0 deletions templates/inspec/tests/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -836,3 +836,14 @@ resource "google_compute_node_group" "inspec-node-group" {
size = var.node_group["size"]
node_template = "${google_compute_node_template.inspec-template.self_link}"
}

resource "google_spanner_instance" "spanner_instance" {
project = "${var.gcp_project_id}"
config = "${var.spannerinstance["config"]}"
name = "${var.spannerinstance["name"]}"
display_name = "${var.spannerinstance["display_name"]}"
node_count = "${var.spannerinstance["node_count"]}"
labels = {
"${var.spannerinstance["label_key"]}" = "${var.spannerinstance["label_value"]}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,13 @@ node_template:
node_group:
name: inspec-node-group
description: A description of the node group
size: 0
size: 0

spannerinstance:
config: regional-us-east1
name: inspec_inst
display_name: inspectest
node_count: 2
label_key: env
label_value: test

0 comments on commit f87a2a2

Please sign in to comment.