Skip to content

Commit

Permalink
Filter SSM items to require a name (#18)
Browse files Browse the repository at this point in the history
Co-authored-by: pebers <[email protected]>
  • Loading branch information
peterebden and pebers authored Jun 17, 2022
1 parent 3ea2eda commit 9b4d14c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ func TestStringStringMapSection(t *testing.T) {
if val, present := res.Section["key3"]; !present || val != "" {
t.Errorf("res.Section.Name=%q present=%v; want %q", res.Section["key3"], present, "")
}
if len(res.Section) != 3 {
t.Errorf("Wrong number of items in section; expected 3, got %d", len(res.Section))
}
}

func TestFatalOnly(t *testing.T) {
Expand Down
10 changes: 6 additions & 4 deletions set.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ func set(c *warnings.Collector, cfg interface{}, sect, sub, name string,
if vSect.IsNil() {
vSect.Set(reflect.MakeMap(vst))
}
if sub != "" {
vSect.SetMapIndex(reflect.ValueOf(sub+" "+name), reflect.ValueOf(value))
} else {
vSect.SetMapIndex(reflect.ValueOf(name), reflect.ValueOf(value))
if name != "" {
if sub != "" {
vSect.SetMapIndex(reflect.ValueOf(sub+" "+name), reflect.ValueOf(value))
} else {
vSect.SetMapIndex(reflect.ValueOf(name), reflect.ValueOf(value))
}
}
return nil
}
Expand Down

0 comments on commit 9b4d14c

Please sign in to comment.