Protect against panic when unprotecting state with no resources

Fixes: #4405
This commit is contained in:
stack72 2020-04-18 14:19:56 +01:00
parent c04d1beaab
commit b7a3d73f69
2 changed files with 8 additions and 0 deletions

View file

@ -6,6 +6,9 @@ CHANGELOG
- Add support for a `PULUMI_CONSOLE_DOMAIN` environment variable to override the
behavior for how URLs to the Pulumi Console are generated.
[#4410](https://github.com/pulumi/pulumi/pull/4410)
- Protect against panic when unprotecting non-existant resources
[#4441](https://github.com/pulumi/pulumi/pull/4441)
## 2.0.0 (2020-04-16)
=======

View file

@ -68,6 +68,11 @@ This command clears the 'protect' bit on one or more resources, allowing those r
func unprotectAllResources(stackName string, showPrompt bool) result.Result {
res := runTotalStateEdit(stackName, showPrompt, func(_ display.Options, snap *deploy.Snapshot) error {
// Protects against Panic when a user tries to unprotect non-existing resources
if snap == nil {
return fmt.Errorf("no resources found to unprotect")
}
for _, res := range snap.Resources {
err := edit.UnprotectResource(snap, res)
contract.AssertNoError(err)