Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add memcache, gke release channel, sql ca cert (#3682) (#412)
Browse files Browse the repository at this point in the history
* Add memcache, gke release channel, sql ca cert

* Fixes

* Revert extra ga version

* Fixes

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jun 18, 2020
1 parent f69f6ed commit aadb95f
Show file tree
Hide file tree
Showing 22 changed files with 591 additions and 4 deletions.
14 changes: 14 additions & 0 deletions docs/resources/google_container_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ end
describe google_container_cluster(project: 'chef-gcp-inspec', location: 'europe-west2-a', name: 'nonexistent') do
it { should_not exist }
end
describe google_container_cluster(project: 'chef-gcp-inspec', location: 'europe-west2-a', name: 'gcp-inspec-kube-cluster', beta: true) do
it { should exist }
its('release_channel.channel') { should cmp "RAPID" }
end
```

### Test that a GCP container cluster is in a particular state e.g. "RUNNING"
Expand Down Expand Up @@ -282,6 +287,15 @@ Properties that can be accessed from the `google_container_cluster` resource:

* `enabled`: If enabled, all container images will be validated by Binary Authorization.

* `release_channel`: (Beta only) ReleaseChannel indicates which release channel a cluster is subscribed to. Release channels are arranged in order of risk and frequency of updates.

* `channel`: Which release channel the cluster is subscribed to.
Possible values:
* UNSPECIFIED
* RAPID
* REGULAR
* STABLE

* `location`: The location where the cluster is deployed


Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_container_clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ See [google_container_cluster.md](google_container_cluster.md) for more detailed
* `node_pools`: an array of `google_container_cluster` node_pools
* `pod_security_policy_configs`: (Beta only) an array of `google_container_cluster` pod_security_policy_config
* `binary_authorizations`: an array of `google_container_cluster` binary_authorization
* `release_channels`: (Beta only) an array of `google_container_cluster` release_channel
* `locations`: an array of `google_container_cluster` location

## Filter Criteria
Expand Down
54 changes: 54 additions & 0 deletions docs/resources/google_memcache_instance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: About the google_memcache_instance resource
platform: gcp
---

## Syntax
A `google_memcache_instance` is used to test a Google Instance resource

## Examples
```
describe google_memcache_instance(project: 'chef-gcp-inspec', region: 'europe-west2', name: 'mem-instance') do
it { should exist }
its('node_count') { should cmp 1 }
end
describe google_memcache_instance(project: 'chef-gcp-inspec', region: 'europe-west2', name: "nonexistent") do
it { should_not exist }
end
```

## Properties
Properties that can be accessed from the `google_memcache_instance` resource:


* `name`: (Beta only) The resource name of the instance.

* `display_name`: (Beta only) A user-visible name for the instance.

* `create_time`: (Beta only) Creation timestamp in RFC3339 text format.

* `labels`: (Beta only) Resource labels to represent user-provided metadata.

* `zones`: (Beta only) Zones where memcache nodes should be provisioned. If not provided, all zones will be used.

* `authorized_network`: (Beta only) The full name of the GCE network to connect the instance to. If not provided, 'default' will be used.

* `node_count`: (Beta only) Number of nodes in the memcache instance.

* `node_config`: (Beta only) Configuration for memcache nodes.

* `cpu_count`: (Beta only) Number of CPUs per node.

* `memory_size_mb`: (Beta only) Memory size in Mebibytes for each memcache node.

* `memcache_parameters`: (Beta only) User-specified parameters for this memcache instance.

* `id`: (Beta only) This is a unique ID associated with this set of parameters.

* `params`: (Beta only) User-defined set of parameters to use in the memcache process.

* `region`: (Beta only) The name of the Memcache region of the instance.


## GCP Permissions
36 changes: 36 additions & 0 deletions docs/resources/google_memcache_instances.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: About the google_memcache_instances resource
platform: gcp
---

## Syntax
A `google_memcache_instances` is used to test a Google Instance resource

## Examples
```
describe google_memcache_instances(project: 'chef-gcp-inspec', region: 'europe-west2') do
its('count') { should be >= 1 }
its('node_counts') { should include 1 }
end
```

## Properties
Properties that can be accessed from the `google_memcache_instances` resource:

See [google_memcache_instance.md](google_memcache_instance.md) for more detailed information
* `names`: (Beta only) an array of `google_memcache_instance` name
* `display_names`: (Beta only) an array of `google_memcache_instance` display_name
* `create_times`: (Beta only) an array of `google_memcache_instance` create_time
* `labels`: (Beta only) an array of `google_memcache_instance` labels
* `zones`: (Beta only) an array of `google_memcache_instance` zones
* `authorized_networks`: (Beta only) an array of `google_memcache_instance` authorized_network
* `node_counts`: (Beta only) an array of `google_memcache_instance` node_count
* `node_configs`: (Beta only) an array of `google_memcache_instance` node_config
* `memcache_parameters`: (Beta only) an array of `google_memcache_instance` memcache_parameters
* `regions`: (Beta only) an array of `google_memcache_instance` region

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.

## GCP Permissions
14 changes: 14 additions & 0 deletions docs/resources/google_sql_database_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ Properties that can be accessed from the `google_sql_database_instance` resource

* `kms_key_version_name`: The KMS key version used to encrypt the Cloud SQL instance

* `server_ca_cert`: SSL configuration

* `cert`: PEM representation of the X.509 certificate.

* `cert_serial_number`: Serial number, as extracted from the certificate.

* `common_name`: User supplied name. Constrained to [a-zA-Z.-_ ]+.

* `create_time`: The time when the certificate was created in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.

* `expiration_time`: The time when the certificate expires in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.

* `sha1_fingerprint`: SHA-1 fingerprint of the certificate.


## GCP Permissions

Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_sql_database_instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ See [google_sql_database_instance.md](google_sql_database_instance.md) for more
* `instance_states`: an array of `google_sql_database_instance` state
* `disk_encryption_configurations`: an array of `google_sql_database_instance` disk_encryption_configuration
* `disk_encryption_statuses`: an array of `google_sql_database_instance` disk_encryption_status
* `server_ca_certs`: an array of `google_sql_database_instance` server_ca_cert

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
Expand Down
34 changes: 34 additions & 0 deletions libraries/google/container/property/cluster_release_channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 Container
module Property
class ClusterReleaseChannel
attr_reader :channel

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

def to_s
"#{@parent_identifier} ClusterReleaseChannel"
end
end
end
end
end
37 changes: 37 additions & 0 deletions libraries/google/memcache/property/instance_memcache_parameters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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 Memcache
module Property
class InstanceMemcacheParameters
attr_reader :id

attr_reader :params

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

def to_s
"#{@parent_identifier} InstanceMemcacheParameters"
end
end
end
end
end
37 changes: 37 additions & 0 deletions libraries/google/memcache/property/instance_node_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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 Memcache
module Property
class InstanceNodeConfig
attr_reader :cpu_count

attr_reader :memory_size_mb

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@cpu_count = args['cpuCount']
@memory_size_mb = args['memorySizeMb']
end

def to_s
"#{@parent_identifier} InstanceNodeConfig"
end
end
end
end
end
54 changes: 54 additions & 0 deletions libraries/google/sql/property/databaseinstance_server_ca_cert.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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 SQL
module Property
class DatabaseInstanceServerCaCert
attr_reader :cert

attr_reader :cert_serial_number

attr_reader :common_name

attr_reader :create_time

attr_reader :expiration_time

attr_reader :sha1_fingerprint

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@cert = args['cert']
@cert_serial_number = args['certSerialNumber']
@common_name = args['commonName']
@create_time = parse_time_string(args['createTime'])
@expiration_time = parse_time_string(args['expirationTime'])
@sha1_fingerprint = args['sha1Fingerprint']
end

def to_s
"#{@parent_identifier} DatabaseInstanceServerCaCert"
end

# Handles parsing RFC3339 time string
def parse_time_string(time_string)
time_string ? Time.parse(time_string) : nil
end
end
end
end
end
8 changes: 4 additions & 4 deletions libraries/google_compute_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,17 @@ def service_account_scopes
end

def block_project_ssh_keys
return false if !defined?(@metadata.items) || @metadata.items.nil?
@metadata.items.each do |element|
return false if !defined?(@metadata['items']) || @metadata['items'].nil?
@metadata['items'].each do |element|
return true if element.key=='block-project-ssh-keys' and element.value.casecmp('true').zero?
return true if element.key=='block-project-ssh-keys' and element.value=='1'
end
false
end

def has_serial_port_disabled?
return false if !defined?(@metadata.items) || @metadata.items.nil?
@metadata.items.each do |element|
return false if !defined?(@metadata['items']) || @metadata['items'].nil?
@metadata['items'].each do |element|
return true if element.key=='serial-port-enable' and element.value.casecmp('false').zero?
return true if element.key=='serial-port-enable' and element.value=='0'
end
Expand Down
3 changes: 3 additions & 0 deletions libraries/google_container_cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
require 'google/container/property/cluster_node_pools'
require 'google/container/property/cluster_pod_security_policy_config'
require 'google/container/property/cluster_private_cluster_config'
require 'google/container/property/cluster_release_channel'

# A provider to manage Google Kubernetes Engine resources.
class ContainerCluster < GcpResourceBase
Expand Down Expand Up @@ -80,6 +81,7 @@ class ContainerCluster < GcpResourceBase
attr_reader :node_pools
attr_reader :pod_security_policy_config
attr_reader :binary_authorization
attr_reader :release_channel
attr_reader :location

def initialize(params)
Expand Down Expand Up @@ -127,6 +129,7 @@ def parse
@node_pools = GoogleInSpec::Container::Property::ClusterNodePoolsArray.parse(@fetched['nodePools'], to_s)
@pod_security_policy_config = GoogleInSpec::Container::Property::ClusterPodSecurityPolicyConfig.new(@fetched['podSecurityPolicyConfig'], to_s)
@binary_authorization = GoogleInSpec::Container::Property::ClusterBinaryAuthorization.new(@fetched['binaryAuthorization'], to_s)
@release_channel = GoogleInSpec::Container::Property::ClusterReleaseChannel.new(@fetched['releaseChannel'], to_s)
@location = @fetched['location']
end

Expand Down
2 changes: 2 additions & 0 deletions libraries/google_container_clusters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ContainerClusters < GcpResourceBase
filter_table_config.add(:node_pools, field: :node_pools)
filter_table_config.add(:pod_security_policy_configs, field: :pod_security_policy_config)
filter_table_config.add(:binary_authorizations, field: :binary_authorization)
filter_table_config.add(:release_channels, field: :release_channel)
filter_table_config.add(:locations, field: :location)

filter_table_config.connect(self, :table)
Expand Down Expand Up @@ -137,6 +138,7 @@ def transformers
'nodePools' => ->(obj) { return :node_pools, GoogleInSpec::Container::Property::ClusterNodePoolsArray.parse(obj['nodePools'], to_s) },
'podSecurityPolicyConfig' => ->(obj) { return :pod_security_policy_config, GoogleInSpec::Container::Property::ClusterPodSecurityPolicyConfig.new(obj['podSecurityPolicyConfig'], to_s) },
'binaryAuthorization' => ->(obj) { return :binary_authorization, GoogleInSpec::Container::Property::ClusterBinaryAuthorization.new(obj['binaryAuthorization'], to_s) },
'releaseChannel' => ->(obj) { return :release_channel, GoogleInSpec::Container::Property::ClusterReleaseChannel.new(obj['releaseChannel'], to_s) },
'location' => ->(obj) { return :location, obj['location'] },
}
end
Expand Down
Loading

0 comments on commit aadb95f

Please sign in to comment.