docker

package
v2.7.20 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvAppVersion APP_VERSION
	EnvAppVersion = "APP_VERSION"
	// EnvAuroraVersion AURORA_VERSION
	EnvAuroraVersion = "AURORA_VERSION"
	// EnvSnapshotVersion SNAPSHOT_TAG
	EnvSnapshotVersion = "SNAPSHOT_TAG"
	// EnvPushExtraTags PUSH_EXTRA_TAGS
	EnvPushExtraTags = "PUSH_EXTRA_TAGS"
	// TZ TZ
	TZ = "TZ"
	// ImageBuildTime IMAGE_BUILD_TIME
	ImageBuildTime = "IMAGE_BUILD_TIME"
)

Env keys

Variables

This section is empty.

Functions

func ClusterRegistryCredentials added in v2.7.12

func ClusterRegistryCredentials() func(string) (*RegistryCredentials, error)

ClusterRegistryCredentials load docker credentials from build pod

func ConvertRepositoryTagToTag

func ConvertRepositoryTagToTag(tag string) string

ConvertRepositoryTagToTag convert repository tag to tag

func ConvertRepositoryTagsToTags

func ConvertRepositoryTagsToTags(tags []string) []string

ConvertRepositoryTagsToTags convert multiple repository tags to tags

func ConvertTagToRepositoryTag

func ConvertTagToRepositoryTag(tag string) string

ConvertTagToRepositoryTag Convert tag to repository tag

func CreateImageNameFromSpecAndTags

func CreateImageNameFromSpecAndTags(tags []string, outputRegistry string, outputRepository string) []string

CreateImageNameFromSpecAndTags makes a target image to be used for push. The tag format in docker is somewhat confusing. For a description, see https://docs.docker.com/engine/reference/commandline/tag/ Given format a list of tags consisting of "a", "b" and "c", a registry host:5000 and repository "aurora/test", this function will return: host:5000/aurora/test:a host:5000/aurora/test:b host:5000/aurora/test:c

func GetDockerConfigPath

func GetDockerConfigPath() (string, error)

GetDockerConfigPath path to the docker configuration file

func GetPortOrDefault

func GetPortOrDefault(port string) string

GetPortOrDefault return port or 443 if not set

func GetUtcTimestamp

func GetUtcTimestamp() string

GetUtcTimestamp get utc timestamp

func InsecureOrDefault

func InsecureOrDefault(config *config.Config) bool

InsecureOrDefault use insecure if build is BinaryBuild

func LocalRegistryCredentials

func LocalRegistryCredentials() func(string) (*RegistryCredentials, error)

LocalRegistryCredentials load docker credentials from localhost

Types

type BasicAuthWrapper

type BasicAuthWrapper struct {
	// contains filtered or unexported fields
}

BasicAuthWrapper RoundTrip

func (*BasicAuthWrapper) RoundTrip

func (rt *BasicAuthWrapper) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip append registry credentials

type BuildConfig

type BuildConfig struct {
	AuroraVersion    *runtime.AuroraVersion
	DockerRepository string
	BuildFolder      string
	Image            runtime.DockerImage //We need to pull the newest image...
	OutputRegistry   string
	Env              map[string]string
	Labels           map[string]string
	Cmd              []string
	Entrypoint       []string
}

BuildConfig image build configuration

type Config

