Skip to content

Commit

Permalink
Merge pull request #1486 from salv-orlando/fix_import_wrapper
Browse files Browse the repository at this point in the history
ImporterWrapper: Allocate a new Importer object (#1481)
  • Loading branch information
salv-orlando authored Dec 18, 2024
2 parents 7a2c41a + 9c89f9c commit f626dd0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nsxt/removed_resource_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,18 @@ func deleteWrapper(originalFunc schema.DeleteFunc, name string) schema.DeleteFun
}

func importerWrapper(originalImporter *schema.ResourceImporter, name string) *schema.ResourceImporter {
newImporter := new(schema.ResourceImporter)
wrappedFunc := func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
if commonVersionCheck(m) {
return originalImporter.State(d, m)
stateFunc := originalImporter.State
return stateFunc(d, m)
}
log.Printf("[INFO] Failing import for resource %s: removed from NSX 9.0.0", name)
return nil, mpResourceRemovedError(name)
}
originalImporter.State = wrappedFunc
return originalImporter
newImporter.State = wrappedFunc
newImporter.StateContext = originalImporter.StateContext
return newImporter
}

func removedResourceWrapper(realResourceFunc resourceFunc, name string) *schema.Resource {
Expand Down

0 comments on commit f626dd0

Please sign in to comment.