Documentation
¶
Index ¶
- Constants
- func ExpandFromContext(context map[string]string, value string) string
- func NormalizeImageTag(img string) string
- type BuilderContext
- type ContextAware
- type ContextAwareFileSystem
- func (r *ContextAwareFileSystem) Chdir(path string) error
- func (r *ContextAwareFileSystem) Cleanup()
- func (r *ContextAwareFileSystem) CreateTempDir() (tmpDir string, err error)
- func (r *ContextAwareFileSystem) DoesDirExist(path string) (bool, error)
- func (r *ContextAwareFileSystem) DoesFileExist(path string) (bool, error)
- func (r *ContextAwareFileSystem) Getwd() (string, error)
- func (r *ContextAwareFileSystem) IsDirEmpty(path string) (bool, error)
- func (r *ContextAwareFileSystem) SetContext(context *BuilderContext)
- func (r *ContextAwareFileSystem) TempDirsCreated() []string
- func (r *ContextAwareFileSystem) WriteFile(path string, source io.Reader) error
- type DockerCredential
- type EnvVar
- type FileSystem
- type GitReference
- type ImageDependencies
- type ImageReference
- type Request
- type Runner
- type Source
- type SourceTarget
- type Target
Constants ¶
const DockerHubRegistry = "registry.hub.docker.com"
DockerHubRegistry is the docker hub registry
Variables ¶
This section is empty.
Functions ¶
func ExpandFromContext ¶
ExpandFromContext : given a context and a string with reference to env variables, expand it
func NormalizeImageTag ¶ added in v0.4.0
NormalizeImageTag adds "latest" to the image if the specified image has no tag and it's not referenced by digest.
Types ¶
type BuilderContext ¶
type BuilderContext struct {
// contains filtered or unexported fields
}
BuilderContext is the context for Runners
func NewContext ¶
func NewContext(userDefined []EnvVar, systemGenerated []EnvVar) *BuilderContext
NewContext creates a new running context
func (*BuilderContext) Append ¶
func (r *BuilderContext) Append(newlyGenerated []EnvVar) *BuilderContext
Append append environment variables that the commands are run on
func (*BuilderContext) Expand ¶
func (r *BuilderContext) Expand(value string) string
Expand expands an string given the runner's environment
func (*BuilderContext) Export ¶
func (r *BuilderContext) Export() []string
Export the environment variables to child cmd to use
type ContextAware ¶
type ContextAware interface {
SetContext(context *BuilderContext)
GetContext() *BuilderContext
}
ContextAware are any objects that are aware of build contexts
type ContextAwareFileSystem ¶
type ContextAwareFileSystem struct {
// contains filtered or unexported fields
}
ContextAwareFileSystem is a collections of file sysetm operations which will resolves the input with respect to BuilderContext
func NewContextAwareFileSystem ¶
func NewContextAwareFileSystem(context *BuilderContext) *ContextAwareFileSystem
NewContextAwareFileSystem creates a new file system with no context
func (*ContextAwareFileSystem) Chdir ¶
func (r *ContextAwareFileSystem) Chdir(path string) error
Chdir changes current working directory for the runner
func (*ContextAwareFileSystem) Cleanup ¶ added in v0.5.0
func (r *ContextAwareFileSystem) Cleanup()
Cleanup delete all resources allocated by this filesystem object such as temp directory
func (*ContextAwareFileSystem) CreateTempDir ¶ added in v0.5.0
func (r *ContextAwareFileSystem) CreateTempDir() (tmpDir string, err error)
CreateTempDir creates a temp directory
func (*ContextAwareFileSystem) DoesDirExist ¶
func (r *ContextAwareFileSystem) DoesDirExist(path string) (bool, error)
DoesDirExist checks if a given directory exists
func (*ContextAwareFileSystem) DoesFileExist ¶
func (r *ContextAwareFileSystem) DoesFileExist(path string) (bool, error)
DoesFileExist checks if a given file exists
func (*ContextAwareFileSystem) Getwd ¶
func (r *ContextAwareFileSystem) Getwd() (string, error)
Getwd gets the current working directory
func (*ContextAwareFileSystem) IsDirEmpty ¶
func (r *ContextAwareFileSystem) IsDirEmpty(path string) (bool, error)
IsDirEmpty checks if given directory is empty
func (*ContextAwareFileSystem) SetContext ¶
func (r *ContextAwareFileSystem) SetContext(context *BuilderContext)
SetContext changes the context that the file system uses
func (*ContextAwareFileSystem) TempDirsCreated ¶ added in v0.5.0
func (r *ContextAwareFileSystem) TempDirsCreated() []string
TempDirsCreated lists all temp dir created
func (*ContextAwareFileSystem) WriteFile ¶ added in v0.5.0
func (r *ContextAwareFileSystem) WriteFile(path string, source io.Reader) error
WriteFile writes stream from reader to path NOTE: 1. it assumes that the directory already exists 2. it overwrites any existing file and will not create a backup
type DockerCredential ¶
DockerCredential denote how to authenticate to a docker registry
type FileSystem ¶
type FileSystem interface {
Getwd() (string, error)
Chdir(path string) error
DoesDirExist(path string) (bool, error)
DoesFileExist(path string) (bool, error)
IsDirEmpty(path string) (bool, error)
WriteFile(path string, source io.Reader) error
CreateTempDir() (string, error)
Cleanup()
}
FileSystem contains a few interfaces that we are using in acr-builder
type GitReference ¶
type GitReference struct {
GitHeadRev string `json:"git-head-revision"`
}
GitReference defines the reference to git source code
type ImageDependencies ¶
type ImageDependencies struct {
Image *ImageReference `json:"image"`
Runtime *ImageReference `json:"runtime-dependency"`
Buildtime []*ImageReference `json:"buildtime-dependency"`
Git *GitReference `json:"git,omitempty"`
}
ImageDependencies denotes docker image dependencies
func NewImageDependencies ¶
func NewImageDependencies(env *BuilderContext, image string, runtime string, buildtimes []string) (*ImageDependencies, error)
NewImageDependencies creates ImageDependencies with no references registered
type ImageReference ¶
type ImageReference struct {
Registry string `json:"registry"`
Repository string `json:"repository"`
Tag string `json:"tag,omitempty"`
Digest string `json:"digest"`
// contains filtered or unexported fields
}
ImageReference defines the reference to a docker image
func NewImageReference ¶
func NewImageReference(path string) (*ImageReference, error)
NewImageReference parses a path of a image and creates a ImageReference object
func (*ImageReference) String ¶
func (ref *ImageReference) String() string
String method converts the ImageReference to string
type Request ¶
type Request struct {
DockerRegistry string
DockerCredentials []DockerCredential
Targets []SourceTarget
}
Request defines a acr-builder build
type Runner ¶
type Runner interface {
GetStdin() io.Reader
GetFileSystem() FileSystem
SetContext(context *BuilderContext)
GetContext() *BuilderContext
ExecuteCmd(cmdExe string, cmdArgs []string, reader io.Reader) error
QueryCmd(cmdExe string, cmdArgs []string) (string, error)
// Note: ExecuteCmdWithObfuscation allow obfuscating sensitive data such as
// authentication tokens or passwords not to be shown in logs
// However, passing these sensitive data through command lines are not
// quite safe anyway because OS would keep command logs
// We need to think about the security implications
ExecuteCmdWithObfuscation(obfuscate func([]string), cmdExe string, cmdArgs []string) error
}
Runner is used to run shell commands
type Source ¶
type Source interface {
Obtain(runner Runner) error
Remark(runner Runner, dependencies *ImageDependencies)
Return(runner Runner) error
Export() []EnvVar
}
Source defines where the source code is and how to fetch the code
type SourceTarget ¶
SourceTarget defines a source and a set of BuildTargets to run
type Target ¶
type Target interface {
// Build task can't be a generic tasks now because it needs to return ImageDependencies
// If we use docker events to figure out dependencies, we can make build tasks a generic task
Ensure(runner Runner) error
Build(runner Runner) error
Push(runner Runner) error
ScanForDependencies(runner Runner) ([]ImageDependencies, error)
Export() []EnvVar
}
Target is the build part of SourceTarget