Skip to content

Commit

Permalink
Fix bug when setting null scaling spec on update (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandyliu authored Jun 26, 2024
1 parent bec44d6 commit ef45e59
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

## 📋 Checklist

- [ ] Rebased from the main (or release if patching) branch (before testing)
- [ ] Added/updated applicable tests
- [ ] Added/updated examples in the `examples/` directory
- [ ] Tested against [Astro-API](https://github.com/astronomer/astro/)
- [ ] Communicated to/tagged owners of respective clients potentially impacted by these changes.
- [ ] Updated any related [documentation](https://github.com/astronomer/docs/)
4 changes: 2 additions & 2 deletions internal/provider/resources/resource_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,8 @@ func validateClusterIdConfig(ctx context.Context, data *models.DeploymentResourc
// RequestScalingSpec converts a Terraform object to a platform.DeploymentScalingSpecRequest to be used in create and update requests
func RequestScalingSpec(ctx context.Context, scalingSpecObj types.Object) (*platform.DeploymentScalingSpecRequest, diag.Diagnostics) {
if scalingSpecObj.IsNull() {
// If the scaling spec is not set, return nil for the request
return nil, nil
// If the scaling spec is not set, return an empty scaling spec for the request
return &platform.DeploymentScalingSpecRequest{}, nil
}
var scalingSpec models.DeploymentScalingSpec
diags := scalingSpecObj.As(ctx, &scalingSpec, basetypes.ObjectAsOptions{
Expand Down
8 changes: 8 additions & 0 deletions internal/provider/resources/resource_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ func TestAcc_ResourceDeploymentStandardScalingSpec(t *testing.T) {
resource.TestCheckNoResourceAttr(scalingSpecResourceVar, "scaling_spec.hibernation_spec.schedules"),
),
},
// Make scaling spec null to test that it is removed from the deployment with no errors
{
Config: astronomerprovider.ProviderConfig(t, true) + developmentDeployment(scalingSpecDeploymentName,
` `),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(scalingSpecResourceVar, "scaling_spec.%", "0"),
),
},
{
Config: astronomerprovider.ProviderConfig(t, true) + developmentDeployment(scalingSpecDeploymentName,
`scaling_spec = {
Expand Down

0 comments on commit ef45e59

Please sign in to comment.