Skip to content

Commit

Permalink
Use switch when determining the onboarding strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
damyan committed Oct 25, 2024
1 parent 1eaa706 commit f3a73d4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/metal/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ 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 {
if i.MacAddress != "" && i.Name != "" {
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 != "" {
Expand All @@ -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
}
Expand Down

0 comments on commit f3a73d4

Please sign in to comment.