This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
forked from inspec/inspec-gcp
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add InSpec support for node groups, node templates and network endpoi…
…nt group Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
7860c53
commit c156acf
Showing
25 changed files
with
1,089 additions
and
12 deletions.
There are no files selected for viewing
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,47 @@ | ||
--- | ||
title: About the google_compute_network_endpoint_group resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_compute_network_endpoint_group` is used to test a Google NetworkEndpointGroup resource | ||
|
||
## Examples | ||
``` | ||
describe google_compute_network_endpoint_group(project: 'chef-gcp-inspec', zone: 'zone', name: 'inspec-gcp-endpoint-group') do | ||
it { should exist } | ||
its('default_port') { should cmp '90' } | ||
end | ||
describe google_compute_network_endpoint_group(project: 'chef-gcp-inspec', zone: 'zone', name: 'nonexistent') do | ||
it { should_not exist } | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_compute_network_endpoint_group` resource: | ||
|
||
|
||
* `id`: The unique identifier for the resource. | ||
|
||
* `name`: Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. | ||
|
||
* `description`: An optional description of this resource. Provide this property when you create the resource. | ||
|
||
* `network_endpoint_type`: Type of network endpoints in this network endpoint group. Currently the only supported value is GCE_VM_IP_PORT. | ||
|
||
* `size`: Number of network endpoints in the network endpoint group. | ||
|
||
* `network`: The network to which all network endpoints in the NEG belong. Uses "default" project network if unspecified. | ||
|
||
* `subnetwork`: Optional subnetwork to which all network endpoints in the NEG belong. | ||
|
||
* `default_port`: The default port used if the port number is not specified in the network endpoint. | ||
|
||
* `zone`: Zone where the network endpoint group is located. | ||
|
||
|
||
## GCP Permissions | ||
|
||
Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. |
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,38 @@ | ||
--- | ||
title: About the google_compute_network_endpoint_groups resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_compute_network_endpoint_groups` is used to test a Google NetworkEndpointGroup resource | ||
|
||
## Examples | ||
``` | ||
describe google_compute_network_endpoint_groups(project: 'chef-gcp-inspec', zone: 'zone') do | ||
its('default_ports') { should include '90' } | ||
its('names') { should include 'inspec-gcp-endpoint-group' } | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_compute_network_endpoint_groups` resource: | ||
|
||
See [google_compute_network_endpoint_group.md](google_compute_network_endpoint_group.md) for more detailed information | ||
* `ids`: an array of `google_compute_network_endpoint_group` id | ||
* `names`: an array of `google_compute_network_endpoint_group` name | ||
* `descriptions`: an array of `google_compute_network_endpoint_group` description | ||
* `network_endpoint_types`: an array of `google_compute_network_endpoint_group` network_endpoint_type | ||
* `sizes`: an array of `google_compute_network_endpoint_group` size | ||
* `networks`: an array of `google_compute_network_endpoint_group` network | ||
* `subnetworks`: an array of `google_compute_network_endpoint_group` subnetwork | ||
* `default_ports`: an array of `google_compute_network_endpoint_group` default_port | ||
* `zones`: an array of `google_compute_network_endpoint_group` zone | ||
|
||
## 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 | ||
|
||
Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. |
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,42 @@ | ||
--- | ||
title: About the google_compute_node_group resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_compute_node_group` is used to test a Google NodeGroup resource | ||
|
||
## Examples | ||
``` | ||
describe google_compute_node_group(project: 'chef-gcp-inspec', zone: 'zone', name: 'inspec-node-group') do | ||
it { should exist } | ||
its('description') { should cmp 'A description of the node group' } | ||
its('size') { should cmp '0' } | ||
end | ||
describe google_compute_node_group(project: 'chef-gcp-inspec', zone: 'zone', name: 'nonexistent') do | ||
it { should_not exist } | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_compute_node_group` resource: | ||
|
||
|
||
* `creation_timestamp`: Creation timestamp in RFC3339 text format. | ||
|
||
* `description`: An optional textual description of the resource. | ||
|
||
* `name`: Name of the resource. | ||
|
||
* `node_template`: The URL of the node template to which this node group belongs. | ||
|
||
* `size`: The total number of nodes in the node group. | ||
|
||
* `zone`: Zone where this node group is located | ||
|
||
|
||
## GCP Permissions | ||
|
||
Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. |
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,37 @@ | ||
--- | ||
title: About the google_compute_node_groups resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_compute_node_groups` is used to test a Google NodeGroup resource | ||
|
||
## Examples | ||
``` | ||
describe google_compute_node_groups(project: 'chef-gcp-inspec', zone: 'zone') do | ||
it { should exist } | ||
its('descriptions') { should include 'A description of the node group' } | ||
its('sizes') { should include '0' } | ||
its('names') { should include 'inspec-node-group' } | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_compute_node_groups` resource: | ||
|
||
See [google_compute_node_group.md](google_compute_node_group.md) for more detailed information | ||
* `creation_timestamps`: an array of `google_compute_node_group` creation_timestamp | ||
* `descriptions`: an array of `google_compute_node_group` description | ||
* `names`: an array of `google_compute_node_group` name | ||
* `node_templates`: an array of `google_compute_node_group` node_template | ||
* `sizes`: an array of `google_compute_node_group` size | ||
* `zones`: an array of `google_compute_node_group` zone | ||
|
||
## 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 | ||
|
||
Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. |
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,49 @@ | ||
--- | ||
title: About the google_compute_node_template resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_compute_node_template` is used to test a Google NodeTemplate resource | ||
|
||
## Examples | ||
``` | ||
describe google_compute_node_template(project: 'chef-gcp-inspec', region: 'europe-west2', name: 'inspec-node-template') do | ||
it { should exist } | ||
its('node_affinity_labels') { should include('key' => 'value') } | ||
end | ||
describe google_compute_node_template(project: 'chef-gcp-inspec', region: 'europe-west2', name: 'nonexistent') do | ||
it { should_not exist } | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_compute_node_template` resource: | ||
|
||
|
||
* `creation_timestamp`: Creation timestamp in RFC3339 text format. | ||
|
||
* `description`: An optional textual description of the resource. | ||
|
||
* `name`: Name of the resource. | ||
|
||
* `node_affinity_labels`: Labels to use for node affinity, which will be used in instance scheduling. | ||
|
||
* `node_type`: Node type to use for nodes group that are created from this template. Only one of nodeTypeFlexibility and nodeType can be specified. | ||
|
||
* `node_type_flexibility`: Flexible properties for the desired node type. Node groups that use this node template will create nodes of a type that matches these properties. Only one of nodeTypeFlexibility and nodeType can be specified. | ||
|
||
* `cpus`: Number of virtual CPUs to use. | ||
|
||
* `memory`: Physical memory available to the node, defined in MB. | ||
|
||
* `local_ssd`: Use local SSD | ||
|
||
* `region`: Region where nodes using the node template will be created | ||
|
||
|
||
## GCP Permissions | ||
|
||
Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. |
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,35 @@ | ||
--- | ||
title: About the google_compute_node_templates resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_compute_node_templates` is used to test a Google NodeTemplate resource | ||
|
||
## Examples | ||
``` | ||
describe google_compute_node_templates(project: 'chef-gcp-inspec', region: 'europe-west2') do | ||
its('names') { should include 'inspec-node-template' } | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_compute_node_templates` resource: | ||
|
||
See [google_compute_node_template.md](google_compute_node_template.md) for more detailed information | ||
* `creation_timestamps`: an array of `google_compute_node_template` creation_timestamp | ||
* `descriptions`: an array of `google_compute_node_template` description | ||
* `names`: an array of `google_compute_node_template` name | ||
* `node_affinity_labels`: an array of `google_compute_node_template` node_affinity_labels | ||
* `node_types`: an array of `google_compute_node_template` node_type | ||
* `node_type_flexibilities`: an array of `google_compute_node_template` node_type_flexibility | ||
* `regions`: an array of `google_compute_node_template` 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 | ||
|
||
Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. |
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
40 changes: 40 additions & 0 deletions
40
libraries/google/compute/property/nodetemplate_node_type_flexibility.rb
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,40 @@ | ||
# 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 Compute | ||
module Property | ||
class NodeTemplateNodeTypeFlexibility | ||
attr_reader :cpus | ||
|
||
attr_reader :memory | ||
|
||
attr_reader :local_ssd | ||
|
||
def initialize(args = nil, parent_identifier = nil) | ||
return if args.nil? | ||
@parent_identifier = parent_identifier | ||
@cpus = args['cpus'] | ||
@memory = args['memory'] | ||
@local_ssd = args['localSsd'] | ||
end | ||
|
||
def to_s | ||
"#{@parent_identifier} NodeTemplateNodeTypeFlexibility" | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# 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. | ||
# | ||
# ---------------------------------------------------------------------------- | ||
require 'gcp_backend' | ||
|
||
# A provider to manage Compute Engine resources. | ||
class ComputeNetworkEndpointGroup < GcpResourceBase | ||
name 'google_compute_network_endpoint_group' | ||
desc 'NetworkEndpointGroup' | ||
supports platform: 'gcp' | ||
|
||
attr_reader :params | ||
attr_reader :id | ||
attr_reader :name | ||
attr_reader :description | ||
attr_reader :network_endpoint_type | ||
attr_reader :size | ||
attr_reader :network | ||
attr_reader :subnetwork | ||
attr_reader :default_port | ||
attr_reader :zone | ||
|
||
def initialize(params) | ||
super(params.merge({ use_http_transport: true })) | ||
@params = params | ||
@fetched = @connection.fetch(product_url, resource_base_url, params, 'Get') | ||
parse unless @fetched.nil? | ||
end | ||
|
||
def parse | ||
@id = @fetched['id'] | ||
@name = @fetched['name'] | ||
@description = @fetched['description'] | ||
@network_endpoint_type = @fetched['networkEndpointType'] | ||
@size = @fetched['size'] | ||
@network = @fetched['network'] | ||
@subnetwork = @fetched['subnetwork'] | ||
@default_port = @fetched['defaultPort'] | ||
@zone = @fetched['zone'] | ||
end | ||
|
||
# Handles parsing RFC3339 time string | ||
def parse_time_string(time_string) | ||
time_string ? Time.parse(time_string) : nil | ||
end | ||
|
||
def exists? | ||
!@fetched.nil? | ||
end | ||
|
||
def to_s | ||
"NetworkEndpointGroup #{@params[:name]}" | ||
end | ||
|
||
private | ||
|
||
def product_url | ||
'https://www.googleapis.com/compute/v1/' | ||
end | ||
|
||
def resource_base_url | ||
'projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}' | ||
end | ||
end |
Oops, something went wrong.