sudo87 commented on code in PR #335:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/335#discussion_r3946649885


##########
cloudstack/resource_cloudstack_project_test.go:
##########


Review Comment:
   ```suggestion
                                ImportState:       true,
                                ImportStateVerify: true,
                                ImportStateVerifyIgnore: 
[]string{"displaytext", "display_text"}
   ```



##########
cloudstack/resource_cloudstack_project.go:
##########
@@ -358,10 +358,20 @@ func resourceCloudStackProjectRead(d 
*schema.ResourceData, meta any) error {
        d.Set("name", project.Name)
        d.Set("domain", project.Domain)
 
-       // Both fields are Computed, so setting both unconditionally reflects 
the
-       // API value without creating a diff for a config that only sets one.
-       d.Set("displaytext", project.Displaytext)
-       d.Set("display_text", project.Displaytext)
+       // Only refresh whichever of displaytext (deprecated) / display_text the
+       // config is actually using, so a config that only sets one of them
+       // doesn't see a perpetual diff on the other.
+       _, displaytextOk := d.GetOk("displaytext")
+       _, displayTextOk := d.GetOk("display_text")
+
+       switch {
+       case displaytextOk && !displayTextOk:
+               d.Set("displaytext", project.Displaytext)
+       case displayTextOk:
+               d.Set("display_text", project.Displaytext)
+       default:
+               d.Set("displaytext", project.Displaytext)
+       }

Review Comment:
   ```suggestion
        _, legacyFieldConfigured := d.GetOk("displaytext")
       _, newFieldConfigured := d.GetOk("display_text")
   
       if legacyFieldConfigured {
           d.Set("displaytext", project.Displaytext)
       }
       if newFieldConfigured {
           d.Set("display_text", project.Displaytext)
       }
   ```



-- 
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]

Reply via email to