From 9b7b50595275748a5c7176c0fa473e309b9ca89a Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Thu, 29 Apr 2021 14:36:08 -0700 Subject: [PATCH 1/9] add initial_size to google_compute_node_group --- mmv1/products/compute/api.yaml | 17 ++++++++++++++--- mmv1/products/compute/terraform.yaml | 4 ++++ .../node_group_autoscaling_policy.tf.erb | 2 +- .../compute_node_group_url_replace.go.erb | 8 ++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 mmv1/templates/terraform/pre_create/compute_node_group_url_replace.go.erb diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index 7385e8abad6c..a1fd290192b2 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -8333,7 +8333,7 @@ objects: name: 'NodeGroup' kind: 'compute#NodeGroup' base_url: projects/{{project}}/zones/{{zone}}/nodeGroups - create_url: projects/{{project}}/zones/{{zone}}/nodeGroups?initialNodeCount={{size}} + create_url: projects/{{project}}/zones/{{zone}}/nodeGroups?initialNodeCount=PRE_CREATE_REPLACE_ME has_self_link: true description: | Represents a NodeGroup resource to manage a group of sole-tenant nodes. @@ -8395,9 +8395,20 @@ objects: - !ruby/object:Api::Type::Integer name: 'size' description: | - The total number of nodes in the node group. - required: true + The total number of nodes in the node group. One of `initial_size` or `size` must be specified. + input: true + exactly_one_of: + - size + - initial_size send_empty_value: true + - !ruby/object:Api::Type::Integer + name: 'initialSize' + description: | + The initial number of nodes in the node group. One of `initial_size` or `size` must be specified. + url_param_only: true + exactly_one_of: + - size + - initial_size - !ruby/object:Api::Type::String name: 'maintenancePolicy' description: | diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index e51c3e465e42..2716efa58044 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -1351,6 +1351,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides required: false default_from_api: true custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb' + size: !ruby/object:Overrides::Terraform::PropertyOverride + default_from_api: true autoscalingPolicy: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true autoscalingPolicy.mode: !ruby/object:Overrides::Terraform::PropertyOverride @@ -1359,6 +1361,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides default_from_api: true autoscalingPolicy.maxNodes: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true + custom_code: !ruby/object:Provider::Terraform::CustomCode + pre_create: templates/terraform/pre_create/compute_node_group_url_replace.go.erb NodeTemplate: !ruby/object:Overrides::Terraform::ResourceOverride examples: - !ruby/object:Provider::Terraform::Examples diff --git a/mmv1/templates/terraform/examples/node_group_autoscaling_policy.tf.erb b/mmv1/templates/terraform/examples/node_group_autoscaling_policy.tf.erb index a023cd40cf20..e552ec74eea4 100644 --- a/mmv1/templates/terraform/examples/node_group_autoscaling_policy.tf.erb +++ b/mmv1/templates/terraform/examples/node_group_autoscaling_policy.tf.erb @@ -12,7 +12,7 @@ resource "google_compute_node_group" "<%= ctx[:primary_resource_id] %>" { maintenance_window { start_time = "08:00" } - size = 1 + initial_size = 1 node_template = google_compute_node_template.soletenant-tmpl.id autoscaling_policy { mode = "ONLY_SCALE_OUT" diff --git a/mmv1/templates/terraform/pre_create/compute_node_group_url_replace.go.erb b/mmv1/templates/terraform/pre_create/compute_node_group_url_replace.go.erb new file mode 100644 index 000000000000..62e4828bb500 --- /dev/null +++ b/mmv1/templates/terraform/pre_create/compute_node_group_url_replace.go.erb @@ -0,0 +1,8 @@ +var sizeParam string +if v, ok := d.GetOkExists("size"); ok { + sizeParam = fmt.Sprintf("%v", v) +} else if v, ok := d.GetOkExists("initial_size"); ok { + sizeParam = fmt.Sprintf("%v", v) +} + +url = regexp.MustCompile("PRE_CREATE_REPLACE_ME").ReplaceAllLiteralString(url, sizeParam) From ee7d4e2206e1130aa99913a44f044a0060811555 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Mon, 3 May 2021 15:53:44 -0700 Subject: [PATCH 2/9] move terraform specific parameter to terraform.yaml --- mmv1/products/compute/api.yaml | 2 +- mmv1/products/compute/terraform.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index a1fd290192b2..8cc0049d236c 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -8333,7 +8333,7 @@ objects: name: 'NodeGroup' kind: 'compute#NodeGroup' base_url: projects/{{project}}/zones/{{zone}}/nodeGroups - create_url: projects/{{project}}/zones/{{zone}}/nodeGroups?initialNodeCount=PRE_CREATE_REPLACE_ME + create_url: projects/{{project}}/zones/{{zone}}/nodeGroups?initialNodeCount={{size}} has_self_link: true description: | Represents a NodeGroup resource to manage a group of sole-tenant nodes. diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 2716efa58044..47baf0578d69 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -1327,6 +1327,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides custom_code: !ruby/object:Provider::Terraform::CustomCode encoder: 'templates/terraform/encoders/network_peering_routes_config.go.erb' NodeGroup: !ruby/object:Overrides::Terraform::ResourceOverride + create_url: projects/{{project}}/zones/{{zone}}/nodeGroups?initialNodeCount=PRE_CREATE_REPLACE_ME docs: !ruby/object:Provider::Terraform::Docs warning: | Due to limitations of the API, Terraform cannot update the From 109e505590616de71d71d88f08ccc8fd8bf910ee Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Mon, 3 May 2021 16:01:51 -0700 Subject: [PATCH 3/9] exclude initialSize from inspec and ansible --- mmv1/products/compute/ansible.yaml | 4 ++++ mmv1/products/compute/inspec.yaml | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/mmv1/products/compute/ansible.yaml b/mmv1/products/compute/ansible.yaml index 20efe31ead52..56b0ad3597d6 100644 --- a/mmv1/products/compute/ansible.yaml +++ b/mmv1/products/compute/ansible.yaml @@ -284,6 +284,10 @@ overrides: !ruby/object:Overrides::ResourceOverrides InterconnectAttachment: !ruby/object:Overrides::Ansible::ResourceOverride tests: !ruby/object:Provider::Ansible::Tests has_autogenerated_test: false + NodeGroup: !ruby/object:Overrides::Terraform::ResourceOverride + properties: + initialSize: !ruby/object:Overrides::Inspec::PropertyOverride + exclude: true RegionDisk: !ruby/object:Overrides::Ansible::ResourceOverride properties: sourceSnapshotEncryptionKey: !ruby/object:Overrides::Ansible::PropertyOverride diff --git a/mmv1/products/compute/inspec.yaml b/mmv1/products/compute/inspec.yaml index f1b8cbd3753a..40f398587bc6 100644 --- a/mmv1/products/compute/inspec.yaml +++ b/mmv1/products/compute/inspec.yaml @@ -116,6 +116,10 @@ overrides: !ruby/object:Overrides::ResourceOverrides exclude: true NetworkPeeringRoutesConfig: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true + NodeGroup: !ruby/object:Overrides::Terraform::ResourceOverride + properties: + initialSize: !ruby/object:Overrides::Inspec::PropertyOverride + exclude: true OrganizationSecurityPolicy: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true OrganizationSecurityPolicyAssociation: !ruby/object:Overrides::Inspec::ResourceOverride @@ -222,3 +226,4 @@ overrides: !ruby/object:Overrides::ResourceOverrides exclude: true TargetGrpcProxy: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true + From 7200725ffdb8377827117f93a9d3a0be9448e221 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Tue, 4 May 2021 12:47:44 -0400 Subject: [PATCH 4/9] Update mmv1/products/compute/inspec.yaml Co-authored-by: Riley Karson --- mmv1/products/compute/inspec.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mmv1/products/compute/inspec.yaml b/mmv1/products/compute/inspec.yaml index 40f398587bc6..e8d955e8b763 100644 --- a/mmv1/products/compute/inspec.yaml +++ b/mmv1/products/compute/inspec.yaml @@ -116,7 +116,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides exclude: true NetworkPeeringRoutesConfig: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true - NodeGroup: !ruby/object:Overrides::Terraform::ResourceOverride + NodeGroup: !ruby/object:Overrides::Inspec::ResourceOverride properties: initialSize: !ruby/object:Overrides::Inspec::PropertyOverride exclude: true @@ -226,4 +226,3 @@ overrides: !ruby/object:Overrides::ResourceOverrides exclude: true TargetGrpcProxy: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true - From bdaa6e3f5d111d972f40a1140ca28414863cf170 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Tue, 4 May 2021 12:47:50 -0400 Subject: [PATCH 5/9] Update mmv1/products/compute/ansible.yaml Co-authored-by: Riley Karson --- mmv1/products/compute/ansible.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/compute/ansible.yaml b/mmv1/products/compute/ansible.yaml index 56b0ad3597d6..25e51c0eb6f3 100644 --- a/mmv1/products/compute/ansible.yaml +++ b/mmv1/products/compute/ansible.yaml @@ -284,7 +284,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides InterconnectAttachment: !ruby/object:Overrides::Ansible::ResourceOverride tests: !ruby/object:Provider::Ansible::Tests has_autogenerated_test: false - NodeGroup: !ruby/object:Overrides::Terraform::ResourceOverride + NodeGroup: !ruby/object:Overrides::Ansible::ResourceOverride properties: initialSize: !ruby/object:Overrides::Inspec::PropertyOverride exclude: true From cd7e8e6b8d68b4e3d84e58834f2a03dfb315aac1 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Tue, 4 May 2021 10:07:03 -0700 Subject: [PATCH 6/9] migrate to terraform.yaml to avoid surfacing description in ansible or inspec --- mmv1/products/compute/api.yaml | 2 +- mmv1/products/compute/terraform.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index 8cc0049d236c..a4adae0b0014 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -8395,7 +8395,7 @@ objects: - !ruby/object:Api::Type::Integer name: 'size' description: | - The total number of nodes in the node group. One of `initial_size` or `size` must be specified. + The total number of nodes in the node group. input: true exactly_one_of: - size diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 47baf0578d69..2ba4d63daffb 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -1354,6 +1354,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb' size: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true + description: | + The total number of nodes in the node group. One of `initial_size` or `size` must be specified. autoscalingPolicy: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true autoscalingPolicy.mode: !ruby/object:Overrides::Terraform::PropertyOverride From 285c212c8e5576fc2b49f31cf84a34173caab745 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Tue, 4 May 2021 12:46:03 -0700 Subject: [PATCH 7/9] fix anible build failure --- mmv1/products/compute/api.yaml | 3 --- mmv1/products/compute/terraform.yaml | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index a4adae0b0014..5f679a8c15cd 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -8397,9 +8397,6 @@ objects: description: | The total number of nodes in the node group. input: true - exactly_one_of: - - size - - initial_size send_empty_value: true - !ruby/object:Api::Type::Integer name: 'initialSize' diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 2ba4d63daffb..bb7cd28481c3 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -1356,6 +1356,9 @@ overrides: !ruby/object:Overrides::ResourceOverrides default_from_api: true description: | The total number of nodes in the node group. One of `initial_size` or `size` must be specified. + exactly_one_of: + - size + - initial_size autoscalingPolicy: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true autoscalingPolicy.mode: !ruby/object:Overrides::Terraform::PropertyOverride From 41b1ce10e048162986bcdb193fa5ae9c5fdf2fac Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Tue, 4 May 2021 13:55:20 -0700 Subject: [PATCH 8/9] Inspec to Ansible --- mmv1/products/compute/ansible.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/compute/ansible.yaml b/mmv1/products/compute/ansible.yaml index 25e51c0eb6f3..1a152474fc4b 100644 --- a/mmv1/products/compute/ansible.yaml +++ b/mmv1/products/compute/ansible.yaml @@ -286,7 +286,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides has_autogenerated_test: false NodeGroup: !ruby/object:Overrides::Ansible::ResourceOverride properties: - initialSize: !ruby/object:Overrides::Inspec::PropertyOverride + initialSize: !ruby/object:Overrides::Ansible::PropertyOverride exclude: true RegionDisk: !ruby/object:Overrides::Ansible::ResourceOverride properties: From 5f7725dfad107b0a2815598c1d280cae9299fa74 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Tue, 4 May 2021 17:01:16 -0700 Subject: [PATCH 9/9] add required true for ansible and inspec --- mmv1/products/compute/ansible.yaml | 2 ++ mmv1/products/compute/inspec.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mmv1/products/compute/ansible.yaml b/mmv1/products/compute/ansible.yaml index 1a152474fc4b..7c6e59892754 100644 --- a/mmv1/products/compute/ansible.yaml +++ b/mmv1/products/compute/ansible.yaml @@ -286,6 +286,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides has_autogenerated_test: false NodeGroup: !ruby/object:Overrides::Ansible::ResourceOverride properties: + size: !ruby/object:Overrides::Ansible::PropertyOverride + required: true initialSize: !ruby/object:Overrides::Ansible::PropertyOverride exclude: true RegionDisk: !ruby/object:Overrides::Ansible::ResourceOverride diff --git a/mmv1/products/compute/inspec.yaml b/mmv1/products/compute/inspec.yaml index e8d955e8b763..5c3418615289 100644 --- a/mmv1/products/compute/inspec.yaml +++ b/mmv1/products/compute/inspec.yaml @@ -118,6 +118,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides exclude: true NodeGroup: !ruby/object:Overrides::Inspec::ResourceOverride properties: + size: !ruby/object:Overrides::Inspec::PropertyOverride + required: true initialSize: !ruby/object:Overrides::Inspec::PropertyOverride exclude: true OrganizationSecurityPolicy: !ruby/object:Overrides::Inspec::ResourceOverride