Skip to content

Commit 391836c

Browse files
committed
do not report autoscalarconfig if size is not auto
1 parent 3bbb6e7 commit 391836c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

akp/types/types.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ func (c *Cluster) Update(ctx context.Context, diagnostics *diag.Diagnostics, api
221221
c.Labels = labels
222222
c.Annotations = annotations
223223

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" {
226226
newAPIConfig := apiCluster.GetData().GetAutoscalerConfig()
227227
if !plan.Spec.Data.AutoscalerConfig.IsNull() && !plan.Spec.Data.AutoscalerConfig.IsUnknown() && newAPIConfig != nil &&
228228
newAPIConfig.RepoServer != nil && newAPIConfig.ApplicationController != nil {
@@ -259,11 +259,6 @@ func (c *Cluster) Update(ctx context.Context, diagnostics *diag.Diagnostics, api
259259
} else {
260260
autoscalerConfig = toAutoScalerConfigTFModel(newAPIConfig)
261261
}
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())
267262
}
268263

269264
c.Spec = &ClusterSpec{
@@ -1101,6 +1096,9 @@ func toAutoScalerConfigTFModel(cfg *argocdv1.AutoScalerConfig) basetypes.ObjectV
11011096
}
11021097

11031098
attributes := map[string]attr.Value{}
1099+
if cfg == nil {
1100+
return basetypes.NewObjectNull(attributeTypes)
1101+
}
11041102
if cfg.ApplicationController != nil {
11051103
attributes["application_controller"] = basetypes.NewObjectValueMust(
11061104
attributeTypes["application_controller"].(basetypes.ObjectType).AttrTypes,

0 commit comments

Comments
 (0)