Skip to content

Commit

Permalink
Only search active images for matched tags
Browse files Browse the repository at this point in the history
Instead of search all found image stream tags only search for matched
tags since these are the ones that concern us.

Signed-off-by: Simon Rüegg <simon@rueggs.ch>
  • Loading branch information
srueg committed Mar 31, 2020
1 parent 399f81c commit cf9afb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func ExecuteHistoryCleanupCommand(args []string) error {
}
var matchingTags = cleanup.GetMatchingTags(&gitCandidates, &imageStreamTags, matchOption)

activeImageStreamTags, err := openshift.GetActiveImageStreamTags(namespace, image, imageStreamTags)
activeImageStreamTags, err := openshift.GetActiveImageStreamTags(namespace, image, matchingTags)
if err != nil {
return fmt.Errorf("could not retrieve active image stream tags for '%s/%s': %w", namespace, image, err)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/openshift/imagestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ var (

// GetActiveImageStreamTags retrieves the image streams tags referenced in some Kubernetes resources
func GetActiveImageStreamTags(namespace, imageStream string, imageStreamTags []string) (activeImageStreamTags []string, funcError error) {
if len(imageStreamTags) == 0 {
return []string{}, nil
}
funk.ForEach(resources, func(resource schema.GroupVersionResource) {
funk.ForEach(imageStreamTags, func(imageStreamTag string) {
if funk.ContainsString(activeImageStreamTags, imageStreamTag) {
Expand Down

0 comments on commit cf9afb2

Please sign in to comment.