Skip to content

Commit

Permalink
Fix index out of range errors when processing the VARS attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonSludge committed Sep 15, 2021
1 parent 7f874de commit 2998abf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,14 @@ func (i *Inventory) GetHostVariables(host string) (map[string]string, error) {
continue
}

pairs := strings.Split(attrs.Vars, cfg.Txt.Vars.Separator)
for _, p := range pairs {
kv := strings.Split(p, cfg.Txt.Vars.Equalsign)
variables[kv[0]] = kv[1]
if len(attrs.Vars) > 0 {
pairs := strings.Split(attrs.Vars, cfg.Txt.Vars.Separator)
for _, p := range pairs {
kv := strings.Split(p, cfg.Txt.Vars.Equalsign)
if len(kv) == 2 {
variables[kv[0]] = kv[1]
}
}
}
}

Expand Down

0 comments on commit 2998abf

Please sign in to comment.