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 <mheon@redhat.com>

Closes: #828
Approved by: mheon
This commit is contained in:
Matthew Heon
2018-05-24 10:41:56 -04:00
committed by Atomic Bot
parent c8b72e57a7
commit de13777e71
2 changed files with 12 additions and 4 deletions

View File

@ -84,9 +84,13 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
importBuilder.SetCmd(c.config.Command) importBuilder.SetCmd(c.config.Command)
// Env // Env
for _, e := range c.config.Spec.Process.Env { // TODO - this includes all the default environment vars as well
splitEnv := strings.Split(e, "=") // Should we store the ENV we actually want in the spec separately?
importBuilder.SetEnv(splitEnv[0], splitEnv[1]) 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 // Expose ports
for _, p := range c.config.PortMappings { for _, p := range c.config.PortMappings {

View File

@ -13,7 +13,11 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data)
runtimeInfo := c.state runtimeInfo := c.state
spec := c.config.Spec 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 var path string
if len(args) > 0 { if len(args) > 0 {
path = args[0] path = args[0]