feat(cdn) - Feature parity - #1601
Conversation
|
Hi @matheuspolitano, |
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
| cdnSdk "github.com/stackitcloud/stackit-sdk-go/services/cdn/v1api" | ||
| ) | ||
|
|
||
| func createTestConfig(vals map[string]attr.Value) types.Object { |
There was a problem hiding this comment.
Please add tests here as well to test the values. The createTestConfig is kind of special. Maybe you could use a fixture config like in other tests instead of this?
| Computed: true, // Required when using Default | ||
| Description: schemaDescriptions["config_blocked_ips"], | ||
| ElementType: types.StringType, | ||
| Default: listdefault.StaticValue(types.ListValueMust(types.StringType, []attr.Value{})), |
There was a problem hiding this comment.
We try to avoid using defaults because then the value gets actively set by Terraform, and you cannot use a server-side default or change this later. Feel free to reach out to me if you have further questions regarding this.
There was a problem hiding this comment.
If we don't define a schema Default, Terraform plans the omitted attribute as null. But when the API returns [], mapFields writes [] into the state. Because null (plan) does not match [] (state), Terraform throws the "Provider produced inconsistent result after apply" error. Adding Default: listdefault.StaticValue(...) forces the planned value to be [] in the plan before apply, making it match the returned state perfectly and preventing the error.
There was a problem hiding this comment.
Also this value will never change so is safe
Description
(https://jira.schwarz/browse/STACKITCDN-1451)
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)