This message was deleted.
s
This message was deleted.
b
it's currently cosmetic, but you should call it as it lets the component know that all outputs have resolved
m
I see. Am I calling it the right way? I read about apply in Pulumi, but I wonder if the return in my first function could potentially execute before the apply callback in second function is executed (during resource provisioning). For reference, here’s my go code:
Copy code
func NewMyComponent(ctx *pulumi.Context, name string, opts …pulumi.ResourceOption) (*MyComponent, error) {
  
  // infos is a []pulumi.StringOutput in format "output_key1=output_value1;;;output_key2=output_value2…"
  addInfoToOutputs(ctx, myComponent, infos)

  return myComponent, nil
}

func addInfoToOutputs(ctx *pulumi.Context, myComponent *MyComponent, infos []pulumi.StringOutput) {
  pulumi.All(infos).ApplyT(
    func(args []interface{}) error {
      var outputs pulumi.Map
      for _, arg := range args {
        s := strings.Split(arg.(string), ;;;)
        for _, element := range s {
          pair := strings.Split(element, "=")
          if len(pair) != 2 {
            return errors.New(fmt.Sprintf("Expected computed output pair to be of length 2, but got length %v", len(pair)))
          }
          outputs[pair[0]] = pulumi.String(pair[1])
        }
      }
      err := ctx.RegisterResourceOutputs(myComponent, outputs)
      if err != nil {
        return err
      }
      return nil
    },
  )
}
b
I personally would not call that from a function, but that looks functionally correct yes
👍 1
m
Is there any feedback I should be able to see from
pulumi preview
letting me know that
RegisterResourceOutputs
actually ran?
b
not in preview no, preview doesn't know about outputs
m
Right makes sense. I guess that would only resolve after actual provisioning — thanks for your help 🙂
b
yeah, outputs only resolve once the cloud provider returns values
👍 1