docker

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MPL-2.0 Imports: 50 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_waypoint_builtin_docker_plugin_proto protoreflect.FileDescriptor
View Source
var Options = []sdk.Option{
	sdk.WithComponents(&Builder{}, &Registry{}, &Platform{}),
}

Options are the SDK options to use for instantiation.

Functions

func HasImg added in v0.3.0

func HasImg() bool

HasImg returns true if "img" is available on the PATH.

This doesn't do any fancy checking that "img" is the "img" we expect. We can make the checking here more advanced later.

func TempDockerConfig added in v0.3.0

func TempDockerConfig(
	log hclog.Logger,
	target *Image,
	encodedAuth string,
) (string, error)

TempDockerConfig creates a new Docker configuration with the configured auth in it. It saves this Docker config to a temporary path and returns the path to that Docker file.

We have to do this because `img` doesn't support setting auth for a single operation. Therefore, we must set auth in the Docker config, but we don't want to pollute any concurrent runs or the main file. So we create a copy.

This can return ("", nil) if there is no custom Docker config necessary.

Callers should defer file deletion for this temporary file.

Types

type Builder

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

Builder uses `docker build` to build a Docker iamge.

func (*Builder) Build

func (b *Builder) Build(
	ctx context.Context,
	ui terminal.UI,
	src *component.Source,
	log hclog.Logger,
) (*Image, error)

Build

func (*Builder) BuildFunc

func (b *Builder) BuildFunc() interface{}

BuildFunc implements component.Builder

func (*Builder) Config

func (b *Builder) Config() (interface{}, error)

Config implements Configurable

func (*Builder) Documentation

func (b *Builder) Documentation() (*docs.Documentation, error)

type BuilderConfig

type BuilderConfig struct {
	// Control whether or not to inject the entrypoint binary into the resulting image
	DisableCEB bool `hcl:"disable_entrypoint,optional"`

	// Controls whether or not the image should be build with buildkit or docker v1
	UseBuildKit bool `hcl:"buildkit,optional"`

	// The name/path to the Dockerfile if it is not the root of the project
	Dockerfile string `hcl:"dockerfile,optional"`

	// Controls the passing of build time variables
	BuildArgs map[string]*string `hcl:"build_args,optional"`

	// Controls the passing of build context
	Context string `hcl:"context,optional"`
}

Config is the configuration structure for the registry.

type ClientConfig added in v0.1.3

type ClientConfig struct {
	// Host to use when connecting to Docker
	// This can be used to connect to remote Docker instances
	Host string `hcl:"host,optional"`

	// Path to load the certificates for the Docker Engine
	CertPath string `hcl:"cert_path,optional"`

	// Docker API version to use for connection
	APIVersion string `hcl:"api_version,optional"`
}

type Config

type Config struct {
	// Image is the name of the image plus tag that the image will be pushed as.
	Image string `hcl:"image,attr"`

	// Tag is the tag to apply to the image.
	Tag string `hcl:"tag,attr"`

	// Local if true will not push this image to a remote registry.
	Local bool `hcl:"local,optional"`

	// The docker specific encoded authentication string to use to talk to the registry.
	EncodedAuth string `hcl:"encoded_auth,optional"`
}

Config is the configuration structure for the registry.

type Deployment

type Deployment struct {
	Id            string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Name          string   `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Container     string   `protobuf:"bytes,3,opt,name=container,proto3" json:"container,omitempty"`
	ResourceState *any.Any `protobuf:"bytes,4,opt,name=resource_state,json=resourceState,proto3" json:"resource_state,omitempty"`
	// contains filtered or unexported fields
}

func (*Deployment) Descriptor deprecated

func (*Deployment) Descriptor() ([]byte, []int)

Deprecated: Use Deployment.ProtoReflect.Descriptor instead.

func (*Deployment) GetContainer

func (x *Deployment) GetContainer() string

func (*Deployment) GetId

func (x *Deployment) GetId() string

func (*Deployment) GetName

func (x *Deployment) GetName() string

func (*Deployment) GetResourceState added in v0.4.0

func (x *Deployment) GetResourceState() *any.Any

func (*Deployment) ProtoMessage

func (*Deployment) ProtoMessage()

func (*Deployment) ProtoReflect added in v0.3.0

func (x *Deployment) ProtoReflect() protoreflect.Message

func (*Deployment) Reset

func (x *Deployment) Reset()

func (*Deployment) String

func (x *Deployment) String() string

type Image

type Image struct {
	Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"`
	Tag   string `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"`
	// location is where this image is currently. This can be used to
	// determine if the image is pulled or not based on this proto rather
	// than environment inspection.
	//
	// If this is not set, it will be assumed that the image is in a local
	// Docker daemon registry for backwards compatiblity reasons.
	//
	// Types that are assignable to Location:
	//	*Image_Registry
	//	*Image_Docker
	//	*Image_Img
	Location isImage_Location `protobuf_oneof:"location"`
	// contains filtered or unexported fields
}

