fix stack reference helpers to handle nil values (#4370)

This commit is contained in:
Evan Boyle 2020-04-12 08:44:08 -07:00 committed by GitHub
parent 779c4144f9
commit fe7877177c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -56,6 +56,9 @@ CHANGELOG
- Propagate unknowns in Go SDK during marshal operations - Propagate unknowns in Go SDK during marshal operations
[#4369](https://github.com/pulumi/pulumi/pull/4369/files) [#4369](https://github.com/pulumi/pulumi/pull/4369/files)
- Fix Go SDK stack reference helpers to handle nil values
[#4370](https://github.com/pulumi/pulumi/pull/4370)
## 1.14.0 (2020-04-01) ## 1.14.0 (2020-04-01)
- Fix error related to side-by-side versions of `@pulumi/pulumi`. - Fix error related to side-by-side versions of `@pulumi/pulumi`.
[#4235](https://github.com/pulumi/pulumi/pull/4235) [#4235](https://github.com/pulumi/pulumi/pull/4235)

View file

@ -23,15 +23,19 @@ func (s *StackReference) GetOutput(name StringInput) AnyOutput {
// GetStringOutput returns a stack output keyed by the given name as an StringOutput // GetStringOutput returns a stack output keyed by the given name as an StringOutput
func (s *StackReference) GetStringOutput(name StringInput) StringOutput { func (s *StackReference) GetStringOutput(name StringInput) StringOutput {
return s.GetOutput(name).ApplyString(func(v interface{}) string { return s.GetOutput(name).ApplyString(func(out interface{}) string {
return v.(string) var res string
if out != nil {
res = out.(string)
}
return res
}) })
} }
// GetIDOutput returns a stack output keyed by the given name as an IDOutput // GetIDOutput returns a stack output keyed by the given name as an IDOutput
func (s *StackReference) GetIDOutput(name StringInput) IDOutput { func (s *StackReference) GetIDOutput(name StringInput) IDOutput {
return s.GetOutput(name).ApplyID(func(v interface{}) ID { return s.GetStringOutput(name).ApplyID(func(out string) ID {
return ID(v.(string)) return ID(out)
}) })
} }