bored-vr-79323
05/02/2023, 9:13 AMimport (
    "<http://github.com/pulumi/pulumi-command/sdk/go/command/remote|github.com/pulumi/pulumi-command/sdk/go/command/remote>"
    "<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
)
func InstallRke2(ctx *pulumi.Context, connection *remote.ConnectionArgs) {
    ...
    res1, _ := remote.NewCommand(ctx, "is-rke2-server-active", &remote.CommandArgs{
        Connection: connection,
        Create:     pulumi.String("systemctl is-active rke2-server.service"),
    })
    // How do I get the result of the `systemctl` command at this point?
    // Do I use `ApplyT` on `res1.Stdout`?
    // The command below should run only if the service is `active`
    res2, _ := remote.NewCommand(ctx, "get-registration-token", &remote.CommandArgs{
        Connection: connection,
        Create:     pulumi.String("cat /var/lib/rancher/rke2/server/node-token"),
        Triggers:   pulumi.All(res1.Create, res1.Stdin),
    }, pulumi.DependsOn([]pulumi.Resource{res1}))
...
}
I could get the status with ApplyT . But since it’s like a promise, should I use channels and waitgroups to get it out? I have a feeling this isn’t the way to go.
result := res1.Stdout.ApplyT(func(status string) string {
        log.Println(status) // active
        return status
    })
log.Println(result) // {0xc0002de070}
I’ve read the command package docs and looked through all the examples but couldn’t find a solution.
How should I go about this?