user

package
v0.0.0-...-215933a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = fmt.Errorf("user: not supported on this system")

ErrUnsupported is used when a system is not supported

Functions

This section is empty.

Types

type AddUserOptions

type AddUserOptions struct {
	UID       string
	Group     string
	Comment   string
	Directory string
}

AddUserOptions are the options specified in the configuration to be used when adding a user

func SetAddUserOptions

func SetAddUserOptions(u *User) *AddUserOptions

SetAddUserOptions returns a AddUserOptions struct with the options specified in the configuration for adding a user

type Preparer

type Preparer struct {
	// Username is the user login name.
	Username string `hcl:"username" required:"true"`

	// UID is the user ID.
	UID *uint32 `hcl:"uid"`

	// GroupName is the primary group for user and must already exist.
	// Only one of GID or Groupname may be indicated.
	GroupName string `hcl:"groupname" mutually_exclusive:"gid,groupname"`

	// Gid is the primary group ID for user and must refer to an existing group.
	// Only one of GID or Groupname may be indicated.
	GID *uint32 `hcl:"gid" mutually_exclusive:"gid,groupname"`

	// Name is the user description.
	Name string `hcl:"name"`

	// HomeDir is the user's login directory. By default,  the login
	// name is appended to the home directory.
	HomeDir string `hcl:"home_dir"`

	// State is whether the user should be present.
	State State `hcl:"state" valid_values:"present,absent"`
}

Preparer for User

User renders user data

func (*Preparer) Prepare

func (p *Preparer) Prepare(render resource.Renderer) (resource.Task, error)

Prepare a new task

type State

type State string

State type for User

const (
	// StatePresent indicates the user should be present
	StatePresent State = "present"

	// StateAbsent indicates the user should be absent
	StateAbsent State = "absent"
)

type System

type System struct{}

System implements SystemUtils

func (*System) AddUser

func (s *System) AddUser(userName string, options *AddUserOptions) error

AddUser adds a user

func (*System) DelUser

func (s *System) DelUser(userName string) error

DelUser deletes a user

func (*System) Lookup

func (s *System) Lookup(userName string) (*user.User, error)

Lookup looks up a user by name If the user cannot be found an error is returned

func (*System) LookupGroup

func (s *System) LookupGroup(groupName string) (*user.Group, error)

LookupGroup looks up a group by name If the group cannot be found an error is returned

func (*System) LookupGroupID

func (s *System) LookupGroupID(groupID string) (*user.Group, error)

LookupGroupID looks up a group by gid If the group cannot be found an error is returned

func (*System) LookupID

func (s *System) LookupID(userID string) (*user.User, error)

LookupID looks up a user by uid If the user cannot be found an error is returned

type SystemUtils

type SystemUtils interface {
	AddUser(userName string, options *AddUserOptions) error
	DelUser(userName string) error
	Lookup(userName string) (*user.User, error)
	LookupID(userID string) (*user.User, error)
	LookupGroup(groupName string) (*user.Group, error)
	LookupGroupID(groupID string) (*user.Group, error)
}

SystemUtils provides system utilities for user

type User

type User struct {
	Username  string
	UID       string
	GroupName string
	GID       string
	Name      string
	HomeDir   string
	State     State
	// contains filtered or unexported fields
}

User manages user users

func NewUser

func NewUser(system SystemUtils) *User

NewUser constructs and returns a new User

func (*User) Apply

func (u *User) Apply() (resource.TaskStatus, error)

Apply changes for user

func (*User) Check

Check if a user user exists

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL