From 523289509ec7acd4e6ff5f9fc2f07c30ff24d48c Mon Sep 17 00:00:00 2001 From: Kristof Lemmens Date: Wed, 13 Apr 2022 09:43:24 +0200 Subject: [PATCH 1/2] Only process config-dir when config-dir is not empty --- config/config.go | 68 ++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/config/config.go b/config/config.go index 8a4b896..efa90e0 100644 --- a/config/config.go +++ b/config/config.go @@ -174,46 +174,46 @@ func ReadConfigFile(configFile string, configDir string, inputPrefix, outputPref return nil, fmt.Errorf("could not parse config file %q: %w", absConfigFile, err) } - _, err = os.Stat(util.AbsolutePath(inputPrefix, configDir)) - if configDir != "" && os.IsNotExist(err) { - zlog.Error().Err(err).Msg("config directory doesn't exist") - - } else { - items, err := ioutil.ReadDir(util.AbsolutePath(inputPrefix, configDir)) - if err != nil { - log.Error().Err(err).Msg("Error reading directory") - return nil, fmt.Errorf("could not read config directory %q: %w", configDir, err) - } - for _, item := range items { - fileExtension := filepath.Ext(item.Name()) - if (fileExtension == ".yaml" || fileExtension == ".yml") && !item.IsDir() { - - currentConfigFile := util.AbsolutePath(inputPrefix, configDir) + "/" + item.Name() - log.Debug().Msg("reading config file " + currentConfigFile) - yamlFile, err := ioutil.ReadFile(currentConfigFile) - if err != nil { - log.Error().Err(err).Msg("could not read config file") - return nil, fmt.Errorf("trouble reading config file %q: %w", currentConfigFile, err) - } + if configDir != "" { + _, err = os.Stat(util.AbsolutePath(inputPrefix, configDir)) - currentConfig, err := ReadConfig(log, yamlFile, inputPrefix, outputPrefix) - config.VaultConfig.Secrets = append(config.VaultConfig.Secrets, currentConfig.VaultConfig.Secrets...) - config.VaultConfig.Templates = append(config.VaultConfig.Templates, currentConfig.VaultConfig.Templates...) - config.VaultConfig.SSHCertificates = append(config.VaultConfig.SSHCertificates, currentConfig.VaultConfig.SSHCertificates...) - config.VaultConfig.AWS = append(config.VaultConfig.AWS, currentConfig.VaultConfig.AWS...) - for k, v := range currentConfig.Templates { - config.Templates[k] = v - } - for k, v := range currentConfig.Composites { - config.Composites[k] = v + if os.IsNotExist(err) { + zlog.Error().Err(err).Msg("config directory doesn't exist") + } else { + + items, err := ioutil.ReadDir(util.AbsolutePath(inputPrefix, configDir)) + if err != nil { + log.Error().Err(err).Msg("Error reading directory") + return nil, fmt.Errorf("could not read config directory %q: %w", configDir, err) + } + for _, item := range items { + fileExtension := filepath.Ext(item.Name()) + if (fileExtension == ".yaml" || fileExtension == ".yml") && !item.IsDir() { + + currentConfigFile := util.AbsolutePath(inputPrefix, configDir) + "/" + item.Name() + log.Debug().Msg("reading config file " + currentConfigFile) + yamlFile, err := ioutil.ReadFile(currentConfigFile) + if err != nil { + log.Error().Err(err).Msg("could not read config file") + return nil, fmt.Errorf("trouble reading config file %q: %w", currentConfigFile, err) + } + + currentConfig, err := ReadConfig(log, yamlFile, inputPrefix, outputPrefix) + config.VaultConfig.Secrets = append(config.VaultConfig.Secrets, currentConfig.VaultConfig.Secrets...) + config.VaultConfig.Templates = append(config.VaultConfig.Templates, currentConfig.VaultConfig.Templates...) + config.VaultConfig.SSHCertificates = append(config.VaultConfig.SSHCertificates, currentConfig.VaultConfig.SSHCertificates...) + config.VaultConfig.AWS = append(config.VaultConfig.AWS, currentConfig.VaultConfig.AWS...) + for k, v := range currentConfig.Templates { + config.Templates[k] = v + } + for k, v := range currentConfig.Composites { + config.Composites[k] = v + } } - } } } - return config, err - } // createCompositeSecrets brings an obscure feature of v1 where multiple secret stanzas could From 1971f0f6b56c55ded688478913f84e96dd1ac690 Mon Sep 17 00:00:00 2001 From: Kristof Lemmens Date: Thu, 14 Apr 2022 20:26:33 +0200 Subject: [PATCH 2/2] Update version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 27be368..78beab9 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CURRENTOS := $(shell go env GOOS) CURRENTARCH := $(shell go env GOARCH) COMMIT := $(shell git rev-parse --short HEAD) -VERSION := v1.3.5 +VERSION := v1.3.6 LDFLAGS="-X main.buildVersion=$(VERSION) -X main.commitVersion=$(COMMIT)" .DEFAULT_GOAL := build