From 1c7625d51fb475064383ac648b26116bd5b2072e Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Thu, 21 Jul 2022 19:03:46 +0200 Subject: [PATCH] elemental-operator register: support config files in /oem subdirectories We save the registration config.yaml file under /oem/registration dir. The function we use to scan the /oem dir for files was not able to deal with subdirectories: FATA[0000] failed to read config /oem/registration/config.yaml: Config File "config.yaml" Not Found in "[/oem]" Signed-off-by: Francesco Giudici --- cmd/operator/register/root.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/operator/register/root.go b/cmd/operator/register/root.go index 5f05bfdb3..a4a4eab6e 100644 --- a/cmd/operator/register/root.go +++ b/cmd/operator/register/root.go @@ -70,7 +70,11 @@ func NewRegisterCommand() *cobra.Command { for _, arg := range args { viper.AddConfigPath(arg) _ = filepath.WalkDir(arg, func(path string, d fs.DirEntry, err error) error { - if !d.IsDir() && filepath.Ext(d.Name()) == ".yaml" { + if d.IsDir() { + viper.AddConfigPath(path) + return nil + } + if filepath.Ext(d.Name()) == ".yaml" { viper.SetConfigType("yaml") viper.SetConfigName(d.Name()) if err := viper.MergeInConfig(); err != nil {