Documentation ¶
Overview ¶
Package build defines types and interfaces that could potentially be compiled to various external build-tool scripts but share a general internal abstraction and rules for escaping.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortFilesByDir ¶ added in v0.5.0
SortFilesByDir returns both the given files indexed by parent directory and a sorted slice of those parent directories. The latter is useful in ensuring deterministic iteration since the ordering of map keys is not guaranteed.
Types ¶
type Copy ¶
type Copy struct { Sources []string // source file/directory paths Destination string // destination path }
Copy is a concrete build instruction for copying source files/directories from the build host into the image.
type CopyAs ¶ added in v0.3.0
type CopyAs struct { UID uint // owner UID GID uint // owner GID Instruction }
CopyAs is a concrete build instruction for copying source files/directories and setting their ownership to the given UID/GID.
While it can technically wrap any build.Instruction, it is meant to be used with build.Copy and build.CopyFrom to enforce file/directory ownership.
type CopyFrom ¶
CopyFrom is a concrete build instruction for copying source files/directories from one variant image to another.
type EntryPoint ¶ added in v0.3.0
type EntryPoint struct {
Command []string // command and arguments
}
EntryPoint is a build instruction for declaring a container's default runtime process.
func (EntryPoint) Compile ¶ added in v0.3.0
func (ep EntryPoint) Compile() []string
Compile returns the quoted entrypoint command and arguments.
type Env ¶
Env is a concrete build instruction for declaring a container's runtime environment variables.
type Instruction ¶
type Instruction interface {
Compile() []string
}
Instruction defines a common interface that all concrete build types must implement.
func ApplyUser ¶ added in v0.3.0
func ApplyUser(uid uint, gid uint, instructions []Instruction) []Instruction
ApplyUser wraps any build.Copy instructions as build.CopyAs using the given UID/GID.
func SyncFiles ¶ added in v0.5.0
func SyncFiles(files []string, dest string) []Instruction
SyncFiles returns build instructions to copy over the given files after creating their parent directories. Parent directories are created in a sorted order.
type Label ¶
Label is a concrete build instruction for declaring a number of meta-data key/value pairs to be included in the image.
type Phase ¶
type Phase int
Phase enum type
const ( PhasePrivileged Phase = iota // first, copies/execution done as root PhasePrivilegeDropped // second, copies/execution done as unprivileged user from here on PhasePreInstall // third, before application files and artifacts are copied PhaseInstall // fourth, application files and artifacts are copied PhasePostInstall // fifth, after application files and artifacts are copied )
Distinct build phases that each compiler implementation should pass to PhaseCompileable configuration (in the order they are defined here) to allow for dependency injection during compilation.
type PhaseCompileable ¶
type PhaseCompileable interface {
InstructionsForPhase(phase Phase) []Instruction
}
PhaseCompileable defines and interface that all configuration types should implement if they want to inject build instructions into any of the defined build phases.
type Run ¶
type Run struct { Command string // command string (e.g. "useradd -d %s -u %s") Arguments []string // command arguments both inner and final (e.g. ["/home/user", "123", "user"]) }
Run is a concrete build instruction for passing any number of arguments to a shell command.
The command string may contain inner argument placeholders using the "%s" format verb and will be appended with the quoted values of any arguments that remain after interpolation of the command string.
func Chown ¶ added in v0.3.0
Chown returns a build.Run instruction for setting ownership on the given path.
func CreateDirectories ¶ added in v0.5.0
CreateDirectories returns a build.Run instruction for creating all the given directories.
func CreateDirectory ¶ added in v0.3.0
CreateDirectory returns a build.Run instruction for creating the given directory.
func CreateUser ¶ added in v0.3.0
CreateUser returns build.Run instructions for creating the given user account and group.
type RunAll ¶
type RunAll struct {
Runs []Run // multiple Run instructions to be executed together
}
RunAll is a concrete build instruction for declaring multiple Run instructions that will be executed together in a `cmd1 && cmd2` chain.
type User ¶ added in v0.3.0
type User struct {
Name string // user name
}
User is a build instruction for setting which user will run future commands.
type WorkingDirectory ¶ added in v0.3.0
type WorkingDirectory struct {
Path string // working directory path
}
WorkingDirectory is a build instruction for defining the working directory for future command and entrypoint instructions.
func (WorkingDirectory) Compile ¶ added in v0.3.0
func (wd WorkingDirectory) Compile() []string
Compile returns the quoted working directory path.