diff --git a/metakube/resource_node_deployment.go b/metakube/resource_node_deployment.go index 0a43f9a..4f4f9e4 100644 --- a/metakube/resource_node_deployment.go +++ b/metakube/resource_node_deployment.go @@ -116,7 +116,7 @@ func metakubeResourceNodeDeploymentCreate(ctx context.Context, d *schema.Resourc nodeDeployment := &models.NodeDeployment{ Name: d.Get("name").(string), - Spec: metakubeNodeDeploymentExpandSpec(d.Get("spec").([]interface{})), + Spec: metakubeNodeDeploymentExpandSpec(d.Get("spec").([]interface{}), true), } if err := metakubeResourceNodeDeploymentVersionCompatibleWithCluster(ctx, k, projectID, clusterID, nodeDeployment); err != nil { @@ -223,7 +223,7 @@ func metakubeResourceNodeDeploymentUpdate(ctx context.Context, d *schema.Resourc clusterID := d.Get("cluster_id").(string) nodeDeployment := &models.NodeDeployment{ - Spec: metakubeNodeDeploymentExpandSpec(d.Get("spec").([]interface{})), + Spec: metakubeNodeDeploymentExpandSpec(d.Get("spec").([]interface{}), false), } if err := metakubeResourceNodeDeploymentVersionCompatibleWithCluster(ctx, k, projectID, clusterID, nodeDeployment); err != nil { diff --git a/metakube/resource_node_deployment_structure.go b/metakube/resource_node_deployment_structure.go index 4c5fa99..9f2791b 100644 --- a/metakube/resource_node_deployment_structure.go +++ b/metakube/resource_node_deployment_structure.go @@ -285,7 +285,7 @@ func metakubeNodeDeploymentFlattenAzureSpec(in *models.AzureNodeSpec) []interfac // expanders -func metakubeNodeDeploymentExpandSpec(p []interface{}) *models.NodeDeploymentSpec { +func metakubeNodeDeploymentExpandSpec(p []interface{}, isCreate bool) *models.NodeDeploymentSpec { if len(p) < 1 { return nil } @@ -302,7 +302,9 @@ func metakubeNodeDeploymentExpandSpec(p []interface{}) *models.NodeDeploymentSpe if v, ok := in["min_replicas"]; ok { if vv, ok := v.(int); ok { obj.MinReplicas = int32(vv) - obj.Replicas = int32ToPtr(obj.MinReplicas) + if isCreate { + obj.Replicas = int32ToPtr(obj.MinReplicas) + } } } diff --git a/metakube/resource_node_deployment_structure_test.go b/metakube/resource_node_deployment_structure_test.go index 43527f8..f1b4b24 100644 --- a/metakube/resource_node_deployment_structure_test.go +++ b/metakube/resource_node_deployment_structure_test.go @@ -404,7 +404,7 @@ func TestExpandNodeDeploymentSpec(t *testing.T) { } for _, tc := range cases { - output := metakubeNodeDeploymentExpandSpec(tc.Input) + output := metakubeNodeDeploymentExpandSpec(tc.Input, false) if diff := cmp.Diff(tc.ExpectedOutput, output); diff != "" { t.Fatalf("Unexpected output from expander: mismatch (-want +got):\n%s", diff) }