Skip to content

Commit

Permalink
Fix the yaml panic (#421)
Browse files Browse the repository at this point in the history
Fixes #418
  • Loading branch information
komalali authored Oct 7, 2024
1 parent cdc7852 commit a396a31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

### Bug Fixes

- Fix panic in environment definition [#418](https://github.com/pulumi/pulumi-pulumiservice/issues/418)

### Miscellaneous
17 changes: 11 additions & 6 deletions provider/pkg/provider/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,20 @@ func (st *PulumiServiceEnvironmentResource) Check(req *pulumirpc.CheckRequest) (
}
}

yamlBytes := []byte{}
if !inputMap["yaml"].IsComputed() {
yamlBytes, err = getBytesFromAsset(inputMap["yaml"].AssetValue())
if err != nil {
return nil, err
var stringYaml string
inputYaml := inputMap["yaml"]
if !inputYaml.IsComputed() {
if inputYaml.IsAsset() {
yamlBytes, err := getBytesFromAsset(inputYaml.AssetValue())
if err != nil {
return nil, err
}
stringYaml = string(yamlBytes)
} else {
stringYaml = inputYaml.StringValue()
}
}

stringYaml := string(yamlBytes)
trimmedYaml := strings.TrimSpace(stringYaml)
inputMap["yaml"] = resource.MakeSecret(resource.NewStringProperty(trimmedYaml))

Expand Down

0 comments on commit a396a31

Please sign in to comment.