Skip to content

Commit

Permalink
Convert to using set
Browse files Browse the repository at this point in the history
  • Loading branch information
bradmwilliams committed Jan 18, 2022
1 parent 2e73087 commit 927315f
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions cmd/release-controller/prune_graph.go
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
releasecontroller "github.com/openshift/release-controller/pkg/release-controller"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
kv1core "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/klog"
Expand Down Expand Up @@ -49,29 +50,10 @@ func (c *Controller) PruneGraph(secretClient kv1core.SecretInterface, ns, name s
}
}

// To tags that are not in the From tags
pruneTagList := make([]string, 0, len(c.graph.To))
for _, tag := range toMissingList {
if !releasecontroller.StringSliceContains(fromMissingList, tag) {
pruneTagList = append(pruneTagList, tag)
}
}

// From tags that are not in the To tags
for _, tag := range fromMissingList {
if !releasecontroller.StringSliceContains(toMissingList, tag) {
pruneTagList = append(pruneTagList, tag)
}
}

// Tags that are in both the From and To lists
for _, tag := range toMissingList {
if releasecontroller.StringSliceContains(fromMissingList, tag) {
pruneTagList = append(pruneTagList, tag)
}
}

// Combine the 2 lists into a set to eliminate duplicates
pruneTagList := sets.NewString(append(toMissingList, fromMissingList...)...).UnsortedList()
klog.V(2).Infof("Pruning %d/%d tags from release controller graph\n", len(pruneTagList), len(c.graph.To))

c.graph.PruneTags(pruneTagList)

if confirm {
Expand Down

0 comments on commit 927315f

Please sign in to comment.