Copilot commented on code in PR #332:
URL:
https://github.com/apache/cloudstack-terraform-provider/pull/332#discussion_r3880013370
##########
cloudstack/resource_cloudstack_project.go:
##########
@@ -47,6 +47,12 @@ func resourceCloudStackProject() *schema.Resource {
},
"displaytext": {
+ Type: schema.TypeString,
+ Optional: true,
+ Deprecated: "use display_text instead",
+ },
Review Comment:
`displaytext` is now deprecated and is conditionally omitted from Read(),
but the schema is still Optional-only. That can leave stale `displaytext`
values in state and cause perpetual diffs when users migrate configs from
`displaytext` to `display_text` (the old state value will keep being compared
against an unset config value). Mark this attribute as `Computed: true`
(similar to other resources’ `display_text`) so state can retain it without
forcing config to keep specifying it.
This issue also appears on line 55 of the same file.
##########
cloudstack/resource_cloudstack_project.go:
##########
@@ -76,12 +82,22 @@ func resourceCloudStackProject() *schema.Resource {
}
}
+// projectDisplayText resolves the effective display text from the new
+// display_text field and the deprecated displaytext field. display_text
+// wins when both are set, since it's the field new configs should use.
+func projectDisplayText(d *schema.ResourceData) string {
+ if v, ok := d.GetOk("display_text"); ok {
+ return v.(string)
+ }
+ return d.Get("displaytext").(string)
+}
Review Comment:
New behavior adds `display_text` support and precedence logic
(`projectDisplayText`, conditional refresh in Read, and update triggers), but
the existing acceptance tests in this repo only exercise the deprecated
`displaytext` attribute. Add/update an acceptance test that configures
`display_text` (and optionally both attrs to verify precedence) to prevent
regressions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]