Copilot commented on code in PR #293:
URL:
https://github.com/apache/cloudstack-terraform-provider/pull/293#discussion_r3557480204
##########
cloudstack/resource_cloudstack_user_data.go:
##########
@@ -125,11 +125,19 @@ func resourceCloudStackUserDataRead(d
*schema.ResourceData, meta interface{}) er
p := cs.User.NewListUserDataParams()
p.SetId(id)
+ if v, ok := d.GetOk("project_id"); ok {
+ p.SetProjectid(v.(string))
+ }
+
userdata, err := cs.User.ListUserData(p)
if err != nil {
return fmt.Errorf("Error retrieving user data with ID %s: %s",
id, err)
}
+ if len(userdata.UserData) == 0 {
+ return fmt.Errorf("No user data found with ID %s", id)
+ }
Review Comment:
In a resource Read(), an empty list result should generally be treated as
the remote object having been deleted (clear the ID and return nil), not as a
hard error. Returning an error here will cause refresh/plan to fail if the user
data is deleted out-of-band, and it also breaks the common pattern used
throughout this provider (e.g., resource_cloudstack_autoscale_policy.go clears
state when Count==0).
--
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]