feat(workflows): Adds more optional fields to workflows#997
feat(workflows): Adds more optional fields to workflows#997d0weinberger wants to merge 1 commit intomainfrom
Conversation
c522375 to
e9fa086
Compare
| Type: schema.TypeString, | ||
| Description: "Informational guide text for the workflow", | ||
| Optional: true, | ||
| ValidateDiagFunc: ValidateMaxLength(10000), |
There was a problem hiding this comment.
We agreed not to validate field lengths, since the API might change, right?
Could you remove it?
| Type: schema.TypeString, | ||
| Description: "The type of the owner. Possible values are `USER` and `GROUP`", | ||
| Optional: true, | ||
| DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { return new == "" }, |
There was a problem hiding this comment.
What's the reason for the DiffSupressFunc here? Is there a different behavior (sent data vs received data)?
| task_defaults = jsonencode({ | ||
| "timeout" : 3600 | ||
| }) | ||
| guide = chomp(<<-EOT |
There was a problem hiding this comment.
Do we really want to keep this huge markdown?
I don't see a real benefit in having it, and it would just reduce the readability and also maintainability of the example files. For testing, a short string would be enough
There was a problem hiding this comment.
Really nit, but is new_fields a good pick for a name? If new properties come in, will there be a new-fields2.tf? 😅
| if me.IsDeployed == nil { | ||
| me.IsDeployed = opt.NewBool(true) | ||
| } |
There was a problem hiding this comment.
So, the value on the API side can still be undefined, even if it has a default value?
When running locally, without is_deployed, the value is always defined for me
| // Same pattern as `private` — `isDeployed` defaults to `true` | ||
| isDeployed, isDeployedExists := decoder.GetOkExists("is_deployed") | ||
| if !isDeployedExists { | ||
| me.IsDeployed = opt.NewBool(true) | ||
| } else { | ||
| me.IsDeployed = opt.NewBool(isDeployed.(bool)) | ||
| } |

Why this PR?
The
dynatrace_automation_workflowresource was missing several fields supported by the Dynatrace Automation API. Users couldn’t configure important workflow properties like deployment state, execution limits, or workflow-level input parameters, forcing them to manage these settings outside of Terraform.What has changed?
New workflow-level attributes (all Optional, non-breaking):
is_deployedbooltrueowner_typestringUSER/GROUP- type of the workflow ownerhourly_execution_limitint1000inputstring(JSON)task_defaultsstring(JSON)guidestringresultstringHow does it do it?
All changes follow established patterns in this provider:
Workflowwith correct JSON tags.Schema()with appropriate types, defaults, and validation (StringInSlice,ValidateMaxLength,SuppressJSONorEOT).is_deployedusing the*bool+GetOkExistspattern (same as existingisPrivate) to avoid TF SDK default/zero-value pitfalls.inputandtask_defaultsusing the existing JSON-string pattern (likeTask.Input):map[string]anyin Go/API,jsonencode()in HCL.MarshalJSONto include all new fields in the custom serialization struct (which injectsschemaVersion).MarshalHCL/UnmarshalHCLto encode/decode the new fields.How is it tested?
I added a new Terraform file for E2E testing using the newly introduced fields.
How does it affect users?
Issue: CA-18196