pulumi / pulumi-component-provider-go-boilerplate

Apache License 2.0
15 stars 3 forks source link

Eliminate redundancy in registering resource properties #2

Open joeduffy opened 3 years ago

joeduffy commented 3 years ago

It seems there are three places a resource's properties need to be specified:

  1. On the resource struct itself, with pulumi tags on its fields
  2. In the call to RegisterResourceOutputs, after the resource is created
  3. In the State returned from the call to construct the resource

Is there any reason we can't just use the resource struct as the source of truth, and have ways to get its properties as a Map for purposes of the other calls? For example, a PropertyMap() function or method on ResourceState that uses reflection to look for pulumi tags would seem to do the trick. For the example linked to above, it's not too bad, because there are only two properties -- however, I have a Go component that has 20, and I'm finding that it's rather tedious and error prone.