debian-forge-cli/cmd/image-builder/repos.go
Michael Vogt 2719f3f727 list-images: add --datadir override for e.g. custom repositories
This commit adds a `--datadir` override that allows overriding
the default search paths for e.g. the custom repositories. In
practise only repository overrides are supported because that
is the only data stored there.
2024-11-29 08:30:30 +00:00

31 lines
953 B
Go

package main
import (
"github.com/osbuild/images/pkg/reporegistry"
)
// XXX: copied from "composer", should be exported there so
// that we keep this in sync
// XXX2: means we need to depend on osbuild-composer-common or a new rpm
// that provides the relevant packages *or* we use go:embed (cf images#1038)
//
// defaultDataDirs contains the default search paths to look for repository
// data. Note that the repositories are under a repositories/ sub-directory
// and contain a bunch of json files of the form "$distro_$version".json
// (but that is an implementation detail that the "images" library takes
// care of).
var defaultDataDirs = []string{
"/etc/osbuild-composer",
"/usr/share/osbuild-composer",
}
var newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) {
var dataDirs []string
if dataDir != "" {
dataDirs = []string{dataDir}
} else {
dataDirs = defaultDataDirs
}
return reporegistry.New(dataDirs)
}