group

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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

ErrUnsupported is used when a system is not supported

Functions

This section is empty.

Types

type Group

type Group struct {
	GID     string
	Name    string
	NewName string
	State   State
	// contains filtered or unexported fields
}

Group manages user groups

func NewGroup

func NewGroup(system SystemUtils) *Group

NewGroup constructs and returns a new Group

func (*Group) Apply

func (g *Group) Apply() (resource.TaskStatus, error)

Apply changes for group

func (*Group) Check

Check if a user group exists

type ModGroupOptions

type ModGroupOptions struct {
	GID     string
	NewName string
}

ModGroupOptions are the options specified in the configuration to be used when modifying a group

func SetModGroupOptions

func SetModGroupOptions(g *Group) *ModGroupOptions

SetModGroupOptions returns a ModGroupOptions struct with the options specified in the configuration for modifying a group

type Preparer

type Preparer struct {
	// Gid is the group gid.
	GID *uint32 `hcl:"gid"`

	// Name is the group name.
	Name string `hcl:"name" required:"true"`

	// NewName is used when modifying a group.
	// The group Name will be changed to NewName.
	NewName string `hcl:"new_name"`

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

Preparer for Group

Group renders group 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 Group

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

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

type System

type System struct{}

System implements SystemUtils

func (*System) AddGroup

func (s *System) AddGroup(groupName, groupID string) error

AddGroup adds a group

func (*System) DelGroup

func (s *System) DelGroup(groupName string) error

DelGroup deletes a group

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) ModGroup

func (s *System) ModGroup(groupName string, options *ModGroupOptions) error

ModGroup modifies a group

type SystemUtils

type SystemUtils interface {
	AddGroup(groupName, groupID string) error
	DelGroup(groupName string) error
	ModGroup(groupName string, options *ModGroupOptions) error
	LookupGroup(groupName string) (*user.Group, error)
	LookupGroupID(groupID string) (*user.Group, error)
}

SystemUtils provides system utilities for group

Jump to

Keyboard shortcuts

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