Skip to content

Commit 46a6b7d

Browse files
committed
simply naming of interface methods
1 parent 50f1c7f commit 46a6b7d

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

agent/agentcontainers/containers_dockercli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ func EnvInfo(ctx context.Context, execer agentexec.Execer, container, containerU
128128
return &dei, nil
129129
}
130130

131-
func (dei *DockerEnvInfoer) CurrentUser() (*user.User, error) {
131+
func (dei *DockerEnvInfoer) User() (*user.User, error) {
132132
// Clone the user so that the caller can't modify it
133133
u := *dei.user
134134
return &u, nil
135135
}
136136

137-
func (dei *DockerEnvInfoer) UserShell(string) (string, error) {
137+
func (dei *DockerEnvInfoer) Shell(string) (string, error) {
138138
return dei.userShell, nil
139139
}
140140

agent/agentcontainers/containers_internal_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,15 +502,15 @@ func TestDockerEnvInfoer(t *testing.T) {
502502
dei, err := EnvInfo(ctx, agentexec.DefaultExecer, ct.Container.ID, tt.containerUser)
503503
require.NoError(t, err, "Expected no error from DockerEnvInfo()")
504504

505-
u, err := dei.CurrentUser()
505+
u, err := dei.User()
506506
require.NoError(t, err, "Expected no error from CurrentUser()")
507507
require.Equal(t, tt.expectedUsername, u.Username, "Expected username to match")
508508

509-
hd, err := dei.UserHomeDir()
509+
hd, err := dei.HomeDir()
510510
require.NoError(t, err, "Expected no error from UserHomeDir()")
511511
require.NotEmpty(t, hd, "Expected user homedir to be non-empty")
512512

513-
sh, err := dei.UserShell(tt.containerUser)
513+
sh, err := dei.Shell(tt.containerUser)
514514
require.NoError(t, err, "Expected no error from UserShell()")
515515
require.Equal(t, tt.expectedUserShell, sh, "Expected user shell to match")
516516

agent/agentssh/agentssh.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,13 @@ func (s *Server) CreateCommand(ctx context.Context, script string, env []string,
709709
if ei == nil {
710710
ei = &usershell.SystemEnvInfo{}
711711
}
712-
currentUser, err := ei.CurrentUser()
712+
currentUser, err := ei.User()
713713
if err != nil {
714714
return nil, xerrors.Errorf("get current user: %w", err)
715715
}
716716
username := currentUser.Username
717717

718-
shell, err := ei.UserShell(username)
718+
shell, err := ei.Shell(username)
719719
if err != nil {
720720
return nil, xerrors.Errorf("get user shell: %w", err)
721721
}
@@ -777,7 +777,7 @@ func (s *Server) CreateCommand(ctx context.Context, script string, env []string,
777777
_, err = os.Stat(cmd.Dir)
778778
if cmd.Dir == "" || err != nil {
779779
// Default to user home if a directory is not set.
780-
homedir, err := ei.UserHomeDir()
780+
homedir, err := ei.HomeDir()
781781
if err != nil {
782782
return nil, xerrors.Errorf("get home dir: %w", err)
783783
}

agent/agentssh/agentssh_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,19 @@ type fakeEnvInfoer struct {
124124
UserShellFn func(string) (string, error)
125125
}
126126

127-
func (f *fakeEnvInfoer) CurrentUser() (u *user.User, err error) {
127+
func (f *fakeEnvInfoer) User() (u *user.User, err error) {
128128
return f.CurrentUserFn()
129129
}
130130

131131
func (f *fakeEnvInfoer) Environ() []string {
132132
return f.EnvironFn()
133133
}
134134

135-
func (f *fakeEnvInfoer) UserHomeDir() (string, error) {
135+
func (f *fakeEnvInfoer) HomeDir() (string, error) {
136136
return f.UserHomeDirFn()
137137
}
138138

139-
func (f *fakeEnvInfoer) UserShell(u string) (string, error) {
139+
func (f *fakeEnvInfoer) Shell(u string) (string, error) {
140140
return f.UserShellFn(u)
141141
}
142142

agent/usershell/usershell.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ func HomeDir() (string, error) {
2626

2727
// EnvInfoer encapsulates external information about the environment.
2828
type EnvInfoer interface {
29-
// CurrentUser returns the current user.
30-
CurrentUser() (*user.User, error)
29+
// User returns the current user.
30+
User() (*user.User, error)
3131
// Environ returns the environment variables of the current process.
3232
Environ() []string
33-
// UserHomeDir returns the home directory of the current user.
34-
UserHomeDir() (string, error)
35-
// UserShell returns the shell of the given user.
36-
UserShell(username string) (string, error)
33+
// HomeDir returns the home directory of the current user.
34+
HomeDir() (string, error)
35+
// Shell returns the shell of the given user.
36+
Shell(username string) (string, error)
3737
// ModifyCommand modifies the command and arguments before execution based on
3838
// the environment. This is useful for executing a command inside a container.
3939
// In the default case, the command and arguments are returned unchanged.
@@ -44,19 +44,19 @@ type EnvInfoer interface {
4444
// just using the default Go implementations.
4545
type SystemEnvInfo struct{}
4646

47-
func (SystemEnvInfo) CurrentUser() (*user.User, error) {
47+
func (SystemEnvInfo) User() (*user.User, error) {
4848
return user.Current()
4949
}
5050

5151
func (SystemEnvInfo) Environ() []string {
5252
return os.Environ()
5353
}
5454

55-
func (SystemEnvInfo) UserHomeDir() (string, error) {
55+
func (SystemEnvInfo) HomeDir() (string, error) {
5656
return HomeDir()
5757
}
5858

59-
func (SystemEnvInfo) UserShell(username string) (string, error) {
59+
func (SystemEnvInfo) Shell(username string) (string, error) {
6060
return Get(username)
6161
}
6262

0 commit comments

Comments
 (0)