container

package
v0.5.43 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const TypeContainer string = "container"

TypeContainer is the resource string for a Container resource

View Source
const TypeSidecar string = "sidecar"

TypeSidecar is the resource string for a Sidecar resource

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	// embedded type holding name, etc
	types.ResourceMetadata `hcl:",remain"`

	Networks        []NetworkAttachment `hcl:"network,block" json:"networks,omitempty"`           // Attach to the correct network // only when Image is specified
	Image           *Image              `hcl:"image,block" json:"image"`                          // Image to use for the container
	Entrypoint      []string            `hcl:"entrypoint,optional" json:"entrypoint,omitempty"`   // entrypoint to use when starting the container
	Command         []string            `hcl:"command,optional" json:"command,omitempty"`         // command to use when starting the container
	Environment     map[string]string   `hcl:"environment,optional" json:"environment,omitempty"` // environment variables to set when starting the container
	Volumes         []Volume            `hcl:"volume,block" json:"volumes,omitempty"`             // volumes to attach to the container
	Ports           []Port              `hcl:"port,block" json:"ports,omitempty"`                 // ports to expose
	PortRanges      []PortRange         `hcl:"port_range,block" json:"port_ranges,omitempty"`     // range of ports to expose
	DNS             []string            `hcl:"dns,optional" json:"dns,omitempty"`                 // Add custom DNS servers to the container
	Privileged      bool                `hcl:"privileged,optional" json:"privileged,omitempty"`   // run the container in privileged mode?
	MaxRestartCount int                 `hcl:"max_restart_count,optional" json:"max_restart_count,omitempty"`

	// resource constraints
	Resources *Resources `hcl:"resources,block" json:"resources,omitempty"` // resource constraints for the container

	// health checks for the container
	HealthCheck *healthcheck.HealthCheckContainer `hcl:"health_check,block" json:"health_check,omitempty"`

	// User block for mapping the user id and group id inside the container
	RunAs *User `hcl:"run_as,block" json:"run_as,omitempty"`

	// ContainerName is the fully qualified domain name for the container, this can be used
	// to access the container from other sources
	ContainerName string `hcl:"container_name,optional" json:"container_name,omitempty"`
}

Container defines a structure for creating Docker containers

func (*Container) Process

func (c *Container) Process() error

type Image

type Image struct {
	Name string `hcl:"name" json:"name"`
	// Username is the Docker registry user to use for private repositories
	Username string `hcl:"username,optional" json:"username,omitempty"`
	// Password is the Docker registry password to use for private repositories
	Password string `hcl:"password,optional" json:"password,omitempty"`

	// ID is the unique identifier for the image, this is independent of tag
	// and changes each time the image is built. An image that has been tagged
	// multiple times also shares the same ID.
	ID string `hcl:"id,optional" json:"id,omitempty"`
}

Image defines a docker image which will be pushed to the clusters Docker registry

func (Image) ToClientImage

func (i Image) ToClientImage() types.Image

type Images

type Images []Image

func (Images) ToClientImages

func (i Images) ToClientImages() []types.Image

type NetworkAttachment

type NetworkAttachment struct {
	ID        string   `hcl:"id" json:"id"`
	IPAddress string   `hcl:"ip_address,optional" json:"ip_address,omitempty"` // Optional address to assign
	Aliases   []string `hcl:"aliases,optional" json:"aliases,omitempty"`       // Network aliases for the resource

	// Name will equal the name of the network as created by jumppad
	Name string `hcl:"name,optional" json:"name,omitempty"`

	// AssignedAddress will equal if IPAddress is set, else it will be the value automatically
	// assigned from the network
	AssignedAddress string `hcl:"assigned_address,optional" json:"assigned_address,omitempty"`
}

func (NetworkAttachment) ToClientNetworkAttachment

func (n NetworkAttachment) ToClientNetworkAttachment() types.NetworkAttachment

type NetworkAttachments

type NetworkAttachments []NetworkAttachment

func (NetworkAttachments) ToClientNetworkAttachments

func (n NetworkAttachments) ToClientNetworkAttachments() []types.NetworkAttachment

type Port

type Port struct {
	Local         string `hcl:"local" json:"local"`                                                             // Local port in the container
	Remote        string `hcl:"remote" json:"remote"`                                                           // Remote port of the service
	Host          string `hcl:"host,optional" json:"host,omitempty"`                                            // Host port
	Protocol      string `hcl:"protocol,optional" json:"protocol,omitempty"`                                    // Protocol tcp, udp
	OpenInBrowser string `hcl:"open_in_browser,optional" json:"open_in_browser" mapstructure:"open_in_browser"` // When a host port is defined open this port with the given path in a browser
}

Port is a port mapping

func (Port) ToClientPort

func (p Port) ToClientPort() types.Port

type PortRange

