From dc78b05a19254085003546e3b089e954f8001e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Tue, 28 Jun 2022 13:22:25 +0200 Subject: [PATCH] worker: flip error handling when parsing the config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's more idiomatic this way. Signed-off-by: Ondřej Budai --- cmd/osbuild-worker/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/osbuild-worker/main.go b/cmd/osbuild-worker/main.go index 20c8af017..f2b111f1e 100644 --- a/cmd/osbuild-worker/main.go +++ b/cmd/osbuild-worker/main.go @@ -215,17 +215,17 @@ func main() { } config, err := parseConfig(configFile) - if err == nil { - logrus.Info("Composer configuration:") - encoder := toml.NewEncoder(logrus.StandardLogger().WriterLevel(logrus.InfoLevel)) - err := encoder.Encode(&config) - if err != nil { - logrus.Fatalf("Could not print config: %v", err) - } - } else { + if err != nil { logrus.Fatalf("Could not load config file '%s': %v", configFile, err) } + logrus.Info("Composer configuration:") + encoder := toml.NewEncoder(logrus.StandardLogger().WriterLevel(logrus.InfoLevel)) + err = encoder.Encode(&config) + if err != nil { + logrus.Fatalf("Could not print config: %v", err) + } + cacheDirectory, ok := os.LookupEnv("CACHE_DIRECTORY") if !ok { logrus.Fatal("CACHE_DIRECTORY is not set. Is the service file missing CacheDirectory=?")