Skip to content

Commit 7fd24be

Browse files
johnstcnmafredri
andauthored
Apply suggestions from code review
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
1 parent e76af04 commit 7fd24be

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

agent/agentcontainers/containers_dockercli.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func EnvInfo(ctx context.Context, execer agentexec.Execer, container, containerU
9898
// Parse the output of /etc/passwd. It looks like this:
9999
// postgres:x:999:999::/var/lib/postgresql:/bin/bash
100100
passwdFields := strings.Split(foundLine, ":")
101-
if len(passwdFields) < 7 {
101+
if len(passwdFields) != 7 {
102102
return nil, xerrors.Errorf("get container user: invalid line in /etc/passwd: %q", foundLine)
103103
}
104104

@@ -144,14 +144,8 @@ func EnvInfo(ctx context.Context, execer agentexec.Execer, container, containerU
144144

145145
func (dei *ContainerEnvInfoer) CurrentUser() (*user.User, error) {
146146
// Clone the user so that the caller can't modify it
147-
u := &user.User{
148-
Gid: dei.user.Gid,
149-
HomeDir: dei.user.HomeDir,
150-
Name: dei.user.Name,
151-
Uid: dei.user.Uid,
152-
Username: dei.user.Username,
153-
}
154-
return u, nil
147+
u := *dei.user
148+
return &u, nil
155149
}
156150

157151
func (dei *ContainerEnvInfoer) Environ() []string {

0 commit comments

Comments
 (0)