Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve WithUser comments and code style. #2259

Merged
merged 1 commit into from Mar 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions oci/spec_opts_unix.go
Expand Up @@ -234,9 +234,9 @@ func WithNamespacedCgroup() SpecOpts {
}
}

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