From 5eae20f0e8d1da84a7fa8a04fda70f36d4dc7047 Mon Sep 17 00:00:00 2001 From: MajidAbuRmila Date: Tue, 1 Oct 2024 19:46:28 +0300 Subject: [PATCH 1/2] Fix workload options bug --- internal/provider/resource_workload.go | 55 ++++++++++++-------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/internal/provider/resource_workload.go b/internal/provider/resource_workload.go index 838f90b..2bc1e59 100644 --- a/internal/provider/resource_workload.go +++ b/internal/provider/resource_workload.go @@ -379,7 +379,7 @@ func resourceWorkload() *schema.Resource { Type: schema.TypeBool, Description: "Capacity AI. Default: `true`.", Optional: true, - Default: true, + Default: false, }, "debug": { Type: schema.TypeBool, @@ -1606,51 +1606,48 @@ func buildLifeCycleSpec(lifecycle []interface{}, containerSpec *client.Container func buildOptions(options []interface{}, workloadSpec *client.WorkloadSpec, localOptions bool, org string) { - if options == nil { + if len(options) == 0 { return } output := []client.Options{} - if len(options) > 0 { - - for _, o := range options { - - option := o.(map[string]interface{}) + for _, o := range options { - newOptions := client.Options{} + option := o.(map[string]interface{}) - if localOptions { - newOptions.Location = GetString(fmt.Sprintf("/org/%s/location/%s", org, option["location"].(string))) - } + newOptions := client.Options{} - newOptions.CapacityAI = GetBool(option["capacity_ai"]) - newOptions.TimeoutSeconds = GetInt(option["timeout_seconds"]) - newOptions.Debug = GetBool(option["debug"]) - newOptions.Suspend = GetBool(option["suspend"]) + if localOptions { + newOptions.Location = GetString(fmt.Sprintf("/org/%s/location/%s", org, option["location"].(string))) + } - autoScaling := option["autoscaling"].([]interface{}) + newOptions.CapacityAI = GetBool(option["capacity_ai"]) + newOptions.TimeoutSeconds = GetInt(option["timeout_seconds"]) + newOptions.Debug = GetBool(option["debug"]) + newOptions.Suspend = GetBool(option["suspend"]) - if len(autoScaling) > 0 { + autoScaling := option["autoscaling"].([]interface{}) - as := autoScaling[0].(map[string]interface{}) + if len(autoScaling) > 0 { - cas := client.AutoScaling{ + as := autoScaling[0].(map[string]interface{}) - Metric: GetString(as["metric"]), - MetricPercentile: GetString(as["metric_percentile"]), - Target: GetInt(as["target"]), - MaxScale: GetInt(as["max_scale"]), - MinScale: GetInt(as["min_scale"]), - MaxConcurrency: GetInt(as["max_concurrency"]), - ScaleToZeroDelay: GetInt(as["scale_to_zero_delay"]), - } + cas := client.AutoScaling{ - newOptions.AutoScaling = &cas + Metric: GetString(as["metric"]), + MetricPercentile: GetString(as["metric_percentile"]), + Target: GetInt(as["target"]), + MaxScale: GetInt(as["max_scale"]), + MinScale: GetInt(as["min_scale"]), + MaxConcurrency: GetInt(as["max_concurrency"]), + ScaleToZeroDelay: GetInt(as["scale_to_zero_delay"]), } - output = append(output, newOptions) + newOptions.AutoScaling = &cas } + + output = append(output, newOptions) } if workloadSpec == nil { From 6f020b72f3318ed316a2bfeb369cede192cc5abb Mon Sep 17 00:00:00 2001 From: MajidAbuRmila Date: Tue, 1 Oct 2024 22:03:22 +0300 Subject: [PATCH 2/2] Prepare for v1.1.35 release --- Makefile | 2 +- README.md | 4 +++- docs/index.md | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d47ca6c..dc4aa8c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ HOSTNAME=controlplane.com NAMESPACE=com NAME=cpln BINARY=terraform-provider-${NAME} -VERSION=1.1.34 +VERSION=1.1.35 OS_ARCH=linux_amd64 default: install diff --git a/README.md b/README.md index 2ea03ba..18e5878 100644 --- a/README.md +++ b/README.md @@ -302,4 +302,6 @@ tar -cvzf terraform-provider-cpln_1.0.0_windows_amd64.zip terraform-provider-cpl - v1.1.33 - Add import support to mk8s resource. - v1.1.34 - - Make workload options optional. \ No newline at end of file + - Make workload options optional. +- v1.1.35 + - Fix empty options bug in workload resource. \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 5f23ff6..3f2463a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -56,7 +56,7 @@ terraform { required_providers { cpln = { source = "controlplane-com/cpln" - version = "1.1.34" + version = "1.1.35" } } }