group

package
v0.0.0-...-02c76fb Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 8 Imported by: 3

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 {
	// the configured group ID
	GID string `export:"gid"`

	// the configured group name
	Name string `export:"name"`

	// the desired group name
	NewName string `export:"newname"`

	// the group state
	State State `export:"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

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" nonempty:"true"`

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

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

Preparer for Group

Group renders group data

func (*Preparer) Prepare

func (p *Preparer) Prepare(ctx context.Context, 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