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

fix(ocean/gke): Fixed null issue for auto_headroom_percentage field #634

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased

## 1.213.1 (March, 17 2025)
BUG FIX:
* resource/spotinst_ocean_gke_import: Fixed null issue for `auto_headroom_percentage` field.

## 1.213.0 (March, 13 2025)
BUG FIX:
* resource/spotinst_elastigroup_aws: Reverted `availability_zones` object to array of string as existing customer facing an issue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
string(AutoHeadroomPercentage): {
Type: schema.TypeInt,
Optional: true,
Default: -1,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if old == "-1" && new == "null" {
return true
}
return false
},
},

string(ResourceLimits): {
Expand Down Expand Up @@ -192,7 +199,7 @@ func expandAutoscaler(data interface{}) (*gcp.AutoScaler, error) {
autoscaler.SetIsAutoConfig(spotinst.Bool(v))
}

if v, ok := m[string(AutoHeadroomPercentage)].(int); ok && v > 0 {
if v, ok := m[string(AutoHeadroomPercentage)].(int); ok && v > -1 {
autoscaler.SetAutoHeadroomPercentage(spotinst.Int(v))
} else {
autoscaler.SetAutoHeadroomPercentage(nil)
Expand Down Expand Up @@ -324,10 +331,14 @@ func flattenAutoscaler(autoScaler *gcp.AutoScaler) []interface{} {
if autoScaler != nil {
result := make(map[string]interface{})

value := spotinst.Int(-1)
if autoScaler.AutoHeadroomPercentage != nil {
value = autoScaler.AutoHeadroomPercentage
}
result[string(AutoHeadroomPercentage)] = spotinst.IntValue(value)
result[string(IsEnabled)] = spotinst.BoolValue(autoScaler.IsEnabled)
result[string(Cooldown)] = spotinst.IntValue(autoScaler.Cooldown)
result[string(IsAutoConfig)] = spotinst.BoolValue(autoScaler.IsAutoConfig)
result[string(AutoHeadroomPercentage)] = spotinst.IntValue(autoScaler.AutoHeadroomPercentage)
result[string(EnableAutomaticAndManualHeadroom)] = spotinst.BoolValue(autoScaler.EnableAutomaticAndManualHeadroom)

if autoScaler.Headroom != nil {
Expand Down