Documentation ¶
Index ¶
- Variables
- type OSExecutor
- func (o *OSExecutor) Chown(path string, uid, gid int) error
- func (o *OSExecutor) GetGID(path string) (int, error)
- func (o *OSExecutor) GetUID(path string) (int, error)
- func (o *OSExecutor) Lookup(s string) (*user.User, error)
- func (o *OSExecutor) LookupGroup(s string) (*user.Group, error)
- func (o *OSExecutor) LookupGroupID(s string) (*user.Group, error)
- func (o *OSExecutor) LookupID(s string) (*user.User, error)
- func (o *OSExecutor) Stat(path string) (os.FileInfo, error)
- func (o *OSExecutor) Walk(root string, f filepath.WalkFunc) error
- type OSProxy
- type Owner
- type Ownership
- type OwnershipDiff
- type Preparer
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidStat = errors.New("Underlying OS did not return a valid stat_t")
ErrInvalidStat is returned when we fail to stat a file
Functions ¶
This section is empty.
Types ¶
type OSExecutor ¶
type OSExecutor struct{}
OSExecutor provides a real implementation of OSProxy
func (*OSExecutor) Chown ¶
func (o *OSExecutor) Chown(path string, uid, gid int) error
Chown returns the result of OS.Chown
func (*OSExecutor) GetGID ¶
func (o *OSExecutor) GetGID(path string) (int, error)
GetGID returns the GID of a file or directory
func (*OSExecutor) GetUID ¶
func (o *OSExecutor) GetUID(path string) (int, error)
GetUID returns the UID of a file or directory
func (*OSExecutor) Lookup ¶
func (o *OSExecutor) Lookup(s string) (*user.User, error)
Lookup proxies user.Lookup
func (*OSExecutor) LookupGroup ¶
func (o *OSExecutor) LookupGroup(s string) (*user.Group, error)
LookupGroup proxies user.LookupGroup
func (*OSExecutor) LookupGroupID ¶
func (o *OSExecutor) LookupGroupID(s string) (*user.Group, error)
LookupGroupID proxies user.LookupGroupID
func (*OSExecutor) LookupID ¶
func (o *OSExecutor) LookupID(s string) (*user.User, error)
LookupID proxies user.LookupID
type OSProxy ¶
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 ¶
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) SetOSProxy ¶
SetOSProxy sets the internal OS Proxy
type OwnershipDiff ¶
type OwnershipDiff struct { Path string UIDs *[2]int GIDs *[2]int // contains filtered or unexported fields }
OwnershipDiff diffs user and group IDs
func NewOwnershipDiff ¶
func NewOwnershipDiff(p OSProxy, path string, ownership *Ownership) (*OwnershipDiff, error)
NewOwnershipDiff creates a new diff
func (*OwnershipDiff) Apply ¶
func (d *OwnershipDiff) Apply() error
Apply applies the changes in ownership to a file based on a diff
func (*OwnershipDiff) Changes ¶
func (d *OwnershipDiff) Changes() bool
Changes returns true if Original() != Current()
func (*OwnershipDiff) Current ¶
func (d *OwnershipDiff) Current() string
Current returns the desired UID and GID
func (*OwnershipDiff) Original ¶
func (d *OwnershipDiff) Original() string
Original returns the original UID and GID
func (*OwnershipDiff) SetProxy ¶
func (d *OwnershipDiff) SetProxy(p OSProxy) *OwnershipDiff
SetProxy sets the internal OS Proxy
type Preparer ¶
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) SetOSProxy ¶
SetOSProxy sets the private os proxy for mocking in tests