From de13777e71c73cca85c1a69d69da27299be9a269 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 24 May 2018 10:41:56 -0400 Subject: Make references to the Process part of Spec conditional The OCI runtime spec does not require Process to be passed (IE, it can be nil). Make most of our references to it conditional on it existing. Signed-off-by: Matthew Heon Closes: #828 Approved by: mheon --- libpod/container_commit.go | 10 +++++++--- libpod/container_inspect.go | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'libpod') diff --git a/libpod/container_commit.go b/libpod/container_commit.go index 9aa5f407f..8cb04ec1a 100644 --- a/libpod/container_commit.go +++ b/libpod/container_commit.go @@ -84,9 +84,13 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai importBuilder.SetCmd(c.config.Command) // Env - for _, e := range c.config.Spec.Process.Env { - splitEnv := strings.Split(e, "=") - importBuilder.SetEnv(splitEnv[0], splitEnv[1]) + // TODO - this includes all the default environment vars as well + // Should we store the ENV we actually want in the spec separately? + if c.config.Spec.Process != nil { + for _, e := range c.config.Spec.Process.Env { + splitEnv := strings.Split(e, "=") + importBuilder.SetEnv(splitEnv[0], splitEnv[1]) + } } // Expose ports for _, p := range c.config.PortMappings { diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index 6b62a3f44..c8bf1a8cd 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -13,7 +13,11 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data) runtimeInfo := c.state spec := c.config.Spec - args := config.Spec.Process.Args + // Process is allowed to be nil in the spec + args := []string{} + if config.Spec.Process != nil { + args = config.Spec.Process.Args + } var path string if len(args) > 0 { path = args[0] -- cgit v1.2.3-54-g00ecf