From 236d8df84f9f248f58e358448898529d7b81dfc0 Mon Sep 17 00:00:00 2001 From: Tyler Cipriani Date: Fri, 16 Nov 2018 16:42:41 -0700 Subject: Fix entrypoint merge behavior Ensure that the CommonConfig being merged can override the Entrypoint. Change-Id: Icff4876e632d0bd590d63e72dccb4d67c8d1a435 --- config/common.go | 2 +- config/common_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/config/common.go b/config/common.go index 32311b8..90c9c5b 100644 --- a/config/common.go +++ b/config/common.go @@ -32,7 +32,7 @@ func (cc *CommonConfig) Merge(cc2 CommonConfig) { cc.Lives.Merge(cc2.Lives) cc.Runs.Merge(cc2.Runs) - if len(cc.EntryPoint) < 1 { + if cc2.EntryPoint != nil { cc.EntryPoint = cc2.EntryPoint } } diff --git a/config/common_test.go b/config/common_test.go index ba9333e..d22bcff 100644 --- a/config/common_test.go +++ b/config/common_test.go @@ -27,6 +27,15 @@ func TestCommonConfigYAML(t *testing.T) { assert.Equal(t, []string{"/bin/foo"}, variant.EntryPoint) } +// Ensure that entrypoints inherit correctly +// +func TestEntryPointMerge(t *testing.T) { + foo := config.CommonConfig{EntryPoint: []string{"/bin/foo"}} + bar := config.CommonConfig{EntryPoint: []string{"/bin/bar"}} + foo.Merge(bar) + assert.Equal(t, []string{"/bin/bar"}, foo.EntryPoint) +} + func TestCommonConfigValidation(t *testing.T) { t.Run("base", func(t *testing.T) { t.Run("ok", func(t *testing.T) { -- cgit v1.2.1