Skip to content

Commit

Permalink
repos: make clearer why newRepoRegistry is a var
Browse files Browse the repository at this point in the history
This commit reworks the `newRepoRegistry` func so that its easier
to see that it is a variable so that it can be overriden by the
tests. In the tests we want to use the `testrepos` we get from
images and in the real implementation we want to use the full
repo loader with search-paths and extra repos.
  • Loading branch information
mvo5 committed Feb 12, 2025
1 parent 5f6d590 commit e2aeece
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/image-builder/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func parseExtraRepo(extraRepo string) ([]rpmmd.RepoConfig, error) {
}, nil
}

var newRepoRegistry = func(dataDir string, extraRepos []string) (*reporegistry.RepoRegistry, error) {
func newRepoRegistryImpl(dataDir string, extraRepos []string) (*reporegistry.RepoRegistry, error) {
var dataDirs []string
if dataDir != "" {
dataDirs = []string{dataDir}
Expand Down Expand Up @@ -87,3 +87,6 @@ var newRepoRegistry = func(dataDir string, extraRepos []string) (*reporegistry.R

return reporegistry.NewFromDistrosRepoConfigs(conf), nil
}

// this is a variable to make it overridable in tests
var newRepoRegistry = newRepoRegistryImpl

0 comments on commit e2aeece

Please sign in to comment.