Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when setting null scaling spec on update #94

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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