From 9e850506334f87906442ed33d314a4d8f5e40f5b Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Thu, 25 Jan 2024 15:16:00 +0100 Subject: [PATCH] osbuild-worker: add `osbuild_executor` config option --- cmd/osbuild-worker/config.go | 16 ++++++++++++++++ cmd/osbuild-worker/config_test.go | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/cmd/osbuild-worker/config.go b/cmd/osbuild-worker/config.go index e48bacb23..63717c47e 100644 --- a/cmd/osbuild-worker/config.go +++ b/cmd/osbuild-worker/config.go @@ -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 } diff --git a/cmd/osbuild-worker/config_test.go b/cmd/osbuild-worker/config_test.go index 7e0e94746..0fda6c68e 100644 --- a/cmd/osbuild-worker/config_test.go +++ b/cmd/osbuild-worker/config_test.go @@ -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", + }, }, }, }