Skip to content

Commit

Permalink
Add availability domain field to instance and instance template resou…
Browse files Browse the repository at this point in the history
…rce (#12566) (#3212)

[upstream:8765b378e648d65db401f302e4ec05a321dcdbf9]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Dec 13, 2024
1 parent e5d2fc6 commit 1f4a0d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cai2hcl/services/compute/compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func convertScheduling(sched *compute.Scheduling) []map[string]interface{} {
if len(sched.ProvisioningModel) > 0 {
data["provisioning_model"] = sched.ProvisioningModel
}
if sched.AvailabilityDomain > 0 {
data["availability_domain"] = sched.AvailabilityDomain
}
return []map[string]interface{}{data}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/hashicorp/hcl/v2 v2.20.1
github.com/hashicorp/terraform-json v0.22.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241213201446-f86a0265d199
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241213214046-0ff2db35071d
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A=
github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c=
github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241213201446-f86a0265d199 h1:CN7zV5craU5X0zVX2sTQSWYkcSZAOASpkAwSG4bR/ho=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241213201446-f86a0265d199/go.mod h1:+3tdRXgcI0aDAIH8vCVW2qAfcn7JiGlEv8RGuQJp6yY=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241213214046-0ff2db35071d h1:dclwV504ElzFI9UsaxoFg0Oh6udWpJjj7jRnhjRDKt8=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241213214046-0ff2db35071d/go.mod h1:+3tdRXgcI0aDAIH8vCVW2qAfcn7JiGlEv8RGuQJp6yY=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func expandScheduling(v interface{}) (*compute.Scheduling, error) {
scheduling.InstanceTerminationAction = v.(string)
scheduling.ForceSendFields = append(scheduling.ForceSendFields, "InstanceTerminationAction")
}
if v, ok := original["availability_domain"]; ok && v != nil {
scheduling.AvailabilityDomain = int64(v.(int))
}
if v, ok := original["max_run_duration"]; ok {
transformedMaxRunDuration, err := expandComputeMaxRunDuration(v)
if err != nil {
Expand Down Expand Up @@ -276,6 +279,7 @@ func flattenScheduling(resp *compute.Scheduling) []map[string]interface{} {
"min_node_cpus": resp.MinNodeCpus,
"provisioning_model": resp.ProvisioningModel,
"instance_termination_action": resp.InstanceTerminationAction,
"availability_domain": resp.AvailabilityDomain,
}

if resp.AutomaticRestart != nil {
Expand Down Expand Up @@ -727,6 +731,9 @@ func schedulingHasChangeWithoutReboot(d *schema.ResourceData) bool {
if oScheduling["instance_termination_action"] != newScheduling["instance_termination_action"] {
return true
}
if oScheduling["availability_domain"] != newScheduling["availability_domain"] {
return true
}
if oScheduling["host_error_timeout_seconds"] != newScheduling["host_error_timeout_seconds"] {
return true
}
Expand Down

0 comments on commit 1f4a0d6

Please sign in to comment.