From f3a73d4ff696fc90d78b737d8acf0ddc1d8de939 Mon Sep 17 00:00:00 2001 From: Damyan Yordanov Date: Fri, 25 Oct 2024 16:52:36 +0200 Subject: [PATCH] Use switch when determining the onboarding strategy --- plugins/metal/plugin.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/metal/plugin.go b/plugins/metal/plugin.go index 41f0bc8..cb7cc5a 100644 --- a/plugins/metal/plugin.go +++ b/plugins/metal/plugin.go @@ -95,8 +95,9 @@ func loadConfig(args ...string) (*Inventory, error) { inv := &Inventory{} entries := make(map[string]string) + switch { // static inventory list has precedence, always - if len(config.Inventories) > 0 { + case len(config.Inventories) > 0: inv.Strategy = OnBoardingStrategyStatic log.Debug("Using static list onboarding") for _, i := range config.Inventories { @@ -104,7 +105,7 @@ func loadConfig(args ...string) (*Inventory, error) { entries[strings.ToLower(i.MacAddress)] = i.Name } } - } else if len(config.Filter.MacPrefix) > 0 { + case len(config.Filter.MacPrefix) > 0: inv.Strategy = OnboardingStrategyDynamic namePrefix := defaultNamePrefix if config.NamePrefix != "" { @@ -114,7 +115,7 @@ func loadConfig(args ...string) (*Inventory, error) { for _, i := range config.Filter.MacPrefix { entries[strings.ToLower(i)] = namePrefix } - } else { + default: log.Infof("No inventories loaded") return nil, nil }