Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/reporegistry/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package reporegistry

import "fmt"

// NoReposLoadedError is an error type that is returned when no repositories
// are loaded from the given paths.
type NoReposLoadedError struct {
Paths []string
}

func (e *NoReposLoadedError) Error() string {
return fmt.Sprintf("no repositories found in the given paths: %v", e.Paths)
}
3 changes: 0 additions & 3 deletions pkg/reporegistry/reporegistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ func New(repoConfigPaths []string) (*RepoRegistry, error) {
if err != nil {
return nil, err
}
if len(repositories) == 0 {
return nil, fmt.Errorf("no repositories found in the given paths: %v", repoConfigPaths)
}

return &RepoRegistry{repositories}, nil
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/reporegistry/repository.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package reporegistry

import (
"fmt"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -66,6 +65,10 @@ func LoadAllRepositories(confPaths []string) (rpmmd.DistrosRepoConfigs, error) {
}
}

if len(distrosRepoConfigs) == 0 {
return nil, &NoReposLoadedError{confPaths}
}

return distrosRepoConfigs, nil
}

Expand Down Expand Up @@ -93,7 +96,7 @@ func LoadRepositories(confPaths []string, distro string) (map[string][]rpmmd.Rep
}

if repoConfigs == nil {
return nil, fmt.Errorf("LoadRepositories failed: none of the provided paths contain distro configuration")
return nil, &NoReposLoadedError{confPaths}
}

return repoConfigs, nil
Expand Down