Skip to content

Commit

Permalink
fixup! move newRepoRegistry() into it's own file
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Nov 6, 2024
1 parent 8e281b3 commit 6ed22e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
22 changes: 0 additions & 22 deletions cmd/image-builder/list_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,10 @@ package main

import (
"io"
"os"
"strings"

"github.com/osbuild/images/pkg/distrofactory"
"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 something
var repositoryConfigs = []string{
"/etc/osbuild-composer",
"/usr/share/osbuild-composer",
}

// XXX: move to pkg/reporegistry
func newRepoRegistry() (*reporegistry.RepoRegistry, error) {
// useful for development/debugging, e.g. run:
// go build && IMAGE_BUILDER_EXTRA_REPOS_PATH=../../test/data ./image-builder
if extraReposPath := os.Getenv("IMAGE_BUILDER_EXTRA_REPOS_PATH"); extraReposPath != "" {
repositoryConfigs = append(repositoryConfigs, strings.Split(extraReposPath, ":")...)
}

return reporegistry.New(repositoryConfigs)
}

func getFilteredImages(filterExprs []string) ([]FilterResult, error) {
repos, err := newRepoRegistry()
if err != nil {
Expand Down
27 changes: 27 additions & 0 deletions cmd/image-builder/repos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"os"
"strings"

"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 something
var repositoryConfigs = []string{
"/etc/osbuild-composer",
"/usr/share/osbuild-composer",
}

// XXX: move this new env into pkg/reporegistry?
func newRepoRegistry() (*reporegistry.RepoRegistry, error) {
// useful for development/debugging, e.g. run:
// go build && IMAGE_BUILDER_EXTRA_REPOS_PATH=../../test/data ./image-builder
if extraReposPath := os.Getenv("IMAGE_BUILDER_EXTRA_REPOS_PATH"); extraReposPath != "" {
repositoryConfigs = append(repositoryConfigs, strings.Split(extraReposPath, ":")...)
}

return reporegistry.New(repositoryConfigs)
}

0 comments on commit 6ed22e2

Please sign in to comment.