From c4dcd96adbd97d3aeb2399e41444e7016e8d6b6c Mon Sep 17 00:00:00 2001 From: Tom Coupland Date: Wed, 12 Sep 2018 07:27:32 +0100 Subject: [PATCH] Adds key existence check to config equality (#1204) The config equality test doesn't check that keys exist between config maps. Meaning that when two maps, both with a single, yet differing key, with the lefts value being "", the default string, are compared they are considered equal. This change uses the two value assignment version of the map get, allowing it to test for key existence. --- api/models/config.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/models/config.go b/api/models/config.go index 52114a532..356ddcd71 100644 --- a/api/models/config.go +++ b/api/models/config.go @@ -20,8 +20,7 @@ func (c1 Config) Equals(c2 Config) bool { return false } for k1, v1 := range c1 { - v2, _ := c2[k1] - if v1 != v2 { + if v2, ok := c2[k1]; !ok || v1 != v2 { return false } }