oci: add TODO comments

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2018-01-11 14:11:05 +09:00
parent 369d7c9545
commit b99dc56817

View File

@ -101,6 +101,8 @@ func WithImageConfig(image Image) SpecOpts {
} }
s.Process.Cwd = cwd s.Process.Cwd = cwd
if config.User != "" { if config.User != "" {
// According to OCI Image Spec v1.0.0, the following are valid for Linux:
// user, uid, user:group, uid:gid, uid:group, user:gid
parts := strings.Split(config.User, ":") parts := strings.Split(config.User, ":")
switch len(parts) { switch len(parts) {
case 1: case 1:
@ -113,6 +115,7 @@ func WithImageConfig(image Image) SpecOpts {
return err return err
} }
case 2: case 2:
// TODO: support username and groupname
v, err := strconv.Atoi(parts[0]) v, err := strconv.Atoi(parts[0])
if err != nil { if err != nil {
return errors.Wrapf(err, "parse uid %s", parts[0]) return errors.Wrapf(err, "parse uid %s", parts[0])
@ -256,6 +259,7 @@ func WithUIDGID(uid, gid uint32) SpecOpts {
// uid, and not returns error. // uid, and not returns error.
func WithUserID(uid uint32) SpecOpts { func WithUserID(uid uint32) SpecOpts {
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) (err error) { return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) (err error) {
// TODO: support non-snapshot rootfs
if c.Snapshotter == "" { if c.Snapshotter == "" {
return errors.Errorf("no snapshotter set for container") return errors.Errorf("no snapshotter set for container")
} }
@ -304,6 +308,7 @@ func WithUserID(uid uint32) SpecOpts {
// does not exist, or the username is not found in /etc/passwd, // does not exist, or the username is not found in /etc/passwd,
// it returns error. // it returns error.
func WithUsername(username string) SpecOpts { func WithUsername(username string) SpecOpts {
// TODO: support non-snapshot rootfs
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) (err error) { return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) (err error) {
if c.Snapshotter == "" { if c.Snapshotter == "" {
return errors.Errorf("no snapshotter set for container") return errors.Errorf("no snapshotter set for container")