Skip to content

Commit

Permalink
elemental-operator register: support config files in /oem subdirectories
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
fgiudici committed Jul 22, 2022
1 parent 9b9844b commit 1c7625d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/operator/register/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1c7625d

Please sign in to comment.