Skip to content

Commit

Permalink
Merge 379910c into 7c89f95
Browse files Browse the repository at this point in the history
  • Loading branch information
slevenick authored Jan 30, 2019
2 parents 7c89f95 + 379910c commit 2c4387b
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 12 deletions.
4 changes: 4 additions & 0 deletions products/container/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ manifest: !ruby/object:Provider::Ansible::Manifest
datasources: !ruby/object:Overrides::ResourceOverrides
Cluster: !ruby/object:Overrides::Ansible::ResourceOverride
version_added: '2.8'
properties:
location: !ruby/object:Overrides::Ansible::PropertyOverride
aliases:
- zone
facts: !ruby/object:Provider::Ansible::FactsOverride
has_filters: false
test: !ruby/object:Provider::Ansible::AnsibleFactsTestInformation
Expand Down
14 changes: 4 additions & 10 deletions products/container/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ objects:
- !ruby/object:Api::Resource
name: 'Cluster'
<%= indent(compile('products/container/async.yaml'), 4) %>
base_url: 'projects/{{project}}/zones/{{zone}}/clusters'
base_url: 'projects/{{project}}/locations/{{location}}/clusters'
exports:
- !ruby/object:Api::Type::FetchedExternal
name: endpoint
Expand All @@ -42,15 +42,15 @@ objects:
items: 'clusters'
parameters:
- !ruby/object:Api::Type::String
name: 'zone'
description: 'The zone where the cluster is deployed'
name: 'location'
description: 'The location where the cluster is deployed'
required: true
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: |
The name of this cluster. The name must be unique within this project
and zone, and can be up to 40 characters. Must be Lowercase letters,
and location, and can be up to 40 characters. Must be Lowercase letters,
numbers, and hyphens only. Must start with a letter. Must end with a
number or a letter.
- !ruby/object:Api::Type::String
Expand Down Expand Up @@ -219,12 +219,6 @@ objects:
# have a way to add a compile()/include() to the api.yaml. For the time
# being NodePool will be described outside in their own resource, reaching
# the same behavior and also compliant with the current API.
- !ruby/object:Api::Type::Array
name: 'location'
description: |
The list of Google Compute Engine locations in which the cluster's
nodes should be located.
item_type: Api::Type::String
# 'enableKubernetesAlpha' not supported: we are only producing GA API.
- !ruby/object:Api::Type::String
name: 'endpoint'
Expand Down
2 changes: 1 addition & 1 deletion products/container/examples/ansible/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ task: !ruby/object:Provider::Ansible::Task
node_config:
machine_type: "n1-standard-4"
disk_size_gb: 500
zone: 'us-central1-a'
location: 'us-central1-a'
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
31 changes: 31 additions & 0 deletions products/container/inspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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
manifest: !ruby/object:Provider::Inspec::Manifest
summary: 'InSpec resources for verifying GCP infrastructure'
description: |
InSpec resources for verifying GCP infrastructure
overrides: !ruby/object:Overrides::ResourceOverrides
Cluster: !ruby/object:Overrides::Inspec::ResourceOverride
# Change the name of the resulting resource. Do this because
# there exists a `container_cluster` resource in InSpec already
# that can handle zonal resources only
name: 'RegionalCluster'
NodePool: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
KubeConfig: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
files: !ruby/object:Provider::Config::Files
copy:
'Gemfile': 'provider/inspec/Gemfile'
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.')
regional_cluster = attribute('regional_cluster', default: <%= JSON.pretty_generate(grab_attributes['regional_cluster']) -%>, description: 'Regional container cluster 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)}" -%>
<% regional_cluster = grab_attributes['regional_cluster'] -%>
describe google_container_regional_cluster(project: <%= gcp_project_id -%>, location: <%= doc_generation ? "'#{regional_cluster['region']}'" : "regional_cluster['region']" -%>, name: <%= doc_generation ? "'#{regional_cluster['name']}'" : "regional_cluster['name']" -%>) do
it { should exist }
its('initial_node_count') { should eq <%= doc_generation ? "'#{regional_cluster['initial_node_count']}'" : "regional_cluster['initial_node_count']" -%>}
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% regional_cluster = grab_attributes['regional_cluster'] -%>
describe google_container_regional_cluster(project: <%= gcp_project_id -%>, location: <%= doc_generation ? "'#{regional_cluster['region']}'" : "regional_cluster['region']" -%>, name: <%= doc_generation ? "'#{regional_cluster['name']}'" : "regional_cluster['name']" -%>) do
it { should exist }
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 @@ -74,6 +74,10 @@ variable "target_tcp_proxy" {
type = "map"
}

variable "regional_cluster" {
type = "map"
}

resource "google_compute_ssl_policy" "custom-ssl-policy" {
name = "${var.ssl_policy["name"]}"
min_tls_version = "${var.ssl_policy["min_tls_version"]}"
Expand Down Expand Up @@ -308,4 +312,11 @@ resource "google_compute_target_tcp_proxy" "gcp-inspec-target-tcp-proxy" {
name = "${var.target_tcp_proxy["name"]}"
proxy_header = "${var.target_tcp_proxy["proxy_header"]}"
backend_service = "${google_compute_backend_service.gcp-inspec-tcp-backend-service.self_link}"
}

resource "google_container_cluster" "gcp-inspec-regional-cluster" {
project = "${var.gcp_project_id}"
name = "${var.regional_cluster["name"]}"
region = "${var.regional_cluster["region"]}"
initial_node_count = "${var.regional_cluster["initial_node_count"]}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@ global_forwarding_rule:
target_tcp_proxy:
name: inspec-gcp-target-tcp-proxy
proxy_header: NONE
tcp_backend_service_name: gcp-inspec-tcp-backend-service
tcp_backend_service_name: gcp-inspec-tcp-backend-service

regional_cluster:
name: inspec-gcp-regional-cluster
region: europe-west2
initial_node_count: 3

0 comments on commit 2c4387b

Please sign in to comment.