cake

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultShaLength = 64
View Source
const GeneratedDockerFileNamePrefix = "Dockerfile.generated"

Variables

This section is empty.

Functions

func BuildImage

func BuildImage(dockerClient DockerClient, image *Image, config BuildConfig) error

func GenerateReport

func GenerateReport(image *Image, config BuildConfig) error

func ImageExists

func ImageExists(dockerClient DockerClient, image *Image, config BuildConfig) (bool, error)

func PushImage

func PushImage(dockerClient DockerClient, image *Image, config BuildConfig) error

func Tar added in v0.4.0

func Tar(source string, target string) error

tar util with symlink traversal support

func TransformConfigToImages

func TransformConfigToImages(config BuildConfig) (images map[string]*Image, err error)

Transforms list of config items into independent Tree nodes. Checks for duplicate IDs and multiple parents (images with no parent defined)

func WalkBuildGraph

func WalkBuildGraph(graph *Image, apply func(image *Image))

WalkBuildGraph performs a breadth-first traversal of the tree and applies the provided function to all elements from the same level in order. It is recommended using it when 'apply' function has side-effects which require deterministic ordering e.g. building an ordered slice of image tags.

func WalkBuildGraphParallel

func WalkBuildGraphParallel(graph *Image, apply func(image *Image))

WalkBuildGraphParallel performs a breadth-first traversal of the tree and applies the provided function to all elements from the same level in parallel. The provided function should not rely on the ordering of the elements within the same level. The function is called within a goroutine and while it is applied to each element in order, the order of completion is not guaranteed. However, the ordering of levels is always preserved and the new tree level processing doesn't start until all the elements from the previous level are processed.

Types

type AuthConfig

type AuthConfig struct {
	DockerRegistryUrl string
	Username          string
	Password          string
}

type BuildConfig

type BuildConfig struct {
	AuthConfig       AuthConfig
	BaseDir          string
	ReleaseTag       string
	OutputFile       string
	Images           []ImageConfig     `yaml:"images"`
	GlobalProperties map[string]string `yaml:"global_properties"`
}

func (*BuildConfig) LoadConfigFromFile

func (config *BuildConfig) LoadConfigFromFile(fileName string) error

type BuildReport

type BuildReport struct {
	Images []ImageBuildSummary
}

type DockerClient

type DockerClient interface {
	Tags(imageName string) (tags []string, err error)
	ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
	ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error)
}

type ExternalDockerClient

type ExternalDockerClient struct {
	AuthConfig AuthConfig
	Client     *client.Client
	Registry   *registry.Registry
	TagsCache  map[string][]string
}

func NewExternalDockerClient

func NewExternalDockerClient(authConfig AuthConfig) *ExternalDockerClient

func (*ExternalDockerClient) ImageBuild

func (client *ExternalDockerClient) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)

func (*ExternalDockerClient) ImagePush

func (client *ExternalDockerClient) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error)

func (*ExternalDockerClient) Tags

func (client *ExternalDockerClient) Tags(imageName string) (tags []string, err error)

Tags retrieves tags list from the registry for specified image name and adds them to the cache. It returns tags list (whether by making an HTTP call to a registry of from the cache) and any error encountered.

type Image

type Image struct {
	ImageConfig ImageConfig
	Dockerfile  string
	Checksum    string
	Parent      *Image
	Children    []*Image
}

Tree Node represents Docker Image

func CreateImageBuildGraph

func CreateImageBuildGraph(images map[string]*Image) (image *Image, err error)

Constructs a tree/DAG of images and performs cycle detection check and orphaned images check

func (*Image) CalculateChecksum

func (image *Image) CalculateChecksum(checksumLength int) error

func (*Image) RenderDockerfileFromTemplate

func (image *Image) RenderDockerfileFromTemplate(config BuildConfig) error

func (Image) String

func (image Image) String() string

type ImageBuildSummary

type ImageBuildSummary struct {
	Id            string
	StableTag     string
	PublishedTags []string
}

type ImageConfig

type ImageConfig struct {
	Id            string
	Parent        string
	Repository    string
	Name          string
	TagPrefix     string `yaml:"tag_prefix"`
	TagSuffix     string `yaml:"tag_suffix"`
	Template      string
	ExtraFiles    []string `yaml:"extra_files"`
	ExcludedFiles []string `yaml:"exclude_files"`
	Properties    map[string]string
}

func (ImageConfig) String

func (image ImageConfig) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL