osbuild-composer/config: new option: ignore_missing_repos
osbuild/images added an error type that's returned when the reporegistry loader doesn't find any repository configurations to load [1]. This lets callers decide whether to stop or continue execution based on whether repository configurations are required. A new top-level configuration option is added for osbuild-composer that makes it possible to start the service without having static rpm repositories configured. This is useful in certain (SaaS) modes where build requests specify their own repository configurations.
This commit is contained in:
parent
161a263b45
commit
51287ea57e
2 changed files with 36 additions and 20 deletions
|
|
@ -78,16 +78,30 @@ func NewComposer(config *ComposerConfigFile, stateDir, cacheDir string) (*Compos
|
|||
}
|
||||
|
||||
repoConfigs, err := reporegistry.LoadAllRepositories(repositoryConfigs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error loading repository definitions: %v", err)
|
||||
switch err.(type) {
|
||||
case *reporegistry.NoReposLoadedError:
|
||||
if !c.config.IgnoreMissingRepos {
|
||||
return nil, fmt.Errorf("error loading repository definitions: %w", err)
|
||||
}
|
||||
// running without repositories is allowed: log message and continue
|
||||
logrus.Info(err.Error())
|
||||
logrus.Info("ignore_missing_repos enabled: continuing")
|
||||
case nil:
|
||||
c.repos = reporegistry.NewFromDistrosRepoConfigs(repoConfigs)
|
||||
default:
|
||||
return nil, fmt.Errorf("error loading repository definitions: %w", err)
|
||||
}
|
||||
c.repos = reporegistry.NewFromDistrosRepoConfigs(repoConfigs)
|
||||
|
||||
c.solver = dnfjson.NewBaseSolver(path.Join(c.cacheDir, "rpmmd"))
|
||||
c.solver.SetDNFJSONPath(c.config.DNFJson)
|
||||
|
||||
// Clean up the cache, removes unknown distros and files
|
||||
c.solver.CleanupOldCacheDirs(c.repos.ListDistros())
|
||||
// Clean up the cache, removes unknown distros and files.
|
||||
// If no repos are configured, the cache is cleared out completely.
|
||||
var repoDistros []string
|
||||
if c.repos != nil {
|
||||
repoDistros = c.repos.ListDistros()
|
||||
}
|
||||
c.solver.CleanupOldCacheDirs(repoDistros)
|
||||
|
||||
var jobs jobqueue.JobQueue
|
||||
if config.Worker.PGDatabase != "" {
|
||||
|
|
|
|||
|
|
@ -12,18 +12,19 @@ import (
|
|||
)
|
||||
|
||||
type ComposerConfigFile struct {
|
||||
Koji KojiAPIConfig `toml:"koji"`
|
||||
Worker WorkerAPIConfig `toml:"worker"`
|
||||
WeldrAPI WeldrAPIConfig `toml:"weldr_api"`
|
||||
DistroAliases map[string]string `toml:"distro_aliases" env:"DISTRO_ALIASES"`
|
||||
LogLevel string `toml:"log_level"`
|
||||
LogFormat string `toml:"log_format"`
|
||||
DNFJson string `toml:"dnf-json"`
|
||||
SplunkHost string `env:"SPLUNK_HEC_HOST"`
|
||||
SplunkPort string `env:"SPLUNK_HEC_PORT"`
|
||||
SplunkToken string `env:"SPLUNK_HEC_TOKEN"`
|
||||
GlitchTipDSN string `env:"GLITCHTIP_DSN"`
|
||||
DeploymentChannel string `env:"CHANNEL"`
|
||||
Koji KojiAPIConfig `toml:"koji"`
|
||||
Worker WorkerAPIConfig `toml:"worker"`
|
||||
WeldrAPI WeldrAPIConfig `toml:"weldr_api"`
|
||||
DistroAliases map[string]string `toml:"distro_aliases" env:"DISTRO_ALIASES"`
|
||||
LogLevel string `toml:"log_level"`
|
||||
LogFormat string `toml:"log_format"`
|
||||
DNFJson string `toml:"dnf-json"`
|
||||
IgnoreMissingRepos bool `toml:"ignore_missing_repos"`
|
||||
SplunkHost string `env:"SPLUNK_HEC_HOST"`
|
||||
SplunkPort string `env:"SPLUNK_HEC_PORT"`
|
||||
SplunkToken string `env:"SPLUNK_HEC_TOKEN"`
|
||||
GlitchTipDSN string `env:"GLITCHTIP_DSN"`
|
||||
DeploymentChannel string `env:"CHANNEL"`
|
||||
}
|
||||
|
||||
type KojiAPIConfig struct {
|
||||
|
|
@ -129,9 +130,10 @@ func GetDefaultConfig() *ComposerConfigFile {
|
|||
"rhel-9": "rhel-9.5",
|
||||
"rhel-10": "rhel-10.0",
|
||||
},
|
||||
LogLevel: "info",
|
||||
LogFormat: "journal",
|
||||
DNFJson: "/usr/libexec/osbuild-depsolve-dnf",
|
||||
LogLevel: "info",
|
||||
LogFormat: "journal",
|
||||
DNFJson: "/usr/libexec/osbuild-depsolve-dnf",
|
||||
IgnoreMissingRepos: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue