Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - func CheckAllowedUser(d Docker, imageName string, uids user.RangeList, isOnbuild bool) error
 - func GetDefaultDockerConfig() *api.DockerConfig
 - func GetImageRegistryAuth(auths *client.AuthConfigurations, imageName string) client.AuthConfiguration
 - func IsReachable(config *api.Config) bool
 - func LoadAndGetImageRegistryAuth(dockerCfg io.Reader, imageName string) client.AuthConfiguration
 - func LoadImageRegistryAuth(dockerCfg io.Reader) *client.AuthConfigurations
 - func StreamContainerIO(errStream io.Reader, errOutput *string, log func(...interface{}))
 - type BuildImageOptions
 - type Client
 - type CommitContainerOptions
 - type Docker
 - type DockerImageReference
 - type FakeDocker
 - func (f *FakeDocker) BuildImage(opts BuildImageOptions) error
 - func (f *FakeDocker) CheckAndPullImage(name string) (*dockerclient.Image, error)
 - func (f *FakeDocker) CheckImage(name string) (*dockerclient.Image, error)
 - func (f *FakeDocker) CommitContainer(opts CommitContainerOptions) (string, error)
 - func (f *FakeDocker) GetImageID(image string) (string, error)
 - func (f *FakeDocker) GetImageUser(image string) (string, error)
 - func (f *FakeDocker) GetImageWorkdir(name string) (string, error)
 - func (f *FakeDocker) GetLabels(name string) (map[string]string, error)
 - func (f *FakeDocker) GetOnBuild(imageName string) ([]string, error)
 - func (f *FakeDocker) GetScriptsURL(image string) (string, error)
 - func (f *FakeDocker) IsImageInLocalRegistry(imageName string) (bool, error)
 - func (f *FakeDocker) IsImageOnBuild(imageName string) bool
 - func (f *FakeDocker) Ping() error
 - func (f *FakeDocker) PullImage(imageName string) (*dockerclient.Image, error)
 - func (f *FakeDocker) RemoveContainer(id string) error
 - func (f *FakeDocker) RemoveImage(name string) error
 - func (f *FakeDocker) RunContainer(opts RunContainerOptions) error
 - func (f *FakeDocker) UploadToContainer(srcPath, destPath, name string) error
 
- type PostExecutor
 - type PullResult
 - type RunContainerOptions
 
Constants ¶
const ( // Deprecated environment variable name, specifying where to look for the S2I scripts. // It is now being replaced with ScriptsURLLabel. ScriptsURLEnvironment = "STI_SCRIPTS_URL" // Deprecated environment variable name, specifying where to place artifacts in // builder image. It is now being replaced with DestinationLabel. LocationEnvironment = "STI_LOCATION" // ScriptsURLLabel is the name of the Docker image LABEL that tells S2I where // to look for the S2I scripts. This label is also copied into the ouput // image. // The previous name of this label was 'io.s2i.scripts-url'. This is now // deprecated. ScriptsURLLabel = api.DefaultNamespace + "scripts-url" // DestinationLabel is the name of the Docker image LABEL that tells S2I where // to place the artifacts (scripts, sources) in the builder image. // The previous name of this label was 'io.s2i.destination'. This is now // deprecated DestinationLabel = api.DefaultNamespace + "destination" // DefaultDestination is the destination where the artifacts will be placed // if DestinationLabel was not specified. DefaultDestination = "/tmp" // DefaultTag is the image tag, being applied if none is specified. DefaultTag = "latest" // DefaultDockerTimeout specifies a timeout for Docker API calls. When this // timeout is reached, certain Docker API calls might error out. DefaultDockerTimeout = 20 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func CheckAllowedUser ¶ added in v1.0.4
CheckAllowedUser retrieves the user for a Docker image and checks that user against an allowed range of uids.
- If the range of users is not empty, then the user on the Docker image needs to be a numeric user
 - The user's uid must be contained by the range(s) specified by the uids Rangelist
 - If the image contains ONBUILD instructions and those instructions also contain a USER directive, then the user specified by that USER directive must meet the uid range criteria as well.
 
func GetDefaultDockerConfig ¶ added in v1.0.4
func GetDefaultDockerConfig() *api.DockerConfig
func GetImageRegistryAuth ¶
func GetImageRegistryAuth(auths *client.AuthConfigurations, imageName string) client.AuthConfiguration
GetImageRegistryAuth retrieves the appropriate docker client authentication object for a given image name and a given set of client authentication objects.
func IsReachable ¶ added in v1.0.4
IsReachable returns true if the Docker daemon is reachable from s2i
func LoadAndGetImageRegistryAuth ¶ added in v1.0.2
func LoadAndGetImageRegistryAuth(dockerCfg io.Reader, imageName string) client.AuthConfiguration
LoadAndGetImageRegistryAuth loads the set of client auth objects from a docker config file and returns the appropriate client auth object for a given image name.
func LoadImageRegistryAuth ¶ added in v1.0.2
func LoadImageRegistryAuth(dockerCfg io.Reader) *client.AuthConfigurations
LoadImageRegistryAuth loads and returns the set of client auth objects from a docker config json file.
func StreamContainerIO ¶ added in v1.0.2
StreamContainerIO takes data from the Reader and redirects to the log function (typically we pass in glog.Error for stderr and glog.Info for stdout
Types ¶
type BuildImageOptions ¶
type BuildImageOptions struct {
	Name         string
	Stdin        io.Reader
	Stdout       io.Writer
	CGroupLimits *api.CGroupLimits
}
    BuildImageOptions are options passed in to the BuildImage method
type Client ¶
type Client interface {
	RemoveImage(name string) error
	InspectImage(name string) (*docker.Image, error)
	PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
	CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)
	AttachToContainerNonBlocking(opts docker.AttachToContainerOptions) (docker.CloseWaiter, error)
	StartContainer(id string, hostConfig *docker.HostConfig) error
	WaitContainer(id string) (int, error)
	UploadToContainer(id string, opts docker.UploadToContainerOptions) error
	RemoveContainer(opts docker.RemoveContainerOptions) error
	CommitContainer(opts docker.CommitContainerOptions) (*docker.Image, error)
	CopyFromContainer(opts docker.CopyFromContainerOptions) error
	BuildImage(opts docker.BuildImageOptions) error
	InspectContainer(id string) (*docker.Container, error)
	Ping() error
}
    Client contains all methods called on the go Docker client.
type CommitContainerOptions ¶
type CommitContainerOptions struct {
	ContainerID string
	Repository  string
	User        string
	Command     []string
	Env         []string
	Labels      map[string]string
}
    CommitContainerOptions are options passed in to the CommitContainer method
type Docker ¶
type Docker interface {
	IsImageInLocalRegistry(name string) (bool, error)
	IsImageOnBuild(string) bool
	GetOnBuild(string) ([]string, error)
	RemoveContainer(id string) error
	GetScriptsURL(name string) (string, error)
	RunContainer(opts RunContainerOptions) error
	GetImageID(name string) (string, error)
	GetImageWorkdir(name string) (string, error)
	CommitContainer(opts CommitContainerOptions) (string, error)
	RemoveImage(name string) error
	CheckImage(name string) (*docker.Image, error)
	PullImage(name string) (*docker.Image, error)
	CheckAndPullImage(name string) (*docker.Image, error)
	BuildImage(opts BuildImageOptions) error
	GetImageUser(name string) (string, error)
	GetLabels(name string) (map[string]string, error)
	UploadToContainer(srcPath, destPath, name string) error
	Ping() error
}
    Docker is the interface between STI and the Docker client It contains higher level operations called from the STI build or usage commands
func New ¶
func New(config *api.DockerConfig, auth docker.AuthConfiguration) (Docker, error)
New creates a new implementation of the STI Docker interface
type DockerImageReference ¶
type DockerImageReference struct {
	Registry  string
	Namespace string
	Name      string
	Tag       string
	ID        string
}
    DockerImageReference points to a Docker image.
func ParseDockerImageReference ¶
func ParseDockerImageReference(spec string) (DockerImageReference, error)
ParseDockerImageReference parses a Docker pull spec string into a DockerImageReference. FIXME: This code was copied from OpenShift repository
type FakeDocker ¶ added in v1.0.4
type FakeDocker struct {
	LocalRegistryImage           string
	LocalRegistryResult          bool
	LocalRegistryError           error
	RemoveContainerID            string
	RemoveContainerError         error
	DefaultURLImage              string
	DefaultURLResult             string
	DefaultURLError              error
	RunContainerOpts             RunContainerOptions
	RunContainerError            error
	RunContainerErrorBeforeStart bool
	RunContainerContainerID      string
	RunContainerCmd              []string
	GetImageIDImage              string
	GetImageIDResult             string
	GetImageIDError              error
	GetImageUserImage            string
	GetImageUserResult           string
	GetImageUserError            error
	CommitContainerOpts          CommitContainerOptions
	CommitContainerResult        string
	CommitContainerError         error
	RemoveImageName              string
	RemoveImageError             error
	BuildImageOpts               BuildImageOptions
	BuildImageError              error
	PullResult                   bool
	PullError                    error
	OnBuildImage                 string
	OnBuildResult                []string
	OnBuildError                 error
	IsOnBuildResult              bool
	IsOnBuildImage               string
	Labels                       map[string]string
	LabelsError                  error
}
    FakeDocker provides a fake docker interface
func (*FakeDocker) BuildImage ¶ added in v1.0.4
func (f *FakeDocker) BuildImage(opts BuildImageOptions) error
BuildImage builds image
func (*FakeDocker) CheckAndPullImage ¶ added in v1.0.4
func (f *FakeDocker) CheckAndPullImage(name string) (*dockerclient.Image, error)
CheckAndPullImage pulls a fake docker image
func (*FakeDocker) CheckImage ¶ added in v1.0.4
func (f *FakeDocker) CheckImage(name string) (*dockerclient.Image, error)
CheckImage checks image in local registry
func (*FakeDocker) CommitContainer ¶ added in v1.0.4
func (f *FakeDocker) CommitContainer(opts CommitContainerOptions) (string, error)
CommitContainer commits a fake Docker container
func (*FakeDocker) GetImageID ¶ added in v1.0.4
func (f *FakeDocker) GetImageID(image string) (string, error)
GetImageID returns a fake Docker image ID
func (*FakeDocker) GetImageUser ¶ added in v1.0.4
func (f *FakeDocker) GetImageUser(image string) (string, error)
GetImageUser returns a fake user
func (*FakeDocker) GetImageWorkdir ¶ added in v1.0.5
func (f *FakeDocker) GetImageWorkdir(name string) (string, error)
GetImageWorkdir returns the workdir
func (*FakeDocker) GetLabels ¶ added in v1.0.4
func (f *FakeDocker) GetLabels(name string) (map[string]string, error)
func (*FakeDocker) GetOnBuild ¶ added in v1.0.4
func (f *FakeDocker) GetOnBuild(imageName string) ([]string, error)
GetOnBuild returns the list of onbuild instructions for the given image
func (*FakeDocker) GetScriptsURL ¶ added in v1.0.4
func (f *FakeDocker) GetScriptsURL(image string) (string, error)
GetScriptsURL returns a default STI scripts URL
func (*FakeDocker) IsImageInLocalRegistry ¶ added in v1.0.4
func (f *FakeDocker) IsImageInLocalRegistry(imageName string) (bool, error)
IsImageInLocalRegistry checks if the image exists in the fake local registry
func (*FakeDocker) IsImageOnBuild ¶ added in v1.0.4
func (f *FakeDocker) IsImageOnBuild(imageName string) bool
IsImageOnBuild returns true if the builder has onbuild instructions
func (*FakeDocker) Ping ¶ added in v1.0.4
func (f *FakeDocker) Ping() error
Ping tells id the Docker deamon is reachable
func (*FakeDocker) PullImage ¶ added in v1.0.4
func (f *FakeDocker) PullImage(imageName string) (*dockerclient.Image, error)
PullImage pulls a fake docker image
func (*FakeDocker) RemoveContainer ¶ added in v1.0.4
func (f *FakeDocker) RemoveContainer(id string) error
RemoveContainer removes a fake Docker container
func (*FakeDocker) RemoveImage ¶ added in v1.0.4
func (f *FakeDocker) RemoveImage(name string) error
RemoveImage removes a fake Docker image
func (*FakeDocker) RunContainer ¶ added in v1.0.4
func (f *FakeDocker) RunContainer(opts RunContainerOptions) error
RunContainer runs a fake Docker container
func (*FakeDocker) UploadToContainer ¶ added in v1.0.5
func (f *FakeDocker) UploadToContainer(srcPath, destPath, name string) error
type PostExecutor ¶
type PullResult ¶
func GetBuilderImage ¶ added in v1.0.4
func GetBuilderImage(config *api.Config) (*PullResult, error)
GetBuilderImage processes the config and performs operations necessary to make the Docker image specified as BuilderImage available locally. It returns information about the base image, containing metadata necessary for choosing the right STI build strategy.
func PullImage ¶ added in v1.0.4
func PullImage(name string, d Docker, policy api.PullPolicy, force bool) (*PullResult, error)
PullImage pulls the Docker image specifies by name taking the pull policy into the account. TODO: The 'force' option will be removed
type RunContainerOptions ¶
type RunContainerOptions struct {
	Image            string
	PullImage        bool
	PullAuth         docker.AuthConfiguration
	ExternalScripts  bool
	ScriptsURL       string
	Destination      string
	Command          string
	CommandOverrides func(originalCmd string) string
	Env              []string
	Entrypoint       []string
	Stdin            io.Reader
	Stdout           io.Writer
	Stderr           io.Writer
	OnStart          func(containerID string) error
	PostExec         PostExecutor
	TargetImage      bool
	NetworkMode      string
	User             string
	CGroupLimits     *api.CGroupLimits
	CapDrop          []string
}
    RunContainerOptions are options passed in to the RunContainer method