@@ -102,6 +102,8 @@ func WithImageConfig(image Image) SpecOpts {
102102 }
103103 s .Process .Cwd = cwd
104104 if config .User != "" {
105+ // According to OCI Image Spec v1.0.0, the following are valid for Linux:
106+ // user, uid, user:group, uid:gid, uid:group, user:gid
105107 parts := strings .Split (config .User , ":" )
106108 switch len (parts ) {
107109 case 1 :
@@ -114,6 +116,7 @@ func WithImageConfig(image Image) SpecOpts {
114116 return err
115117 }
116118 case 2 :
119+ // TODO: support username and groupname
117120 v , err := strconv .Atoi (parts [0 ])
118121 if err != nil {
119122 return errors .Wrapf (err , "parse uid %s" , parts [0 ])
@@ -257,6 +260,7 @@ func WithUIDGID(uid, gid uint32) SpecOpts {
257260// uid, and not returns error.
258261func WithUserID (uid uint32 ) SpecOpts {
259262 return func (ctx context.Context , client Client , c * containers.Container , s * specs.Spec ) (err error ) {
263+ // TODO: support non-snapshot rootfs
260264 if c .Snapshotter == "" {
261265 return errors .Errorf ("no snapshotter set for container" )
262266 }
@@ -319,6 +323,7 @@ func WithUserID(uid uint32) SpecOpts {
319323// does not exist, or the username is not found in /etc/passwd,
320324// it returns error.
321325func WithUsername (username string ) SpecOpts {
326+ // TODO: support non-snapshot rootfs
322327 return func (ctx context.Context , client Client , c * containers.Container , s * specs.Spec ) (err error ) {
323328 if c .Snapshotter == "" {
324329 return errors .Errorf ("no snapshotter set for container" )
0 commit comments