Skip to content

Commit

Permalink
main: update for new reporegistry.New() api (c.f. pr#1179)
Browse files Browse the repository at this point in the history
This commit updates ibcli for the new API in images for the
`reporegistry.New()`. The main incompatible change is that the
`/repositories` part is not longer automatically added inside
the library so we need to add it on the call-site.

This needs osbuild/images#1179
  • Loading branch information
mvo5 committed Feb 10, 2025
1 parent 1a14f5b commit 0678d8d
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions cmd/image-builder/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ 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).
// defaultDataDirs contains the default search paths to look for
// repository data. They 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",
"/etc/image-builder/repositories",
"/usr/share/image-builder/repositories",
}

var newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) {
Expand All @@ -27,17 +24,5 @@ var newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) {
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
return reporegistry.New(dataDirs, []fs.FS{repos.FS})
}

0 comments on commit 0678d8d

Please sign in to comment.