Skip to content

Commit ef45e59

Browse files
authored
Fix bug when setting null scaling spec on update (#94)
1 parent bec44d6 commit ef45e59

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.github/pull_request_template.md

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
## 📋 Checklist
1616

17-
- [ ] Rebased from the main (or release if patching) branch (before testing)
1817
- [ ] Added/updated applicable tests
1918
- [ ] Added/updated examples in the `examples/` directory
20-
- [ ] Tested against [Astro-API](https://github.com/astronomer/astro/)
21-
- [ ] Communicated to/tagged owners of respective clients potentially impacted by these changes.
2219
- [ ] Updated any related [documentation](https://github.com/astronomer/docs/)

internal/provider/resources/resource_deployment.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,8 @@ func validateClusterIdConfig(ctx context.Context, data *models.DeploymentResourc
960960
// RequestScalingSpec converts a Terraform object to a platform.DeploymentScalingSpecRequest to be used in create and update requests
961961
func RequestScalingSpec(ctx context.Context, scalingSpecObj types.Object) (*platform.DeploymentScalingSpecRequest, diag.Diagnostics) {
962962
if scalingSpecObj.IsNull() {
963-
// If the scaling spec is not set, return nil for the request
964-
return nil, nil
963+
// If the scaling spec is not set, return an empty scaling spec for the request
964+
return &platform.DeploymentScalingSpecRequest{}, nil
965965
}
966966
var scalingSpec models.DeploymentScalingSpec
967967
diags := scalingSpecObj.As(ctx, &scalingSpec, basetypes.ObjectAsOptions{

internal/provider/resources/resource_deployment_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,14 @@ func TestAcc_ResourceDeploymentStandardScalingSpec(t *testing.T) {
438438
resource.TestCheckNoResourceAttr(scalingSpecResourceVar, "scaling_spec.hibernation_spec.schedules"),
439439
),
440440
},
441+
// Make scaling spec null to test that it is removed from the deployment with no errors
442+
{
443+
Config: astronomerprovider.ProviderConfig(t, true) + developmentDeployment(scalingSpecDeploymentName,
444+
` `),
445+
Check: resource.ComposeTestCheckFunc(
446+
resource.TestCheckResourceAttr(scalingSpecResourceVar, "scaling_spec.%", "0"),
447+
),
448+
},
441449
{
442450
Config: astronomerprovider.ProviderConfig(t, true) + developmentDeployment(scalingSpecDeploymentName,
443451
`scaling_spec = {

0 commit comments

Comments
 (0)