Skip to content

Commit bf5112e

Browse files
authored
Merge pull request containerd#2259 from Random-Liu/cleanup-with-user
Improve WithUser comments and code style.
2 parents 1a9f9e6 + 00b600a commit bf5112e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

oci/spec_opts_unix.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ func WithNamespacedCgroup() SpecOpts {
234234
}
235235
}
236236

237-
// WithUser accepts a valid user string in OCI Image Spec v1.0.0:
237+
// WithUser sets the user to be used within the container.
238+
// It accepts a valid user string in OCI Image Spec v1.0.0:
238239
// user, uid, user:group, uid:gid, uid:group, user:gid
239-
// and set the correct UID and GID for container.
240240
func WithUser(userstr string) SpecOpts {
241241
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) error {
242242
parts := strings.Split(userstr, ":")
@@ -249,7 +249,10 @@ func WithUser(userstr string) SpecOpts {
249249
}
250250
return WithUserID(uint32(v))(ctx, client, c, s)
251251
case 2:
252-
var username, groupname string
252+
var (
253+
username string
254+
groupname string
255+
)
253256
var uid, gid uint32
254257
v, err := strconv.Atoi(parts[0])
255258
if err != nil {

0 commit comments

Comments
 (0)