https://pulumi.com logo
#automation-api
Title
# automation-api
l

limited-rainbow-51650

02/15/2021, 5:59 PM
Is there any way to retrieve the update ID via an
UpResult
after running
stack.Up
? https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v2/go/x/auto#UpResult The update ID is what I get returned from this platform REST call: https://api.pulumi.com/api/stacks/{{.Organization}}/{{.Project}}/{{.Stack}}/updates?output-type=service&pageSize=10&page=1
l

lemon-agent-27707

02/15/2021, 7:17 PM
There is a version field that is exposed via
pulumi stack history --json
Does that match up with the ID you're looking for? If so it would be easy to add that to update summary.
l

limited-rainbow-51650

02/15/2021, 9:47 PM
@lemon-agent-27707 yes, it is indeed that version field I’m after. How fast could you get that in in the Go Automation API? With that in place, I don’t need to do another call via the REST API to found out.
l

lemon-agent-27707

02/15/2021, 9:50 PM
I am heads down on some other things this week unfortunately. Should be a simple change, just adding the field here (and a test) so it gets parsed out of the payload: https://github.com/pulumi/pulumi/blob/master/sdk/go/x/auto/stack.go#L629 Contributions welcome, otherwise open a bug and we can get it triaged.
l

limited-rainbow-51650

02/16/2021, 7:29 AM
@lemon-agent-27707 acceptance tests are all green on my PR. You mentioned to add a test. I could do it, but wouldn’t I be just testing the Go JSON deserialization?
l

lemon-agent-27707

02/16/2021, 7:01 PM
The change looks great! Thanks for the contribution. Without a test of some sort, one must pull the branch, write an example, and manually verify that the field does indeed get populated. I agree that the value of a test here isn't massive, but it would be quite easy to add something along the lines of:
Copy code
assert.Greater(t, res.Summary.Version, 0)
To this test: https://github.com/pulumi/pulumi/blob/08c88483753f31a4c62c448a48b324dd19265b9c/sdk/go/x/auto/local_workspace_test.go#L759