Skip to content

Commit

Permalink
Don't dump the environment on error (#390)
Browse files Browse the repository at this point in the history
Fixes #384
  • Loading branch information
komalali authored Aug 21, 2024
1 parent 94f93ae commit dc382f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@

### Bug Fixes

- Fixes a bug where the `Environment` resource would print its contents on error. [#390](https://github.com/pulumi/pulumi-pulumiservice/pull/390)

### Miscellaneous
24 changes: 9 additions & 15 deletions provider/pkg/provider/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,9 @@ func ToPulumiServiceEnvironmentInput(properties *structpb.Struct) (*PulumiServic
}

input := PulumiServiceEnvironmentInput{}
if inputMap["organization"].HasValue() && inputMap["organization"].IsString() {
input.OrgName = inputMap["organization"].StringValue()
} else {
return nil, fmt.Errorf("failed to unmarshal organization value from properties: %s", inputMap)
}
if inputMap["name"].HasValue() && inputMap["name"].IsString() {
input.EnvName = inputMap["name"].StringValue()
} else {
return nil, fmt.Errorf("failed to unmarshal environment name value from properties: %s", inputMap)
}
if inputMap["yaml"].HasValue() && inputMap["yaml"].IsAsset() {
input.Yaml = []byte(inputMap["yaml"].AssetValue().Text)
} else {
return nil, fmt.Errorf("failed to unmarshal yaml value from properties: %s", inputMap)
}
input.OrgName = inputMap["organization"].StringValue()
input.EnvName = inputMap["name"].StringValue()
input.Yaml = []byte(inputMap["yaml"].AssetValue().Text)

return &input, nil
}
Expand Down Expand Up @@ -219,6 +207,12 @@ func (st *PulumiServiceEnvironmentResource) Check(req *pulumirpc.CheckRequest) (
}
}

if !inputMap["yaml"].IsAsset() {
failures = append(failures, &pulumirpc.CheckFailure{
Reason: "property 'yaml' must be an Asset type",
})
}

return &pulumirpc.CheckResponse{Inputs: req.GetNews(), Failures: failures}, nil
}

Expand Down

0 comments on commit dc382f7

Please sign in to comment.