MCPcopy Create free account
hub / github.com/apache/cloudstack-terraform-provider / setValueOrID

Function setValueOrID

cloudstack/resources.go:46–58  ·  view source on GitHub ↗
(d *schema.ResourceData, key string, value string, id string)

Source from the content-addressed store, hash-verified

44}
45
46func setValueOrID(d *schema.ResourceData, key string, value string, id string) {
47 if cloudstack.IsID(d.Get(key).(string)) {
48 // If the given id is an empty string, check if the configured value matches
49 // the UnlimitedResourceID in which case we set id to UnlimitedResourceID
50 if id == "" && d.Get(key).(string) == cloudstack.UnlimitedResourceID {
51 id = cloudstack.UnlimitedResourceID
52 }
53
54 d.Set(key, id)
55 } else {
56 d.Set(key, value)
57 }
58}
59
60func retrieveID(cs *cloudstack.CloudStackClient, name string, value string, opts ...cloudstack.OptionFunc) (id string, e *retrieveError) {
61 // If the supplied value isn't a ID, try to retrieve the ID ourselves

Calls

no outgoing calls

Tested by 2

testSetIDOnResourceDataFunction · 0.68