@@ -221,8 +221,8 @@ func (c *Cluster) Update(ctx context.Context, diagnostics *diag.Diagnostics, api
221
221
c .Labels = labels
222
222
c .Annotations = annotations
223
223
224
- var autoscalerConfig basetypes. ObjectValue
225
- if c . Spec != nil && plan != nil {
224
+ autoscalerConfig := toAutoScalerConfigTFModel ( nil )
225
+ if plan != nil && plan . Spec . Data . Size . ValueString () == "auto" {
226
226
newAPIConfig := apiCluster .GetData ().GetAutoscalerConfig ()
227
227
if ! plan .Spec .Data .AutoscalerConfig .IsNull () && ! plan .Spec .Data .AutoscalerConfig .IsUnknown () && newAPIConfig != nil &&
228
228
newAPIConfig .RepoServer != nil && newAPIConfig .ApplicationController != nil {
@@ -259,11 +259,6 @@ func (c *Cluster) Update(ctx context.Context, diagnostics *diag.Diagnostics, api
259
259
} else {
260
260
autoscalerConfig = toAutoScalerConfigTFModel (newAPIConfig )
261
261
}
262
- } else {
263
- if plan == nil || plan .Spec == nil || plan .Spec .Data .AutoscalerConfig .IsNull () {
264
- autoscalerConfig = basetypes.ObjectValue {}
265
- }
266
- autoscalerConfig = toAutoScalerConfigTFModel (apiCluster .GetData ().GetAutoscalerConfig ())
267
262
}
268
263
269
264
c .Spec = & ClusterSpec {
@@ -1101,6 +1096,9 @@ func toAutoScalerConfigTFModel(cfg *argocdv1.AutoScalerConfig) basetypes.ObjectV
1101
1096
}
1102
1097
1103
1098
attributes := map [string ]attr.Value {}
1099
+ if cfg == nil {
1100
+ return basetypes .NewObjectNull (attributeTypes )
1101
+ }
1104
1102
if cfg .ApplicationController != nil {
1105
1103
attributes ["application_controller" ] = basetypes .NewObjectValueMust (
1106
1104
attributeTypes ["application_controller" ].(basetypes.ObjectType ).AttrTypes ,
0 commit comments