This commit is contained in:
Tom Lanyon 2017-11-09 09:27:13 +00:00 committed by GitHub
commit 5caf3d7c5d
2 changed files with 24 additions and 1 deletions

View file

@ -51,7 +51,7 @@ func mergeLocationAnnotations(loc *ingress.Location, anns map[string]interface{}
loc.Denied = anns[DeniedKeyName].(error)
}
delete(anns, DeniedKeyName)
err := mergo.Map(loc, anns)
err := mergo.MapWithOverwrite(loc, anns)
if err != nil {
glog.Errorf("unexpected error merging extracted annotations in location type: %v", err)
}

View file

@ -82,6 +82,29 @@ func TestMergeLocationAnnotations(t *testing.T) {
}
}
func TestMergeLocationAnnotationsExisting(t *testing.T) {
loc := ingress.Location{
IsDefBackend: true,
Proxy: proxy.Configuration{ReadTimeout: 60},
}
annotations := map[string]interface{}{
"Proxy": proxy.Configuration{ReadTimeout: 999},
}
mergeLocationAnnotations(&loc, annotations)
// Existing value should be unmodified.
if got, want := loc.IsDefBackend, true; got != want {
t.Errorf("loc.IsDefBackend = %v, want %v", got, want)
}
// New value from annotation should be updated.
if got, want := loc.Proxy.ReadTimeout, annotations["Proxy"].(proxy.Configuration).ReadTimeout; got != want {
t.Errorf("loc.Proxy.ReadTimeout = %v, want %v", got, want)
}
}
func TestIntInSlice(t *testing.T) {
fooTests := []struct {
i int