From a66003e5138777b95bc25fe03e2e06df42aa19e7 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Fri, 17 Feb 2023 17:59:22 +0100 Subject: [PATCH] manifest: helper function for collecting pipeline repos Function that filters a list of repositories to return only the global repos and any that define a given pipeline or package set name in their list of PackageSets. --- internal/manifest/manifest.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/internal/manifest/manifest.go b/internal/manifest/manifest.go index e065c119d..afd4ad577 100644 --- a/internal/manifest/manifest.go +++ b/internal/manifest/manifest.go @@ -102,3 +102,23 @@ func (m Manifest) GetExports() []string { } return exports } + +// filterRepos returns a list of repositories that specify the given pipeline +// name in their PackageSets list in addition to any global repositories +// (global repositories are ones that do not specify any PackageSets). +func filterRepos(repos []rpmmd.RepoConfig, plName string) []rpmmd.RepoConfig { + filtered := make([]rpmmd.RepoConfig, 0, len(repos)) + for _, repo := range repos { + if len(repo.PackageSets) == 0 { + filtered = append(filtered, repo) + continue + } + for _, ps := range repo.PackageSets { + if ps == plName { + filtered = append(filtered, repo) + continue + } + } + } + return filtered +}