Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcatDirectoryContents ¶ added in v0.1.9
ConcatDirectoryContents concatenates all regular files inside the source directory and returns their concatenated contents.
Types ¶
type Copier ¶
type Copier struct {
// contains filtered or unexported fields
}
Copier provides helper functions that copy files and directories to specified locations. Common behaviors regardless of the parameters:
- If target diretory's ancestors do not exist, they will be created with default 0755 permission and owned by root.
- If target directory already exists, its permission and owner will be preserved.
- Symlinks are copied with original targets (not guaranteed to be valid).
Then there are 4 scenarios for handling file/directory permissions: - ADD/COPY without flags, from context:
- If target directory doesn't exist, it will be created with default 0755 permission and owned by root.
- For directories and files under source, permissions will be preserved, and owners will be root.
- Use dstDirOwner without overwrite and dstFileAndChildrenOwner with overwrite, set uid:gid to 0:0.
- ADD/COPY --from, without other flags:
- If target directory doesn't exist, it will be created with default 0755 permission and owned by root.
- For directories and files under source, permissions and owners will be preserved.
- Leave dstDirOwner and dstFileAndChildrenOwner empty.
- ADD/COPY --chown, with or wihout --from:
- If target directory doesn't exist, it will be created with default 0755 permission and owned by given uid/gid.
- For directories and files under source, permissions are kept, but owner will be changed to given uid/gid.
- Use dstDirOwner without overwrite and dstFileAndChildrenOwner with overwrite.
- ADD/COPY --from --archive:
- If target directory doesn't exist, it will be created with default 0755 permission and owned by source dir's uid/gid (directly given as copier parameters).
- For directories and files under source, permissions and owners will be preserved.
- Use dstDirOwner without overwrite and source dir's uid/gid.
func NewCopier ¶
func NewCopier(blacklist []string, opts ...CopyOption) *Copier
NewCopier initializes a new copier object. Files from provided blacklist will be ignored.
func (*Copier) CopyDir ¶
CopyDir recursively copies the directory at source to target. The source directory must exist, and the target doesn't need to exist but must be a directory if it does. Existing children files/dirs will be overwritten. Permissions and owners depend on copier attributes.
Note: If src contains dst, this function would break infinite loop silently. This is needed to defend against scenarios like:
COPY --from=stage1 / /
where / will be stashed to some child directory at the end of stage1, and causes infinite loop.
type CopyOption ¶ added in v0.2.0
type CopyOption func(*Copier)
func WithDstDirOwner ¶ added in v0.2.0
func WithDstDirOwner(uid, gid int, overwrite bool) CopyOption
func WithDstFileAndChildrenOwner ¶ added in v0.2.0
func WithDstFileAndChildrenOwner(uid, gid int, overwrite bool) CopyOption