Skip to content

Commit 9b4d14c

Browse files
peterebdenpebers
andauthored
Filter SSM items to require a name (#18)
Co-authored-by: pebers <[email protected]>
1 parent 3ea2eda commit 9b4d14c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Diff for: read_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ func TestStringStringMapSection(t *testing.T) {
488488
if val, present := res.Section["key3"]; !present || val != "" {
489489
t.Errorf("res.Section.Name=%q present=%v; want %q", res.Section["key3"], present, "")
490490
}
491+
if len(res.Section) != 3 {
492+
t.Errorf("Wrong number of items in section; expected 3, got %d", len(res.Section))
493+
}
491494
}
492495

493496
func TestFatalOnly(t *testing.T) {

Diff for: set.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ func set(c *warnings.Collector, cfg interface{}, sect, sub, name string,
239239
if vSect.IsNil() {
240240
vSect.Set(reflect.MakeMap(vst))
241241
}
242-
if sub != "" {
243-
vSect.SetMapIndex(reflect.ValueOf(sub+" "+name), reflect.ValueOf(value))
244-
} else {
245-
vSect.SetMapIndex(reflect.ValueOf(name), reflect.ValueOf(value))
242+
if name != "" {
243+
if sub != "" {
244+
vSect.SetMapIndex(reflect.ValueOf(sub+" "+name), reflect.ValueOf(value))
245+
} else {
246+
vSect.SetMapIndex(reflect.ValueOf(name), reflect.ValueOf(value))
247+
}
246248
}
247249
return nil
248250
}

0 commit comments

Comments
 (0)