Skip to content

Commit

Permalink
fix: move prune channel from function literal to inline code
Browse files Browse the repository at this point in the history
  • Loading branch information
jpower432 committed Dec 14, 2021
1 parent d9718bf commit 0cbc60a
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions alpha/declcfg/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,6 @@ func (g *DiffGenerator) Run(oldModel, newModel model.Model) (model.Model, error)
return nil
}

// Prunes empty channels
pruneEmptyChannels := func() error {
for _, outputPkg := range outputModel {
for _, ch := range outputPkg.Channels {
if len(ch.Bundles) == 0 {
delete(outputPkg.Channels, ch.Name)
}

}
}
return nil
}

headsOnlyMode := len(oldModel) == 0
latestMode := !headsOnlyMode
isInclude := len(g.Includer.Packages) != 0
Expand All @@ -109,8 +96,13 @@ func (g *DiffGenerator) Run(oldModel, newModel model.Model) (model.Model, error)
return nil, err
}
} else {
if err := pruneEmptyChannels(); err != nil {
return nil, err
for _, outputPkg := range outputModel {
for _, ch := range outputPkg.Channels {
if len(ch.Bundles) == 0 {
delete(outputPkg.Channels, ch.Name)
}

}
}
}

Expand Down

0 comments on commit 0cbc60a

Please sign in to comment.