Merge pull request #2554 from quiye/ResMap

Fix length checking for ResMap resources
This commit is contained in:
Jeff Regan
2020-06-05 14:06:37 -07:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -532,7 +532,7 @@ func (m *resWrangler) ErrorIfNotEqualSets(other ResMap) error {
for _, r1 := range m.rList { for _, r1 := range m.rList {
id := r1.CurId() id := r1.CurId()
others := m2.GetMatchingResourcesByCurrentId(id.Equals) others := m2.GetMatchingResourcesByCurrentId(id.Equals)
if len(others) < 0 { if len(others) == 0 {
return fmt.Errorf( return fmt.Errorf(
"id in self missing from other; id: %s", id) "id in self missing from other; id: %s", id)
} }

View File

@@ -669,7 +669,12 @@ func TestErrorIfNotEqualSets(t *testing.T) {
t.Fatalf("%v should not equal %v %v", m1, m2, err) t.Fatalf("%v should not equal %v %v", m1, m2, err)
} }
m3 := resmaptest_test.NewRmBuilder(t, rf).Add( m3 := resmaptest_test.NewRmBuilder(t, rf).AddR(r2).ResMap()
if err := m2.ErrorIfNotEqualSets(m3); err == nil {
t.Fatalf("%v should not equal %v %v", m2, m3, err)
}
m3 = resmaptest_test.NewRmBuilder(t, rf).Add(
map[string]interface{}{ map[string]interface{}{
"apiVersion": "v1", "apiVersion": "v1",
"kind": "ConfigMap", "kind": "ConfigMap",