From e2aeecec8eaaeb0fc0a1cfca45c40f218814329d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 11 Feb 2025 16:51:48 +0100 Subject: [PATCH] repos: make clearer why `newRepoRegistry` is a `var` 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. --- cmd/image-builder/repos.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/image-builder/repos.go b/cmd/image-builder/repos.go index 48fb293..bd28f0c 100644 --- a/cmd/image-builder/repos.go +++ b/cmd/image-builder/repos.go @@ -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} @@ -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