Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Add another layer to the cache to keep regions separated #454

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cmd/nuke.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (n *Nuke) Filter(item *Item) error {
}

func (n *Nuke) HandleQueue() {
listCache := make(map[string][]resources.Resource)
listCache := make(map[string]map[string][]resources.Resource)

for _, item := range n.items {
switch item.State {
Expand Down Expand Up @@ -272,18 +272,22 @@ func (n *Nuke) HandleRemove(item *Item) {
item.Reason = ""
}

func (n *Nuke) HandleWait(item *Item, cache map[string][]resources.Resource) {
func (n *Nuke) HandleWait(item *Item, cache map[string]map[string][]resources.Resource) {
var err error

left, ok := cache[item.Type]
region := item.Region.Name
_, ok := cache[region]
if !ok {
cache[region] = map[string][]resources.Resource{}
}
left, ok := cache[region][item.Type]
if !ok {
left, err = item.List()
if err != nil {
item.State = ItemStateFailed
item.Reason = err.Error()
return
}
cache[item.Type] = left
cache[region][item.Type] = left
}

for _, r := range left {
Expand Down