Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initial_size to google_compute_node_group #4750

Merged
merged 11 commits into from
May 5, 2021
17 changes: 14 additions & 3 deletions mmv1/products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need to make most of these changes in terraform.yaml (any api.yaml property can be used there, it overwrites the api.yaml value) to avoid breaking Ansible / possibly InSpec

has_self_link: true
description: |
Represents a NodeGroup resource to manage a group of sole-tenant nodes.
Expand Down Expand Up @@ -8395,9 +8395,20 @@ objects:
- !ruby/object:Api::Type::Integer
name: 'size'
description: |
The total number of nodes in the node group.
required: true
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
The total number of nodes in the node group. One of `initial_size` or `size` must be specified.
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
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: |
Expand Down
4 changes: 4 additions & 0 deletions mmv1/products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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)