Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

Commit 3b32ef8

Browse files
committed
Merge pull request #357 from mpuncel/mpuncel/dont-return-nil-config
Instantiate empty config map in GetConfig() if necessary
2 parents 2406a71 + 6e764ad commit 3b32ef8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/pods/manifest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ func (manifest *manifest) SetLaunchables(launchableStanzas map[string]Launchable
125125
}
126126

127127
func (manifest *manifest) GetConfig() map[interface{}]interface{} {
128+
if manifest.Config == nil {
129+
return make(map[interface{}]interface{})
130+
}
128131
return manifest.Config
129132
}
130133

pkg/pods/manifest_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,10 @@ config:
223223
builtManifest := builder.GetManifest()
224224
Assert(t).AreEqual(builtManifest.ID(), "thepod", "Expected manifest ID to be preserved when converted to ManifestBuilder and back")
225225
}
226+
227+
func TestGetConfigInitializesIfEmpty(t *testing.T) {
228+
builder := NewManifestBuilder()
229+
manifest := builder.GetManifest()
230+
config := manifest.GetConfig()
231+
Assert(t).IsNotNil(config, "Expected returned config to be instantiated by GetConfig() if not set")
232+
}

0 commit comments

Comments
 (0)