Image is the artifact type for the registry.

func (*Image) Descriptor deprecated

func (*Image) Descriptor() ([]byte, []int)

Deprecated: Use Image.ProtoReflect.Descriptor instead.

func (*Image) GetDocker added in v0.3.0

func (x *Image) GetDocker() *empty.Empty

func (*Image) GetImage

func (x *Image) GetImage() string

func (*Image) GetImg added in v0.3.0

func (x *Image) GetImg() *empty.Empty

func (*Image) GetLocation added in v0.3.0

func (m *Image) GetLocation() isImage_Location

func (*Image) GetRegistry added in v0.3.0

func (x *Image) GetRegistry() *empty.Empty

func (*Image) GetTag

func (x *Image) GetTag() string

func (*Image) Name

func (i *Image) Name() string

Name is the full name including the tag.

func (*Image) ProtoMessage

func (*Image) ProtoMessage()

func (*Image) ProtoReflect added in v0.3.0

func (x *Image) ProtoReflect() protoreflect.Message

func (*Image) Reset

func (x *Image) Reset()

func (*Image) String

func (x *Image) String() string

type Image_Docker added in v0.3.0

type Image_Docker struct {
	// docker is set if the image is in a local Docker daemon registry.
	Docker *empty.Empty `protobuf:"bytes,4,opt,name=docker,proto3,oneof"`
}

type Image_Img added in v0.3.0

type Image_Img struct {
	// img is set if the image is in a local img content store directory.
	// img: https://github.com/genuinetools/img
	Img *empty.Empty `protobuf:"bytes,5,opt,name=img,proto3,oneof"`
}

type Image_Registry added in v0.3.0

type Image_Registry struct {
	// registry is set if the image is in a remote registry. This value
	// might mean the image is local, too, but we never formally "pulled"
	// it so we aren't sure. The image should be treated as remote.
	Registry *empty.Empty `protobuf:"bytes,3,opt,name=registry,proto3,oneof"`
}

type Platform

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

Platform is the Platform implementation for Docker.

func (*Platform) Auth

func (p *Platform) Auth() error

func (*Platform) AuthFunc

func (p *Platform) AuthFunc() interface{}

AuthFunc implements component.Authenticator

func (*Platform) Config

func (p *Platform) Config() (interface{}, error)

Config implements Configurable

func (*Platform) Deploy

func (p *Platform) Deploy(
	ctx context.Context,
	log hclog.Logger,
	src *component.Source,
	job *component.JobInfo,
	img *Image,
	deployConfig *component.DeploymentConfig,
	ui terminal.UI,
) (*Deployment, error)

Deploy deploys an image to Docker.

func (*Platform) DeployFunc

func (p *Platform) DeployFunc() interface{}

DeployFunc implements component.Platform

func (*Platform) Destroy

func (p *Platform) Destroy(
	ctx context.Context,
	log hclog.Logger,
	deployment *Deployment,
	ui terminal.UI,
) error

Destroy deletes a Docker deployment.

func (*Platform) DestroyFunc

func (p *Platform) DestroyFunc() interface{}

DestroyFunc implements component.Destroyer

func (*Platform) Documentation

func (p *Platform) Documentation() (*docs.Documentation, error)

func (*Platform) Status added in v0.4.0

func (p *Platform) Status(
	ctx context.Context,
	log hclog.Logger,
	deployment *Deployment,
	ui terminal.UI,
) (*sdk.StatusReport, error)

func (*Platform) StatusFunc added in v0.4.0

func (p *Platform) StatusFunc() interface{}

StatusFunc implements component.Status

func (*Platform) ValidateAuth

func (p *Platform) ValidateAuth() error

func (*Platform) ValidateAuthFunc

func (p *Platform) ValidateAuthFunc() interface{}

ValidateAuthFunc implements component.Authenticator

type PlatformConfig

