osbuild-composer/config: support specifying distro aliases
Add new configuration option `distro_aliases`, which is a map of strings, allowing to specify distro name alias for supported distributions. Define aliases for RHEL major versions without the minor version specified. For now, the distro aliases map is not used by any API implementation and it is ignored. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
43e87632fb
commit
cdf57e5bc1
4 changed files with 38 additions and 9 deletions
|
|
@ -69,6 +69,9 @@ func NewComposer(config *ComposerConfigFile, stateDir, cacheDir string) (*Compos
|
|||
}
|
||||
|
||||
c.distros = distrofactory.NewDefault()
|
||||
// TODO: set the c.config.DistroAliases to the distrofactory
|
||||
// More work is needed to make the distro aliases behavior consistent for Weldr API,
|
||||
// specifically for picking the correct repositories definition.
|
||||
|
||||
c.solver = dnfjson.NewBaseSolver(path.Join(c.cacheDir, "rpmmd"))
|
||||
c.solver.SetDNFJSONPath(c.config.DNFJson)
|
||||
|
|
|
|||
|
|
@ -11,15 +11,16 @@ import (
|
|||
)
|
||||
|
||||
type ComposerConfigFile struct {
|
||||
Koji KojiAPIConfig `toml:"koji"`
|
||||
Worker WorkerAPIConfig `toml:"worker"`
|
||||
WeldrAPI WeldrAPIConfig `toml:"weldr_api"`
|
||||
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"`
|
||||
Koji KojiAPIConfig `toml:"koji"`
|
||||
Worker WorkerAPIConfig `toml:"worker"`
|
||||
WeldrAPI WeldrAPIConfig `toml:"weldr_api"`
|
||||
DistroAliases map[string]string `toml:"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"`
|
||||
}
|
||||
|
||||
type KojiAPIConfig struct {
|
||||
|
|
@ -112,6 +113,11 @@ func GetDefaultConfig() *ComposerConfigFile {
|
|||
},
|
||||
},
|
||||
},
|
||||
DistroAliases: map[string]string{
|
||||
"rhel-7": "rhel-7.9",
|
||||
"rhel-8": "rhel-8.10",
|
||||
"rhel-9": "rhel-9.4",
|
||||
},
|
||||
LogLevel: "info",
|
||||
LogFormat: "text",
|
||||
DNFJson: "/usr/libexec/osbuild-composer/dnf-json",
|
||||
|
|
|
|||
|
|
@ -61,6 +61,14 @@ func TestDefaultConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
require.Equal(t, expectedWeldrAPIConfig, defaultConfig.WeldrAPI)
|
||||
|
||||
expectedDistroAliases := map[string]string{
|
||||
"rhel-7": "rhel-7.9",
|
||||
"rhel-8": "rhel-8.10",
|
||||
"rhel-9": "rhel-9.4",
|
||||
}
|
||||
require.Equal(t, expectedDistroAliases, defaultConfig.DistroAliases)
|
||||
|
||||
require.Equal(t, "text", defaultConfig.LogFormat)
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +98,14 @@ func TestConfig(t *testing.T) {
|
|||
require.Equal(t, []string{"https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs"}, config.Koji.JWTKeysURLs)
|
||||
require.Equal(t, "", config.Koji.JWTKeysCA)
|
||||
require.Equal(t, "/var/lib/osbuild-composer/acl", config.Koji.JWTACLFile)
|
||||
|
||||
// 'rhel-8' and 'rhel-9' aliases are overwritten by the config file
|
||||
expectedDistroAliases := map[string]string{
|
||||
"rhel-7": "rhel-7.9", // this value is from the default config
|
||||
"rhel-8": "rhel-8.9",
|
||||
"rhel-9": "rhel-9.3",
|
||||
}
|
||||
require.Equal(t, expectedDistroAliases, config.DistroAliases)
|
||||
}
|
||||
|
||||
func TestWeldrDistrosImageTypeDenyList(t *testing.T) {
|
||||
|
|
|
|||
4
cmd/osbuild-composer/testdata/test.toml
vendored
4
cmd/osbuild-composer/testdata/test.toml
vendored
|
|
@ -18,3 +18,7 @@ image_type_denylist = [ "qcow2" ]
|
|||
|
||||
# overrides the default rhel-* configuration
|
||||
[weldr_api.distros."rhel-*"]
|
||||
|
||||
[distro_aliases]
|
||||
rhel-8 = "rhel-8.9"
|
||||
rhel-9 = "rhel-9.3"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue