converge: Index | Files

package owner

import ""


Package Files

OSExecutor.go owner.go ownership.go preparer.go utils.go


var ErrInvalidStat = errors.New("Underlying OS did not return a valid stat_t")

ErrInvalidStat is returned when we fail to stat a file

type OSExecutor Uses

type OSExecutor struct{}

OSExecutor provides a real implementation of OSProxy

func (*OSExecutor) Chown Uses

func (o *OSExecutor) Chown(path string, uid, gid int) error

Chown returns the result of OS.Chown

func (*OSExecutor) GetGID Uses

func (o *OSExecutor) GetGID(path string) (int, error)

GetGID returns the GID of a file or directory

func (*OSExecutor) GetUID Uses

func (o *OSExecutor) GetUID(path string) (int, error)

GetUID returns the UID of a file or directory

func (*OSExecutor) Lookup Uses

func (o *OSExecutor) Lookup(s string) (*user.User, error)

Lookup proxies user.Lookup

func (*OSExecutor) LookupGroup Uses

func (o *OSExecutor) LookupGroup(s string) (*user.Group, error)

LookupGroup proxies user.LookupGroup

func (*OSExecutor) LookupGroupID Uses

func (o *OSExecutor) LookupGroupID(s string) (*user.Group, error)

LookupGroupID proxies user.LookupGroupID

func (*OSExecutor) LookupID Uses

func (o *OSExecutor) LookupID(s string) (*user.User, error)

LookupID proxies user.LookupID

func (*OSExecutor) Stat Uses

func (o *OSExecutor) Stat(path string) (os.FileInfo, error)

Stat returns the result of os.Stat

func (*OSExecutor) Walk Uses

func (o *OSExecutor) Walk(root string, f filepath.WalkFunc) error

Walk returns the result of filepath.Walk

type OSProxy Uses

type OSProxy interface {
    Walk(root string, walkFunc filepath.WalkFunc) error
    Chown(name string, uid, gid int) error
    GetUID(name string) (int, error)
    GetGID(name string) (int, error)
    LookupGroupID(name string) (*user.Group, error)
    LookupGroup(gid string) (*user.Group, error)
    LookupID(name string) (*user.User, error)
    Lookup(uid string) (*user.User, error)
    Stat(path string) (os.FileInfo, error)

OSProxy is an intermediary used for interfacing with the underlying OS or test mocks.

type Owner Uses

type Owner struct {
    // the path to the file that should change; or if `recursive` is set, the path
    // to the root of the filesystem to recursively change.
    Destination string `export:"destination"`

    // the username of the user that should be given ownership of the file
    Username string `export:"username"`

    // the uid of the user that should be given ownership of the file
    UID string `export:"uid"`

    // the group name of the group that should be given ownership of the file
    Group string `export:"group"`

    // the gid of the group that should be given ownership of the file
    GID string `export:"gid"`

    // if true, and `destination` is a directory, apply changes recursively
    Recursive bool `export:"recursive"`

    HideDetails bool
    // contains filtered or unexported fields

Owner represents the ownership mode of a file or directory

func (*Owner) Apply Uses

func (o *Owner) Apply(context.Context) (resource.TaskStatus, error)

Apply applies the ownership to the file

func (*Owner) Check Uses

func (o *Owner) Check(context.Context, resource.Renderer) (resource.TaskStatus, error)

Check checks the ownership status of the file

func (*Owner) SetOSProxy Uses

func (o *Owner) SetOSProxy(p OSProxy) *Owner

SetOSProxy sets the internal OS Proxy

type Ownership Uses

type Ownership struct {
    UID *int
    GID *int

Ownership represents a file ownership

type OwnershipDiff Uses

type OwnershipDiff struct {
    Path string
    UIDs *[2]int
    GIDs *[2]int
    // contains filtered or unexported fields

OwnershipDiff diffs user and group IDs

func NewOwnershipDiff Uses

func NewOwnershipDiff(p OSProxy, path string, ownership *Ownership) (*OwnershipDiff, error)

NewOwnershipDiff creates a new diff

func (*OwnershipDiff) Apply Uses

func (d *OwnershipDiff) Apply() error

Apply applies the changes in ownership to a file based on a diff

func (*OwnershipDiff) Changes Uses

func (d *OwnershipDiff) Changes() bool

Changes returns true if Original() != Current()

func (*OwnershipDiff) Current Uses

func (d *OwnershipDiff) Current() string

Current returns the desired UID and GID

func (*OwnershipDiff) Original Uses

func (d *OwnershipDiff) Original() string

Original returns the original UID and GID

func (*OwnershipDiff) SetProxy Uses

func (d *OwnershipDiff) SetProxy(p OSProxy) *OwnershipDiff

SetProxy sets the internal OS Proxy

type Preparer Uses

type Preparer struct {
    // Destination is the location on disk where the content will be rendered.
    Destination string `hcl:"destination" required:"true" nonempty:"true"`

    // Recursive indicates whether ownership changes should be applied
    // recursively.  Symlinks are not followed.
    Recursive bool `hcl:"recursive"`

    // Username specifies user-owernship by user name
    Username string `hcl:"user" mutally_exclusive:"user,uid"`

    // UID specifies user-ownership by UID
    UID *int `hcl:"uid" mutually_exclusive:"user,uid"`

    // Groupname specifies group-ownership by groupname
    Groupname string `hcl:"group" mutually_exclusive:"group,gid"`

    // GID specifies group ownership by gid
    GID *int `hcl:"gid" mutually_exclusive:"group,gid"`

    // Verbose specifies that when performing recursive updates, a diff should be
    // shown for each file to be changed
    Verbose bool `hcl:"verbose"`
    // contains filtered or unexported fields

Preparer for Owner

Owner sets the file and group ownership of a file or directory. If `recursive` is set to true and `destination` is a directory, then it will also recursively change ownership of all files and subdirectories. Symlinks are ignored. If the file or directory does not exist during the plan phase of application the differences will be calculated during application. Otherwise changes will be limited to the files identified during the plan phase of application.

func (*Preparer) Prepare Uses

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

Prepare a new task

func (*Preparer) SetOSProxy Uses

func (p *Preparer) SetOSProxy(o OSProxy) *Preparer

SetOSProxy sets the private os proxy for mocking in tests

Package owner imports 11 packages (graph) and is imported by 1 packages. Updated 2017-01-01. Refresh now. Tools for package owners.