Skip to content

Commit f4e99f2

Browse files
committed
common: add user provider interface
Like 'FileSystem' and 'CommandExecutor', 'UserProvider' wraps functionality related to the system users in a mockable interface. At the moment, its only function returns the current user, eventually to be used for web server daemon process setup. Signed-off-by: Victoria Dye <[email protected]>
1 parent 6d89cf3 commit f4e99f2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

internal/common/user.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package common
2+
3+
import (
4+
"os/user"
5+
)
6+
7+
type UserProvider interface {
8+
CurrentUser() (*user.User, error)
9+
}
10+
11+
type userProvider struct{}
12+
13+
func NewUserProvider() *userProvider {
14+
return &userProvider{}
15+
}
16+
17+
func (u *userProvider) CurrentUser() (*user.User, error) {
18+
return user.Current()
19+
}

0 commit comments

Comments
 (0)