type PortRange struct {
	Range      string `hcl:"range" json:"local" mapstructure:"local"`                                      // Local port in the container
	EnableHost bool   `hcl:"enable_host,optional" json:"enable_host,omitempty" mapstructure:"enable_host"` // Host port
	Protocol   string `hcl:"protocol,optional" json:"protocol,omitempty"`                                  // Protocol tcp, udp
}

PortRange allows a range of ports to be mapped

func (PortRange) ToClientPortRange

func (p PortRange) ToClientPortRange() types.PortRange

type PortRanges

type PortRanges []PortRange

func (PortRanges) ToClientPortRanges

func (p PortRanges) ToClientPortRanges() []types.PortRange

type Ports

type Ports []Port

func (Ports) ToClientPorts

func (p Ports) ToClientPorts() []types.Port

type Provider

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

Container is a provider for creating and destroying Docker containers

func (*Provider) Changed

func (c *Provider) Changed() (bool, error)

func (*Provider) Create

func (p *Provider) Create() error

Create implements provider method and creates a Docker container with the given config

func (*Provider) Destroy

func (c *Provider) Destroy() error

Destroy stops and removes the container

func (*Provider) Init

func (p *Provider) Init(cfg htypes.Resource, l logger.Logger) error

func (*Provider) Lookup

func (p *Provider) Lookup() ([]string, error)

Lookup the ID based on the config

func (*Provider) Refresh

func (c *Provider) Refresh() error

type Resources

type Resources struct {
	CPU    int   `hcl:"cpu,optional" json:"cpu,omitempty"`         // cpu limit for the container where 1 CPU = 1000
	CPUPin []int `hcl:"cpu_pin,optional" json:"cpu_pin,omitempty"` // pin the container to one or more cpu cores
	Memory int   `hcl:"memory,optional" json:"memory,omitempty"`   // max memory the container can consume in MB
}

Resources allows the setting of resource constraints for the Container

type Sidecar

type Sidecar struct {
	// embedded type holding name, etc
	types.ResourceMetadata `hcl:",remain"`

	Target Container `hcl:"target" json:"target"`

	Image       Image             `hcl:"image,block" json:"image"`                          // image to use for the container
	Entrypoint  []string          `hcl:"entrypoint,optional" json:"entrypoint,omitempty"`   // entrypoint to use when starting the container
	Command     []string          `hcl:"command,optional" json:"command,omitempty"`         // command to use when starting the container
	Environment map[string]string `hcl:"environment,optional" json:"environment,omitempty"` // environment variables to set when starting the container
	Volumes     []Volume          `hcl:"volume,block" json:"volumes,omitempty"`             // volumes to attach to the container

	Privileged bool `hcl:"privileged,optional" json:"privileged,omitempty"` // run the container in privileged mode?

	// resource constraints
	Resources *Resources `hcl:"resources,block" json:"resources,omitempty"` // resource constraints for the container

	// health checks for the container
	HealthCheck *healthcheck.HealthCheckContainer `hcl:"health_check,block" json:"health_check,omitempty"`

	MaxRestartCount int `hcl:"max_restart_count,optional" json:"max_restart_count,omitempty"`

	// ContainerName is the fully qualified domain name for the container the sidecar is linked to, this can be used
	// to access the sidecar from other sources
	ContainerName string `hcl:"c,optional" json:"fqrn,omitempty"`
}

Sidecar defines a structure for creating Docker containers

func (*Sidecar) Process

func (c *Sidecar) Process() error

type User

type User struct {
	// Username or UserID of the user to run the container as
	User string `hcl:"user" json:"user,omitempty"`
	// Group is the GroupID of the user to run the container as
	Group string `hcl:"group" json:"group,omitempty"`
}

type Volume

type Volume struct {
	Source                      string `hcl:"source" json:"source"`                                                                    // source path on the local machine for the volume
	Destination                 string `hcl:"destination" json:"destination"`                                                          // path to mount the volume inside the container
	Type                        string `hcl:"type,optional" json:"type,omitempty"`                                                     // type of the volume to mount [bind, volume, tmpfs]
	ReadOnly                    bool   `hcl:"read_only,optional" json:"read_only,omitempty"`                                           // specify that the volume is mounted read only
	BindPropagation             string `hcl:"bind_propagation,optional" json:"bind_propagation,omitempty"`                             // propagation mode for bind mounts [shared, private, slave, rslave, rprivate]
	BindPropagationNonRecursive bool   `hcl:"bind_propagation_non_recursive,optional" json:"bind_propagation_non_recursive,omitempty"` // recursive bind mount, default true
}

Volume defines a folder, Docker volume, or temp folder to mount to the Container

func (Volume) ToClientVolume

func (v Volume) ToClientVolume() types.Volume

type Volumes

type Volumes []Volume

func (Volumes) ToClientVolumes

func (v Volumes) ToClientVolumes() []types.Volume

Jump to

Keyboard shortcuts

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