Documentation ¶
Index ¶
- Constants
- Variables
- type AddUserOptions
- type ModUserOptions
- type Preparer
- type State
- type System
- func (s *System) AddUser(userName string, options *AddUserOptions) error
- func (s *System) DelUser(userName string) error
- func (s *System) Lookup(userName string) (*user.User, error)
- func (s *System) LookupGroup(groupName string) (*user.Group, error)
- func (s *System) LookupGroupID(groupID string) (*user.Group, error)
- func (s *System) LookupID(userID string) (*user.User, error)
- func (s *System) LookupUserExpiry(userName string) (time.Time, error)
- func (s *System) ModUser(userName string, options *ModUserOptions) error
- type SystemUtils
- type User
- func (u *User) Apply(context.Context) (resource.TaskStatus, error)
- func (u *User) Check(context.Context, resource.Renderer) (resource.TaskStatus, error)
- func (u *User) DiffAdd(status *resource.Status) (*AddUserOptions, error)
- func (u *User) DiffDel(status *resource.Status, userByName *user.User, nameNotFound bool) error
- func (u *User) DiffMod(status *resource.Status, currUser *user.User) (*ModUserOptions, error)
Constants ¶
const ( // StatePresent indicates the user should be present StatePresent State = "present" // StateAbsent indicates the user should be absent StateAbsent State = "absent" // ShortForm layout for time parsing ShortForm = "2006-01-02" // MaxTime is the max representable time MaxTime = "2038-01-19" )
Variables ¶
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 CreateHome bool SkelDir string Directory string Expiry string }
AddUserOptions are the options specified in the configuration to be used when adding a user
type ModUserOptions ¶
type ModUserOptions struct { Username string UID string Group string Comment string Directory string MoveDir bool Expiry string }
ModUserOptions are the options specified in the configuration to be used when modifying a user
type Preparer ¶
type Preparer struct { // Username is the user login name. Username string `hcl:"username" required:"true" nonempty:"true"` // NewUsername is used when modifying a user. // Username will be changed to NewUsername. No changes to the home directory // name or location of the contents will be made. This can be done using // HomeDir and MoveDir options. NewUsername string `hcl:"new_username" nonempty:"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" nonempty:"true"` // 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. // This field can be indicated when adding or modifying a user. Name string `hcl:"name" nonempty:"true"` // CreateHome when set to true will create the home directory for the user. // The files and directories contained in the skeleton directory (which can be // defined with the SkelDir option) will be copied to the home directory. CreateHome bool `hcl:"create_home"` // SkelDir contains files and directories to be copied in the user's home // directory when adding a user. If not set, the skeleton directory is defined // by the SKEL variable in /etc/default/useradd or, by default, /etc/skel. // SkelDir is only valid is CreatHome is specified. SkelDir string `hcl:"skel_dir" nonempty:"true"` // HomeDir is the name of the user's login directory. If not set, the home // directory is defined by appending the value of Username to the HOME // variable in /etc/default/useradd, resulting in /HOME/Username. // This field can be indicated when adding or modifying a user. HomeDir string `hcl:"home_dir" nonempty:"true"` // MoveDir is used to move the contents of HomeDir when modifying a user. // HomeDir must also be indicated if MoveDir is set to true. MoveDir bool `hcl:"move_dir"` // Expiry is the date on which the user account will be disabled. The date is // specified in the format YYYY-MM-DD. If not specified, the default expiry // date specified by the EXPIRE variable in /etc/default/useradd, or an empty // string (no expiry) will be used by default. Expiry time.Time `hcl:"expiry"` // State is whether the user should be present. // The default value is present. State State `hcl:"state" valid_values:"present,absent"` }
Preparer for User
User renders user data
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) Lookup ¶
Lookup looks up a user by name If the user cannot be found an error is returned
func (*System) LookupGroup ¶
LookupGroup looks up a group by name If the group cannot be found an error is returned
func (*System) LookupGroupID ¶
LookupGroupID looks up a group by gid If the group cannot be found an error is returned
func (*System) LookupID ¶
LookupID looks up a user by uid If the user cannot be found an error is returned
func (*System) LookupUserExpiry ¶
LookupUserExpiry looks up a user's expiry
type SystemUtils ¶
type SystemUtils interface { AddUser(userName string, options *AddUserOptions) error DelUser(userName string) error ModUser(userName string, options *ModUserOptions) error LookupUserExpiry(userName string) (time.Time, 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 { // the configured username Username string `export:"username"` // the desired username NewUsername string `export:"newusername"` // the user id UID string `export:"uid"` // the group name GroupName string `export:"groupname"` // the group id GID string `export:"gid"` // the real name of the user Name string `export:"name"` // if the home directory should be created CreateHome bool `export:"createhome"` // the path to the skeleton directory SkelDir string `export:"skeldir"` // the path to the home directory HomeDir string `export:"homedir"` // if the contents of the home directory should be moved MoveDir bool `export:"movedir"` // the date the user account will be disabled Expiry time.Time `export:"expiry"` // configured the user state State State `export:"state"` // contains filtered or unexported fields }
User manages user users
func (*User) DiffAdd ¶
func (u *User) DiffAdd(status *resource.Status) (*AddUserOptions, error)
DiffAdd checks for differences between the current and desired state for the user to be added indicated by the User fields. The options to be used for the add command are set.
func (*User) DiffDel ¶
DiffDel checks for differences between the current and desired state for the user to be deleted indicated by the User fields.