Skip to content

Commit

Permalink
cmd/oci-image-tool: fix config.json generation
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
  • Loading branch information
runcom committed Jul 22, 2016
1 parent 0e8f74b commit 116950e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions image/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,18 @@ func (c *config) runtimeSpec(rootfs string) (*specs.Spec, error) {
var s specs.Spec
s.Version = "0.5.0"
s.Root.Path = rootfs
s.Process.Cwd = c.Config.WorkingDir
s.Process.Env = append([]string(nil), c.Config.Env...)
s.Process.Args = append([]string(nil), c.Config.Entrypoint...)
s.Process.Cwd = "/"
if c.Config.WorkingDir != "" {
s.Process.Cwd = c.Config.WorkingDir
}
s.Process.Env = append(s.Process.Env, c.Config.Env...)
s.Process.Args = append(s.Process.Env, c.Config.Entrypoint...)
s.Process.Args = append(s.Process.Args, c.Config.Cmd...)

if len(s.Process.Args) == 0 {
s.Process.Args = append(s.Process.Args, "sh")
}

if uid, err := strconv.Atoi(c.Config.User); err == nil {
s.Process.User.UID = uint32(uid)
} else if ug := strings.Split(c.Config.User, ":"); len(ug) == 2 {
Expand All @@ -118,7 +125,7 @@ func (c *config) runtimeSpec(rootfs string) (*specs.Spec, error) {

s.Process.User.UID = uint32(uid)
s.Process.User.GID = uint32(gid)
} else {
} else if c.Config.User != "" {
return nil, errors.New("config.User: unsupported format")
}

Expand Down

0 comments on commit 116950e

Please sign in to comment.