Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUserDoesNotExist = errors.New("user does not exist")
ErrUserDoesNotExist is returned by GetLinuxUser if a linux user does not exist yet.
var ErrUserOrGroupAlreadyExists = errors.New("user or group already exists")
ErrUserOrGroupAlreadyExists is the Go error converted from the result of useradd or groupadd when an user or group already exists.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Password string
UID string
GID string
GECOS string
Directory string
Shell string
}
Entry is an entry of a '/etc/passwd' file.
type LinuxUserManager ¶
LinuxUserManager can retrieve information on linux users and create new users.
func NewLinuxUserManager ¶
func NewLinuxUserManager(fs afero.Fs) LinuxUserManager
NewLinuxUserManager creates a new LinuxUserManager.
func NewLinuxUserManagerFake ¶
func NewLinuxUserManagerFake(fs afero.Fs) LinuxUserManager
NewLinuxUserManagerFake creates a new LinuxUserManager that is used for unit tests.
func (*LinuxUserManager) EnsureLinuxUserExists ¶
func (l *LinuxUserManager) EnsureLinuxUserExists(ctx context.Context, username string) (LinuxUser, error)
EnsureLinuxUserExists will try to create the user specified by username and call GetLinuxUser to retrieve user information.
func (*LinuxUserManager) GetLinuxUser ¶
func (l *LinuxUserManager) GetLinuxUser(username string) (LinuxUser, error)
GetLinuxUser tries to find an existing linux user in /etc/passwd.
type Passwd ¶
type Passwd struct{}
Passwd allows to parse users from '/etc/passwd' on the local system.
type StubUserCreator ¶
type StubUserCreator struct {
// contains filtered or unexported fields
}
StubUserCreator is used for unit tests.
func (*StubUserCreator) CreateUser ¶
func (s *StubUserCreator) CreateUser(ctx context.Context, username string) error
CreateUser for StubUserCreator creates an user for an unit test environment.
func (*StubUserCreator) CreateUserWithSpecificUIDAndGID ¶
func (s *StubUserCreator) CreateUserWithSpecificUIDAndGID(ctx context.Context, username string, uid int, gid int) error
CreateUserWithSpecificUIDAndGID for StubUserCreator creates an user with a specific UID and GID for an unit test environment.
type Unix ¶
type Unix struct{}
Unix defines an user creation interface for UNIX systems.
func (Unix) CreateUser ¶
CreateUser creates a new user with sudo access.