osbuild-worker: add osbuild_executor config option

This commit is contained in:
Sanne Raymaekers 2024-01-25 15:16:00 +01:00
parent c9c51613a4
commit 9e85050633
2 changed files with 22 additions and 0 deletions

View file

@ -71,6 +71,10 @@ type pulpConfig struct {
ServerURL string `toml:"server_address"`
}
type executorConfig struct {
Type string `toml:"type"`
}
type workerConfig struct {
Composer *composerConfig `toml:"composer"`
Koji map[string]kojiServerConfig `toml:"koji"`
@ -85,12 +89,17 @@ type workerConfig struct {
// default value: /api/worker/v1
BasePath string `toml:"base_path"`
DNFJson string `toml:"dnf-json"`
// default value: &{ Type: host }
OSBuildExecutor *executorConfig `toml:"osbuild_executor"`
}
func parseConfig(file string) (*workerConfig, error) {
// set defaults
config := workerConfig{
BasePath: "/api/worker/v1",
OSBuildExecutor: &executorConfig{
Type: "host",
},
}
_, err := toml.DecodeFile(file, &config)
@ -113,5 +122,12 @@ func parseConfig(file string) (*workerConfig, error) {
}
}
switch config.OSBuildExecutor.Type {
case "host", "aws.ec2", "qemu.kvm":
// good and supported
default:
return nil, fmt.Errorf("OSBuildExecutor needs to be host, aws.ec2, or qemu.kvm. Got: %s.", config.OSBuildExecutor)
}
return &config, nil
}

View file

@ -73,6 +73,9 @@ server_address = "https://example.com/pulp"
want: &workerConfig{
BasePath: "/api/image-builder-worker/v1",
DNFJson: "/usr/libexec/dnf-json",
OSBuildExecutor: &executorConfig{
Type: "host",
},
Composer: &composerConfig{
Proxy: "http://proxy.example.com",
},
@ -131,6 +134,9 @@ server_address = "https://example.com/pulp"
config: ``,
want: &workerConfig{
BasePath: "/api/worker/v1",
OSBuildExecutor: &executorConfig{
Type: "host",
},
},
},
}