type Config struct {
	Hostname        string              // Hostname
	Domainname      string              // Domainname
	User            string              // User that will run the command(s) inside the container, also support user:group
	AttachStdin     bool                // Attach the standard input, makes possible user interaction
	AttachStdout    bool                // Attach the standard output
	AttachStderr    bool                // Attach the standard error
	ExposedPorts    map[string]struct{} `json:",omitempty"` // List of exposed ports
	Tty             bool                // Attach standard streams to a tty, including stdin if it is not closed.
	OpenStdin       bool                // Open stdin
	StdinOnce       bool                // If true, close stdin after the 1 attached client disconnects.
	Env             []string            // List of environment variable to set in the container
	Cmd             []string            // Command to run when starting the container
	Healthcheck     *HealthConfig       `json:",omitempty"` // Healthcheck describes how to check the container is healthy
	ArgsEscaped     bool                `json:",omitempty"` // True if command is already escaped (meaning treat as a command line) (Windows specific).
	Image           string              // Name of the image as it was passed by the operator (e.g. could be symbolic)
	Volumes         map[string]struct{} // List of volumes (mounts) used for the container
	WorkingDir      string              // Current directory (PWD) in the command will be launched
	Entrypoint      []string            // Entrypoint to run when starting the container
	NetworkDisabled bool                `json:",omitempty"` // Is network disabled
	MacAddress      string              `json:",omitempty"` // Mac Address of the container
	OnBuild         []string            // ONBUILD metadata that were defined on the image Dockerfile
	Labels          map[string]string   // List of labels set to this container
	StopSignal      string              `json:",omitempty"` // Signal to stop a container
	StopTimeout     *int                `json:",omitempty"` // Timeout (in seconds) to stop a container
	Shell           []string            `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
}

Config is the configuration of the container received from the client

type ContainerConfig

type ContainerConfig struct {
	Architecture    string                `json:"architecture"`
	Config          DockerContainerConfig `json:"config"`
	Container       string                `json:"container"`
	ContainerConfig OCIContainerConfig    `json:"container_config"`
	Created         string                `json:"created"`
	History         []history             `json:"history"`
	Os              string                `json:"os"`
	RootFs          rootFs                `json:"rootfs"`
}

ContainerConfig go representation of the ContainerConfig schema

func (*ContainerConfig) AddLayer

func (c *ContainerConfig) AddLayer(digest string) *ContainerConfig

AddLayer to container config

func (*ContainerConfig) CleanCopy

func (c *ContainerConfig) CleanCopy() *ContainerConfig

CleanCopy remove the OCIContainerConfig object

func (*ContainerConfig) Create

func (c *ContainerConfig) Create(buildConfig BuildConfig) ([]byte, error)

Create container configuration

func (*ContainerConfig) Save

func (c *ContainerConfig) Save(dstFolder string, filename string) error

Save container config to file

type DockerContainerConfig

type DockerContainerConfig struct {
	Hostname     string
	DomainName   string
	User         string
	AttachStdin  bool
	AttachStdout bool
	AttachStderr bool
	Tty          bool
	OpenStdin    bool
	StdinOnce    bool
	Env          []string
	Cmd          []string
	ArgsEscaped  bool
	Image        string
	Volumes      interface{}
	WorkingDir   string
	Entrypoint   []string
	OnBuild      []interface{}
	Labels       map[string]string
}

DockerContainerConfig go representation of the DockerContainerConfig schema

type HealthConfig

type HealthConfig struct {
	// Test is the test to perform to check that the container is healthy.
	// An empty slice means to inherit the default.
	// The options are:
	// {} : inherit healthcheck
	// {"NONE"} : disable healthcheck
	// {"CMD", args...} : exec arguments directly
	// {"CMD-SHELL", command} : run command with system's default shell
	Test []string `json:",omitempty"`

	// Zero means to inherit. Durations are expressed as integer nanoseconds.
	Interval    time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
	Timeout     time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
	StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down.

	// Retries is the number of consecutive failures needed to consider a container as unhealthy.
	// Zero means inherit.
	Retries int `json:",omitempty"`
}

HealthConfig holds configuration settings for the HEALTHCHECK feature.

type Layer

type Layer struct {
	MediaType string `json:"mediaType"`
	Size      int    `json:"size"`
	Digest    string `json:"digest"`
}

Layer represents a container layer

type Manifest

type Manifest struct {
	SchemaVersion int    `json:"schemaVersion"`
	MediaType     string `json:"mediaType"`
	Config        struct {
		MediaType string `json:"mediaType"`
		Size      int    `json:"size"`
		Digest    string `json:"digest"`
	} `json:"config"`
	History []struct {
		V1Compatibility string `json:"v1Compatibility"`
	}
}

Manifest schema representation

type ManifestV2

type ManifestV2 struct {
	SchemaVersion int    `json:"schemaVersion"`
	MediaType     string `json:"mediaType"`
	Config        struct {
		MediaType string `json:"mediaType"`
		Size      int    `json:"size"`
		Digest    string `json:"digest"`
	} `json:"config"`
	Layers []Layer `json:"layers"`
}

ManifestV2 is the go representation of a docker manifest

func (*ManifestV2) CleanCopy

func (m *ManifestV2) CleanCopy() *ManifestV2

CleanCopy make a clean copy of the manifest

func (*ManifestV2) Save

func (m *ManifestV2) Save(dstFolder string, name string) error

Save Write the manifest to file

type OCIContainerConfig

type OCIContainerConfig struct {
	Hostname     string
	Domainname   string
	User         string
	AttachStdin  bool
	AttachStdout bool
	AttachStderr bool
	Tty          bool
	OpenStdin    bool
	StdinOnce    bool
	Env          []string
	Cmd          []string
	ArgsEscaped  bool
	Image        string
	Volumes      interface{}
	WorkingDir   string
	Entrypoint   []string
	OnBuild      []interface{}
	Labels       map[string]string
}

OCIContainerConfig go reprsentation of the OCIContainerConfig schema

type Registry

type Registry interface {
	GetImageInfo(ctx context.Context, repository string, tag string) (*runtime.ImageInfo, error)
	GetTags(ctx context.Context, repository string) (*TagsAPIResponse, error)
	GetImageConfig(ctx context.Context, repository string, digest string) (map[string]interface{}, error)
	GetManifest(ctx context.Context, repository string, digest string) (*ManifestV2, error)
	GetContainerConfig(ctx context.Context, repository string, digest string) (*ContainerConfig, error)
	LayerExists(ctx context.Context, repository string, layerDigest string) (bool, error)
	PushLayer(ctx context.Context, layer io.Reader, dstRepository string, layerDigest string) error
	PushManifest(ctx context.Context, manifest []byte, repository string, tag string) error
	PullLayer(ctx context.Context, repository string, layerDigest string) (string, error)
}

Registry interface provides methods for interacting with a container registry

func NewRegistryClient

func NewRegistryClient(connectionInfo RegistryConnectionInfo) Registry

NewRegistryClient create new registry client

type RegistryClient

type RegistryClient struct {
	// contains filtered or unexported fields
}

RegistryClient configuration

func (*RegistryClient) GetContainerConfig

func (registry *RegistryClient) GetContainerConfig(ctx context.Context, repository string, digest string) (*ContainerConfig, error)

GetContainerConfig returns the image's container configuration

func (*RegistryClient) GetImageConfig

func (registry *RegistryClient) GetImageConfig(ctx context.Context, repository string, digest string) (map[string]interface{}, error)

GetImageConfig get image config

func (*RegistryClient) GetImageInfo

func (registry *RegistryClient) GetImageInfo(ctx context.Context, repository string, tag string) (*runtime.ImageInfo, error)

GetImageInfo get information about an image

func (*RegistryClient) GetManifest

func (registry *RegistryClient) GetManifest(ctx context.Context, repository string, tag string) (*ManifestV2, error)

GetManifest returns the image manifest

func (*RegistryClient) GetTags

func (registry *RegistryClient) GetTags(ctx context.Context, repository string) (*TagsAPIResponse, error)

GetTags return image tags for a given repository

func (*RegistryClient) LayerExists

func (registry *RegistryClient) LayerExists(ctx context.Context, repository string, layerDigest string) (bool, error)

LayerExists checks if layer exists in registry

func (*RegistryClient) PullLayer

func (registry *RegistryClient) PullLayer(ctx context.Context, repository string, layerDigest string) (string, error)

PullLayer pull image blob from registry

func (*RegistryClient) PushLayer

func (registry *RegistryClient) PushLayer(ctx context.Context, layer io.Reader, repository string, layerDigest string) error

PushLayer push image blob

func (*RegistryClient) PushManifest

func (registry *RegistryClient) PushManifest(ctx context.Context, manifest []byte, repository string, tag string) error

PushManifest push manifest

type RegistryConnectionInfo

type RegistryConnectionInfo struct {
	Port        string
	Host        string
	Insecure    bool
	Credentials *RegistryCredentials
}

RegistryConnectionInfo registry connection info

func (*RegistryConnectionInfo) DisableTLSValidation

func (r *RegistryConnectionInfo) DisableTLSValidation() bool

DisableTLSValidation disable tls check

func (*RegistryConnectionInfo) URL

func (r *RegistryConnectionInfo) URL() *url.URL

URL create registry url

type RegistryCredentials

type RegistryCredentials struct {
	Username      string `json:"username,omitempty"`
	Password      string `json:"password,omitempty"`
	Serveraddress string `json:"serveraddress,omitempty"`
}

RegistryCredentials registry access url and credentials

type TagsAPIResponse

type TagsAPIResponse struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

TagsAPIResponse list tags registry response

type V1Image

type V1Image struct {
	// ID is a unique 64 character identifier of the image
	ID string `json:"id,omitempty"`
	// Parent is the ID of the parent image
	Parent string `json:"parent,omitempty"`
	// Comment is the commit message that was set when committing the image
	Comment string `json:"comment,omitempty"`
	// Created is the timestamp at which the image was created
	Created time.Time `json:"created"`
	// Container is the id of the container used to commit
	Container string `json:"container,omitempty"`
	// ContainerConfig is the configuration of the container that is committed into the image
	ContainerConfig *Config `json:"container_config,omitempty"`
	// DockerVersion specifies the version of Docker that was used to build the image
	DockerVersion string `json:"docker_version,omitempty"`
	// Author is the name of the author that was specified when committing the image
	Author string `json:"author,omitempty"`
	// Config is the configuration of the container received from the client
	Config *Config `json:"config,omitempty"`
	// Architecture is the hardware that the image is built and runs on
	Architecture string `json:"architecture,omitempty"`
	// OS is the operating system used to build and run the image
	OS string `json:"os,omitempty"`
	// Size is the total size of the image including all layers it is composed of
	Size int64 `json:",omitempty"`
}

V1Image stores the V1 image configuration.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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