Documentation ¶
Index ¶
- func DuplicateBytes(a []byte) []byte
- func DuplicateStrings(a []string) []string
- func EnsureDirectory(path string, perm os.FileMode) error
- func IndexOfString(a []string, s string) int
- func RemoveFromStringSlice(a []string, s string) []string
- func StringInSlice(a []string, s string) bool
- func StringSliceEqual(a []string, b []string) bool
- type DirStructure
- func (ds *DirStructure) ChildDir(dirName string, perm os.FileMode) (child *DirStructure)
- func (ds *DirStructure) Ensure() error
- func (ds *DirStructure) EnsureAbsPath(dirPath string) error
- func (ds *DirStructure) EnsureRelDir(dirNames ...string) error
- func (ds *DirStructure) EnsureRelPath(dirPath string) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DuplicateBytes ¶
DuplicateBytes returns a new copy of the given byte slice.
func DuplicateStrings ¶
DuplicateStrings returns a new copy of the given string slice.
func EnsureDirectory ¶ added in v0.3.0
EnsureDirectory ensures that the given directory exists and that is has the given permissions set. If path is a file, it is deleted and a directory created. If a directory is created, also all missing directories up to the required one are created with the given permissions.
func IndexOfString ¶
IndexOfString returns the index of given string and -1 if its not part of the slice.
func RemoveFromStringSlice ¶
RemoveFromStringSlice removes the given string from the slice and returns a new slice.
func StringInSlice ¶
StringInSlice returns whether the given string is in the string slice.
func StringSliceEqual ¶
StringSliceEqual returns whether the given string slices are equal.
Types ¶
type DirStructure ¶ added in v0.3.0
type DirStructure struct { sync.Mutex Path string Dir string Perm os.FileMode Parent *DirStructure Children map[string]*DirStructure }
DirStructure represents a directory structure with permissions that should be enforced.
Example ¶
Output: / [755] /repo [777] /repo/b [755] /repo/b/c [750] /repo/b/d [755] /repo/b/d/e [755] /repo/b/d/f [755] /secret [700]
func NewDirStructure ¶ added in v0.3.0
func NewDirStructure(path string, perm os.FileMode) *DirStructure
NewDirStructure returns a new DirStructure.
func (*DirStructure) ChildDir ¶ added in v0.3.0
func (ds *DirStructure) ChildDir(dirName string, perm os.FileMode) (child *DirStructure)
ChildDir adds a new child DirStructure and returns it. Should the child already exist, the existing child is returned and the permissions are updated.
func (*DirStructure) Ensure ¶ added in v0.3.0
func (ds *DirStructure) Ensure() error
Ensure ensures that the specified directory structure (from the first parent on) exists.
func (*DirStructure) EnsureAbsPath ¶ added in v0.3.0
func (ds *DirStructure) EnsureAbsPath(dirPath string) error
EnsureAbsPath ensures that the specified directory structure (from the first parent on) and the given absolute path exists. If the given path is outside the DirStructure, an error will be returned.
func (*DirStructure) EnsureRelDir ¶ added in v0.3.0
func (ds *DirStructure) EnsureRelDir(dirNames ...string) error
EnsureRelDir ensures that the specified directory structure (from the first parent on) and the given relative path (to the DirStructure) exists.
func (*DirStructure) EnsureRelPath ¶ added in v0.3.0
func (ds *DirStructure) EnsureRelPath(dirPath string) error
EnsureRelPath ensures that the specified directory structure (from the first parent on) and the given relative path (to the DirStructure) exists.