Prevent panic when using pulumi import with local backend (#5906)

Fixes: #5876
This commit is contained in:
Paul Stack 2020-12-10 13:31:45 +00:00 committed by GitHub
parent cba68b0874
commit 3994fa8c22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View file

@ -5,6 +5,9 @@ CHANGELOG
- Re-apply fix for running multiple `pulumi` processes concurrently. - Re-apply fix for running multiple `pulumi` processes concurrently.
[#5893](https://github.com/pulumi/pulumi/issues/5893) [#5893](https://github.com/pulumi/pulumi/issues/5893)
- [cli] Prevent a panic when using `pulumi import` with local filesystems
[#5906](https://github.com/pulumi/pulumi/issues/5906)
## 2.15.4 (2020-12-08) ## 2.15.4 (2020-12-08)

View file

@ -129,17 +129,19 @@ func (i *importer) wait(ctx context.Context, token completionToken) bool {
} }
func (i *importer) registerExistingResources(ctx context.Context) bool { func (i *importer) registerExistingResources(ctx context.Context) bool {
// Issue same steps per existing resource to make sure that they are recorded in the snapshot. if i != nil && i.deployment != nil && i.deployment.prev != nil {
// We issue these steps serially s.t. the resources remain in the order in which they appear in the state. // Issue same steps per existing resource to make sure that they are recorded in the snapshot.
for _, r := range i.deployment.prev.Resources { // We issue these steps serially s.t. the resources remain in the order in which they appear in the state.
if r.Delete { for _, r := range i.deployment.prev.Resources {
continue if r.Delete {
} continue
}
new := *r new := *r
new.ID = "" new.ID = ""
if !i.executeSerial(ctx, NewSameStep(i.deployment, noopEvent(0), r, &new)) { if !i.executeSerial(ctx, NewSameStep(i.deployment, noopEvent(0), r, &new)) {
return false return false
}
} }
} }
return true return true