Add Go SDK stack output helpers for String and ID (#4341)

This commit is contained in:
Evan Boyle 2020-04-09 07:52:34 -07:00 committed by GitHub
parent 46dababc28
commit 7382de6b5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -29,6 +29,9 @@ CHANGELOG
- Add overloads to Output.All in .NET
[#4321](https://github.com/pulumi/pulumi/pull/4321)
- Add helper methods for stack outputs in the Go SDK
[#4341](https://github.com/pulumi/pulumi/pull/4341)
- Add additional overloads to Deployment.RunAsync in .NET API.
[#4286](https://github.com/pulumi/pulumi/pull/4286)

View file

@ -12,6 +12,7 @@ type StackReference struct {
Outputs MapOutput `pulumi:"outputs"`
}
// GetOutput returns a stack output keyed by the given name as an AnyOutput
func (s *StackReference) GetOutput(name StringInput) AnyOutput {
return All(name, s.Outputs).
ApplyT(func(args []interface{}) interface{} {
@ -20,6 +21,20 @@ func (s *StackReference) GetOutput(name StringInput) AnyOutput {
}).(AnyOutput)
}
// GetStringOutput returns a stack output keyed by the given name as an StringOutput
func (s *StackReference) GetStringOutput(name StringInput) StringOutput {
return s.GetOutput(name).ApplyString(func(v interface{}) string {
return v.(string)
})
}
// GetIDOutput returns a stack output keyed by the given name as an IDOutput
func (s *StackReference) GetIDOutput(name StringInput) IDOutput {
return s.GetOutput(name).ApplyID(func(v interface{}) ID {
return ID(v.(string))
})
}
type stackReferenceArgs struct {
Name string `pulumi:"name"`
}