type PlatformConfig struct {
	// A list of folders to mount to the container.
	Binds []string `hcl:"binds,optional"`

	// ClientConfig allow the user to specify the connection to the Docker
	// engine. By default we try to load this from env vars:
	// DOCKER_HOST to set the url to the docker server.
	// DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest.
	// DOCKER_CERT_PATH to load the TLS certificates from.
	// DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default.
	ClientConfig *ClientConfig `hcl:"client_config,block"`

	// The command to run in the container. This is an array of arguments
	// that are executed directly. These are not executed in the context of
	// a shell. If you want to use a shell, add that to this command manually.
	Command []string `hcl:"command,optional"`

	// Force pull the image from the remote repository
	ForcePull bool `hcl:"force_pull,optional"`

	// A map of key/value pairs, stored in docker as a string. Each key/value pair must
	// be unique. Validiation occurs at the docker layer, not in Waypoint. Label
	// keys are alphanumeric strings which may contain periods (.) and hyphens (-).
	// See the docker docs for more info: https://docs.docker.com/config/labels-custom-metadata/
	Labels map[string]string `hcl:"labels,optional"`

	// An array of strings with network names to connect the container to
	Networks []string `hcl:"networks,optional"`

	// A map of resources to configure the container with such as memory and cpu
	// limits.
	Resources map[string]string `hcl:"resources,optional"`

	// A path to a directory that will be created for the service to store
	// temporary data.
	ScratchSpace string `hcl:"scratch_path,optional"`

	// Environment variables that are meant to configure the application in a static
	// way. This might be control an image that has mulitple modes of operation,
	// selected via environment variable. Most configuration should use the waypoint
	// config commands.
	StaticEnvVars map[string]string `hcl:"static_environment,optional"`

	// Additional ports the application is listening on to expose on the container
	ExtraPorts []uint `hcl:"extra_ports,optional"`

	// Port that your service is running on within the actual container.
	// Defaults to port 3000.
	// TODO Evaluate if this should remain as a default 3000, should be a required field,
	// or default to another port.
	ServicePort uint `hcl:"service_port,optional"`
}

Config is the configuration structure for the Platform.

type Registry

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

Registry represents access to a Docker registry.

func (*Registry) Config

func (r *Registry) Config() (interface{}, error)

Config implements Configurable

func (*Registry) Documentation

func (r *Registry) Documentation() (*docs.Documentation, error)

func (*Registry) Push

func (r *Registry) Push(
	ctx context.Context,
	img *Image,
	ui terminal.UI,
	log hclog.Logger,
) (*Image, error)

Push pushes an image to the registry.

func (*Registry) PushFunc

func (r *Registry) PushFunc() interface{}

PushFunc implements component.Registry

type Release

type Release struct {
	Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
	// contains filtered or unexported fields
}

func (*Release) Descriptor deprecated

func (*Release) Descriptor() ([]byte, []int)

Deprecated: Use Release.ProtoReflect.Descriptor instead.

func (*Release) GetUrl

func (x *Release) GetUrl() string

func (*Release) ProtoMessage

func (*Release) ProtoMessage()

func (*Release) ProtoReflect added in v0.3.0

func (x *Release) ProtoReflect() protoreflect.Message

func (*Release) Reset

func (x *Release) Reset()

func (*Release) String

func (x *Release) String() string

type Resource added in v0.4.0

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

Resource contains the internal resource states.

func (*Resource) Descriptor deprecated added in v0.4.0

func (*Resource) Descriptor() ([]byte, []int)

Deprecated: Use Resource.ProtoReflect.Descriptor instead.

func (*Resource) ProtoMessage added in v0.4.0

func (*Resource) ProtoMessage()

func (*Resource) ProtoReflect added in v0.4.0

func (x *Resource) ProtoReflect() protoreflect.Message

func (*Resource) Reset added in v0.4.0

func (x *Resource) Reset()

func (*Resource) String added in v0.4.0

func (x *Resource) String() string

type Resource_Container added in v0.4.0

type Resource_Container struct {
	Id   string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*Resource_Container) Descriptor deprecated added in v0.4.0

func (*Resource_Container) Descriptor() ([]byte, []int)

Deprecated: Use Resource_Container.ProtoReflect.Descriptor instead.

func (*Resource_Container) GetId added in v0.4.0

func (x *Resource_Container) GetId() string

func (*Resource_Container) GetName added in v0.4.0

func (x *Resource_Container) GetName() string

func (*Resource_Container) ProtoMessage added in v0.4.0

func (*Resource_Container) ProtoMessage()

func (*Resource_Container) ProtoReflect added in v0.4.0

func (x *Resource_Container) ProtoReflect() protoreflect.Message

func (*Resource_Container) Reset added in v0.4.0

func (x *Resource_Container) Reset()

func (*Resource_Container) String added in v0.4.0

func (x *Resource_Container) String() string

type Resource_Network added in v0.4.0

type Resource_Network struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*Resource_Network) Descriptor deprecated added in v0.4.0

func (*Resource_Network) Descriptor() ([]byte, []int)

Deprecated: Use Resource_Network.ProtoReflect.Descriptor instead.

func (*Resource_Network) GetName added in v0.4.0

func (x *Resource_Network) GetName() string

func (*Resource_Network) ProtoMessage added in v0.4.0

func (*Resource_Network) ProtoMessage()

func (*Resource_Network) ProtoReflect added in v0.4.0

func (x *Resource_Network) ProtoReflect() protoreflect.Message

func (*Resource_Network) Reset added in v0.4.0

func (x *Resource_Network) Reset()

func (*Resource_Network) String added in v0.4.0

func (x *Resource_Network) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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