Merge pull request #815 from Random-Liu/support-cmd-for-sandbox-container

Support `Cmd` for sandbox container.
This commit is contained in:
Lantao Liu 2018-06-12 23:03:55 -07:00 committed by GitHub
commit b39546ce2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -344,9 +344,9 @@ func (c *criService) generateSandboxContainerSpec(id string, config *runtime.Pod
g.SetProcessCwd(imageConfig.WorkingDir) g.SetProcessCwd(imageConfig.WorkingDir)
} }
if len(imageConfig.Entrypoint) == 0 { if len(imageConfig.Entrypoint) == 0 && len(imageConfig.Cmd) == 0 {
// Pause image must have entrypoint. // Pause image must have entrypoint or cmd.
return nil, errors.Errorf("invalid empty entrypoint in image config %+v", imageConfig) return nil, errors.Errorf("invalid empty entrypoint and cmd in image config %+v", imageConfig)
} }
// Set process commands. // Set process commands.
g.SetProcessArgs(append(imageConfig.Entrypoint, imageConfig.Cmd...)) g.SetProcessArgs(append(imageConfig.Entrypoint, imageConfig.Cmd...))

View File

@ -128,9 +128,10 @@ func TestGenerateSandboxContainerSpec(t *testing.T) {
}) })
}, },
}, },
"should return error when entrypoint is empty": { "should return error when entrypoint and cmd are empty": {
imageConfigChange: func(c *imagespec.ImageConfig) { imageConfigChange: func(c *imagespec.ImageConfig) {
c.Entrypoint = nil c.Entrypoint = nil
c.Cmd = nil
}, },
expectErr: true, expectErr: true,
}, },