reporegistry: Add a DistroHasRepos helper function
This returns the repos and the found flag, useful for testing if a distro has any valid repos.
This commit is contained in:
parent
963ce1d050
commit
fabe0d28d2
1 changed files with 12 additions and 5 deletions
|
|
@ -96,11 +96,7 @@ func (r *RepoRegistry) ReposByArch(arch distro.Arch, includeTagged bool) ([]rpmm
|
|||
func (r *RepoRegistry) ReposByArchName(distro, arch string, includeTagged bool) ([]rpmmd.RepoConfig, error) {
|
||||
repositories := []rpmmd.RepoConfig{}
|
||||
|
||||
distroRepos, found := r.repos[distro]
|
||||
if !found {
|
||||
return nil, fmt.Errorf("there are no repositories for distribution '%s'", distro)
|
||||
}
|
||||
archRepos, found := distroRepos[arch]
|
||||
archRepos, found := r.DistroHasRepos(distro, arch)
|
||||
if !found {
|
||||
return nil, fmt.Errorf("there are no repositories for distribution '%s' and architecture '%s'", distro, arch)
|
||||
}
|
||||
|
|
@ -116,3 +112,14 @@ func (r *RepoRegistry) ReposByArchName(distro, arch string, includeTagged bool)
|
|||
|
||||
return repositories, nil
|
||||
}
|
||||
|
||||
// DistroHasRepos returns the repositories for the distro+arch, and a found flag
|
||||
func (r *RepoRegistry) DistroHasRepos(distro, arch string) (repos []rpmmd.RepoConfig, found bool) {
|
||||
distroRepos, found := r.repos[distro]
|
||||
if !found {
|
||||
return repos, false
|
||||
}
|
||||
repos, found = distroRepos[arch]
|
||||
|
||||
return repos, found
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue