This commit switches the default repositories to use the build-in ones from images PR#1112. It is still possible to override using `/etc/image-builder` and `/usr/share/image-builder` or `--datadir`. This is implicitly tested via the container test that no longer includes the files from osbuild-composer in the container.
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/osbuild/images/data/repositories"
|
|
"github.com/osbuild/images/pkg/reporegistry"
|
|
)
|
|
|
|
// 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/image-builder",
|
|
"/usr/share/image-builder",
|
|
}
|
|
|
|
var newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) {
|
|
var dataDirs []string
|
|
if dataDir != "" {
|
|
dataDirs = []string{dataDir}
|
|
} else {
|
|
dataDirs = defaultDataDirs
|
|
}
|
|
|
|
// XXX: think about sharing this with reporegistry?
|
|
var fses []fs.FS
|
|
for _, d := range dataDirs {
|
|
fses = append(fses, os.DirFS(filepath.Join(d, "repositories")))
|
|
}
|
|
fses = append(fses, repos.FS)
|
|
|
|
// XXX: should we support disabling the build-ins somehow?
|
|
conf, err := reporegistry.LoadAllRepositoriesFromFS(fses)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return reporegistry.NewFromDistrosRepoConfigs(conf), nil
|
|
}
|