manifest1

package
v0.0.0-...-8e3368f Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Docker = func(args ...string) *exec.Cmd {
	return exec.Command("docker", args...)
}
View Source
var ManifestRandomPorts = true
View Source
var StaticColors = map[string]color.Attribute{
	"convox": color.FgWhite,
	"build":  color.FgWhite,
}

Functions

func DockerHostExposedPorts

func DockerHostExposedPorts() ([]int, error)

func RunAsync

func RunAsync(s Stream, cmd *exec.Cmd, done chan error, opts RunnerOptions)

RunAsync runs a command asynchronously and streams the output

func UpperName

func UpperName(name string) string

Types

type ArgOptions

type ArgOptions struct {
	Command     string
	IgnorePorts bool
	Name        string
}

type Build

type Build struct {
	Context    string            `yaml:"context,omitempty"`
	Dockerfile string            `yaml:"dockerfile,omitempty"`
	Args       map[string]string `yaml:"args,omitempty"`
}

see yaml.go for unmarshallers

func (*Build) Hash

func (b *Build) Hash() string

Hash returns a string suitable for using as a map key

func (*Build) UnmarshalYAML

func (b *Build) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface.

type BuildOptions

type BuildOptions struct {
	Cache       bool
	Environment map[string]string
	Service     string
	Verbose     bool
}

type Command

type Command struct {
	String string   `yaml:"-"`
	Array  []string `yaml:"-"`
}

Command represents the command docker will run either in string or array of strings

func (Command) MarshalYAML

func (c Command) MarshalYAML() (interface{}, error)

MarshalYAML implements the Marshaller interface for the Command type

func (*Command) UnmarshalYAML

func (c *Command) UnmarshalYAML(unmarshal func(interface{}) error) error

type Environment

type Environment []EnvironmentItem

Environment is a service's default environment

func (Environment) Len

func (ee Environment) Len() int

func (Environment) Less

func (ee Environment) Less(i, j int) bool

func (Environment) MarshalYAML

func (ee Environment) MarshalYAML() (interface{}, error)

MarshalYAML implements the Marshaller interface for the Environment type

func (Environment) Swap

func (ee Environment) Swap(i, j int)

func (*Environment) UnmarshalYAML

func (e *Environment) UnmarshalYAML(unmarshal func(interface{}) error) error

type EnvironmentItem

type EnvironmentItem struct {
	Name   string
	Value  string
	Needed bool // if true this value should be provided by the user in .env or convox env
}

EnvironmentItem is a single item in an environment

type Exec

type Exec struct{}

func (*Exec) CombinedOutput

func (e *Exec) CombinedOutput(cmd *exec.Cmd) ([]byte, error)

CombinedOutput synchronously calls the command and returns the output, useful for internal checks

func (*Exec) Run

func (e *Exec) Run(s Stream, cmd *exec.Cmd, opts RunnerOptions) error

Run synchronously calls the command and pipes the output to the stream,

func (*Exec) RunAsync

func (e *Exec) RunAsync(s Stream, cmd *exec.Cmd, done chan error, opts RunnerOptions)

RunAsync synchronously calls the command and pipes the output to the stream,

type ExternalNetwork

type ExternalNetwork Network

type InternalNetwork

type InternalNetwork map[string]ExternalNetwork

type Labels

type Labels map[string]string

func (Labels) Shift

func (labels Labels) Shift(shift int) error

Shift all ports referenced by labels by a given amount

func (*Labels) UnmarshalYAML

func (l *Labels) UnmarshalYAML(unmarshal func(interface{}) error) error

type Manifest

type Manifest struct {
	Version  string             `yaml:"version"`
	Networks Networks           `yaml:"networks,omitempty"`
	Services map[string]Service `yaml:"services"`
}

func Load

func Load(data []byte) (*Manifest, error)

Load a Manifest from raw data

func LoadFile

func LoadFile(path string) (*Manifest, error)

Load a Manifest from a file

func (Manifest) BalancerResourceName

func (m Manifest) BalancerResourceName(process string) string

func (Manifest) Balancers

func (m Manifest) Balancers() []ManifestBalancer

func (*Manifest) Build

func (m *Manifest) Build(dir, appName string, s Stream, opts BuildOptions) error

func (Manifest) EntryNames

func (m Manifest) EntryNames() []string

func (*Manifest) ExternalPorts

func (m *Manifest) ExternalPorts() []int

ExternalPorts returns a collection of ints of the Manifest's Services' external ports

func (Manifest) GetBalancer

func (m Manifest) GetBalancer(name string) *ManifestBalancer

func (Manifest) HasExternalPorts

func (m Manifest) HasExternalPorts() bool

HasExternalPorts returns true if the Manifest's Services have external ports

func (Manifest) HasProcesses

func (m Manifest) HasProcesses() bool

func (*Manifest) InternalPorts

func (m *Manifest) InternalPorts() []int

InternalPorts returns a collection of ints of the Manifest's Services' internal ports

func (Manifest) MarshalYAML

func (m Manifest) MarshalYAML() (interface{}, error)

MarshalYAML implements the Marshaller interface for the Manifest type

func (*Manifest) PortConflicts

func (m *Manifest) PortConflicts() ([]int, error)

Find any port conflits that would prevent this manifest from running TODO - Doesn't find UDP port conflicts

func (*Manifest) Push

func (m *Manifest) Push(template, app, build string, stream Stream) error

func (*Manifest) Raw

func (m *Manifest) Raw() ([]byte, error)

func (*Manifest) Run

func (m *Manifest) Run(dir, app string, opts RunOptions) Run

Run Instantiate a Run object based on this manifest to be run via 'convox start'

func (Manifest) Service

func (m Manifest) Service(name string) (*Service, error)

func (*Manifest) Shift

func (m *Manifest) Shift(shift int) error

Shift all external ports and labels in this Manifest by the given amount and their shift labels

func (*Manifest) UDPPorts

func (m *Manifest) UDPPorts() []int

UDPPorts returns a collection of ints of the Manifest's Services' UDP ports

func (Manifest) Validate

func (m Manifest) Validate() []error

type ManifestBalancer

type ManifestBalancer struct {
	Entry  Service
	Public bool
}

func (ManifestBalancer) DrainingTimeout

func (mb ManifestBalancer) DrainingTimeout() (string, error)

DrainingTimeout The amount of time to allow a draining balancer to keep active connections open.

func (ManifestBalancer) ExternalPorts

func (mb ManifestBalancer) ExternalPorts() []Port

ExternalPorts returns a collection of Port structs of the Manifest's external ports

func (ManifestBalancer) FirstPort

func (mb ManifestBalancer) FirstPort() string

FirstPort returns the first TCP Port defined on the first Service in the Manifest

func (ManifestBalancer) HealthInterval

func (mb ManifestBalancer) HealthInterval() (string, error)

HealthInterval The amount of time in between health checks. This is derived from the timeout value, which must be less than the interval

func (ManifestBalancer) HealthPath

func (mb ManifestBalancer) HealthPath() string

HealthPath The path to check for health. If unset, then implies TCP check

func (ManifestBalancer) HealthPort

func (mb ManifestBalancer) HealthPort() string

HealthPort The balancer port that maps to the container port specified in manifest

func (ManifestBalancer) HealthProtocol

func (mb ManifestBalancer) HealthProtocol() string

HealthProtocol returns the protocol to use for the health check

func (ManifestBalancer) HealthThresholdHealthy

func (mb ManifestBalancer) HealthThresholdHealthy() string

HealthThresholdHealthy The number of consecutive successful health checks that must occur before declaring an EC2 instance healthy.

func (ManifestBalancer) HealthThresholdUnhealthy

func (mb ManifestBalancer) HealthThresholdUnhealthy() string

HealthThresholdUnhealthy The number of consecutive failed health checks that must occur before declaring an EC2 instance unhealthy

func (ManifestBalancer) HealthTimeout

func (mb ManifestBalancer) HealthTimeout() string

HealthTimeout The default health timeout when one is not specified

func (ManifestBalancer) IdleTimeout

func (mb ManifestBalancer) IdleTimeout() (string, error)

IdleTimeout The amount of time to allow the balancer to keep idle connections open. This should be greater than the keep-alive timeout on your back-end, so that the balancer is responsible for closing connections

func (ManifestBalancer) InstanceProtocol

func (mb ManifestBalancer) InstanceProtocol(p Port) string

InstanceProtocol returns protocol the container is listening with

func (ManifestBalancer) InternalPorts

func (mb ManifestBalancer) InternalPorts() []Port

InternalPorts returns a collection of Port structs of the Manifest's internal ports

func (ManifestBalancer) ListenerProtocol

func (mb ManifestBalancer) ListenerProtocol(p Port) string

ListenerProtocol returns the protocol the balancer should use to listen

func (ManifestBalancer) LoadBalancerName

func (mb ManifestBalancer) LoadBalancerName(app string) string

func (ManifestBalancer) PortMappings

func (mb ManifestBalancer) PortMappings() []Port

func (ManifestBalancer) Ports

func (mb ManifestBalancer) Ports() []string

func (ManifestBalancer) ProcessName

func (mb ManifestBalancer) ProcessName() string

func (ManifestBalancer) Protocol

func (mb ManifestBalancer) Protocol(p Port) string

Protocol returns the desired listener protocol of the balancer

func (ManifestBalancer) ProxyProtocol

func (mb ManifestBalancer) ProxyProtocol(p Port) bool

ProxyProtocol returns true if the container is listening for PROXY protocol

func (ManifestBalancer) Randoms

func (mb ManifestBalancer) Randoms() map[string]int

func (ManifestBalancer) ResourceName

func (mb ManifestBalancer) ResourceName() string

func (ManifestBalancer) Scheme

func (mb ManifestBalancer) Scheme() string

type Memory

type Memory int64

func (*Memory) UnmarshalYAML

func (m *Memory) UnmarshalYAML(unmarshal func(interface{}) error) error

type MountableVolume

type MountableVolume struct {
	Host      string
	Container string
}

MountableVolume describes a mountable volume

func (MountableVolume) IsSystem

func (v MountableVolume) IsSystem() bool

IsSystem white lists special host volumes to pass through to the container instead of turning them into an application EFS mount

type Network

type Network struct {
	Name string
}

type Networks

type Networks map[string]InternalNetwork

type Output

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

func NewOutput

func NewOutput(quiet bool) Output

func (*Output) Stream

func (o *Output) Stream(prefix string) Stream

type Port

type Port struct {
	Name      string
	Balancer  int      // the port exposed by the load balancer for TCP, or by the host for UDP
	Container int      // the port used in the container and exposed by the Dockerfile
	Protocol  Protocol // the network protocol used (ie, TCP or UDP)
	Public    bool     // whether the port is internet-facing or internal-only on the load balancer (TCP only)
}

A Port represents a port as defined in docker-compose.yml Currently, UDP ports cannot be Public, as AWS ELBs only support TCP

func (Port) MarshalYAML

func (p Port) MarshalYAML() (interface{}, error)

MarshalYAML implements the Marshaller interface for the Port type

func (Port) String

func (p Port) String() string

String returns a string representation of a Port struct

type Ports

type Ports []Port

Ports is a collection of Port structs

func (Ports) HasPublic

func (pp Ports) HasPublic() bool

HasPublic returns true if any Port in the collection is Public

func (Ports) Shift

func (pp Ports) Shift(shift int)

Shift all external ports by the given amount

If it's an internal-only port then make it external before incrementing

func (*Ports) UnmarshalYAML

func (pp *Ports) UnmarshalYAML(unmarshal func(interface{}) error) error

type Process

type Process struct {
	Args []string
	Name string
	// contains filtered or unexported fields
}

func NewProcess

func NewProcess(app string, s Service, m Manifest) Process

func (*Process) GenerateArgs

func (p *Process) GenerateArgs(opts *ArgOptions) ([]string, error)

GenerateArgs generates the argument list based on a process property Possible to optionally override certain fields via opts

func (*Process) Sync

func (p *Process) Sync(local, remote string, ignores []string) (*sync.Sync, error)

type Protocol

type Protocol string

A Protocol represents a network protocol type (TCP, UDP, etc)

const (
	// TCP network protocol
	TCP Protocol = "tcp"

	// UDP network protocol
	UDP Protocol = "udp"
)

type Proxy

type Proxy struct {
	Name string

	Balancer  int
	Container int

	Protocol string
	Host     string
	Network  string
	Proxy    bool
	Secure   bool
}

func (*Proxy) Start

func (p *Proxy) Start() error

type Run

type Run struct {
	App       string
	Dir       string
	Opts      RunOptions
	Output    Output
	Processes map[string]Process
	// contains filtered or unexported fields
}

func NewRun

func NewRun(m Manifest, dir, app string, opts RunOptions) Run

NewRun Default constructor method for a Run object

func (*Run) Start

func (r *Run) Start() error

func (*Run) Stop

func (r *Run) Stop()

func (*Run) Wait

func (r *Run) Wait(ctx context.Context) error

type RunOptions

type RunOptions struct {
	Service string
	Command []string
	Build   bool
	Cache   bool
	Quiet   bool
	Sync    bool
}

type Runner

type Runner interface {
	CombinedOutput(cmd *exec.Cmd) ([]byte, error)
	Run(s Stream, cmd *exec.Cmd, opts RunnerOptions) error
	RunAsync(s Stream, cmd *exec.Cmd, dobe chan error, opts RunnerOptions)
}

Runner is the interface to run commands

var DefaultRunner Runner = new(Exec)

type RunnerOptions

type RunnerOptions struct {
	Verbose bool
}

RunnerOptions are optional settings for a Runner

type Service

type Service struct {
	Name string `yaml:"-"`

	Build       Build       `yaml:"build,omitempty"`
	Command     Command     `yaml:"command,omitempty"`
	Dockerfile  string      `yaml:"dockerfile,omitempty"`
	Entrypoint  string      `yaml:"entrypoint,omitempty"`
	Environment Environment `yaml:"environment,omitempty"`
	ExtraHosts  []string    `yaml:"extra_hosts,omitempty"`
	Image       string      `yaml:"image,omitempty"`
	Labels      Labels      `yaml:"labels,omitempty"`
	Links       []string    `yaml:"links,omitempty"`
	Networks    Networks    `yaml:"-"`
	Ports       Ports       `yaml:"ports,omitempty"`
	Privileged  bool        `yaml:"privileged,omitempty"`
	Volumes     []string    `yaml:"volumes,omitempty"`

	Cpu    int64  `yaml:"cpu_shares,omitempty"`
	Memory Memory `yaml:"mem_limit,omitempty"`

	//TODO from models manifest, not passive and used at runtime
	Exports  map[string]string        `yaml:"-"`
	LinkVars map[string]template.HTML `yaml:"-"`

	Primary bool `yaml:"-"`
	// contains filtered or unexported fields
}

func (Service) ContainerPorts

func (s Service) ContainerPorts() []string

func (Service) DefaultParams

func (s Service) DefaultParams() string

DefaultParams returns a string of comma-delimited Count, CPU, and Memory params

func (Service) DeploymentMaximum

func (s Service) DeploymentMaximum() string

DeploymentMaximum returns the max percent of containers that are allowed during deployment This will be most likely be overridden and set to 100 for singleton processes like schedulers that cannot have 2 running at once

func (Service) DeploymentMinimum

func (s Service) DeploymentMinimum() string

DeploymentMinimum returns the min percent of containers that are allowed during deployment

func (Service) ExternalPorts

func (s Service) ExternalPorts() []Port

ExternalPorts returns a collection of Port structs from the Service which are TCP and Public

func (Service) ExtraHostsMap

func (s Service) ExtraHostsMap() map[string]string

ExtraHostsMap is a convenience method to allow for easier use of the hosts in AWS templates

func (Service) HasBalancer

func (s Service) HasBalancer() bool

HasBalancer returns false if the Service contains no public ports, or if the `convox.balancer` label is set to false

func (Service) InternalPorts

func (s Service) InternalPorts() []Port

InternalPorts returns a collection of Port structs from the Service which are TCP and not Public

func (Service) IsAgent

func (s Service) IsAgent() bool

IsAgent returns true if Service is a per-host agent, otherwise it returns false

func (Service) LabelDefault

func (s Service) LabelDefault(label, def string) string

LabelDefault returns the value of a given label if it exists, otherwise the specified default

func (Service) LabelsByPrefix

func (s Service) LabelsByPrefix(prefix string) map[string]string

LabelsByPrefix retuns a map of string values with the labels filtered by prefix

func (Service) MountableVolumes

func (s Service) MountableVolumes() []MountableVolume

MountableVolumes return the mountable volumes for a service

func (*Service) NetworkName

func (s *Service) NetworkName() string

NetworkName returns custom network name from the networks, defined in compose file. REturns empty string, if no custom network is defined. We pick the last one, as we currently support only single one.

func (Service) ParamName

func (s Service) ParamName(name string) string

func (*Service) Process

func (s *Service) Process(app string, m Manifest) Process

func (*Service) Proxies

func (s *Service) Proxies(app string) []Proxy

func (*Service) Randoms

func (s *Service) Randoms() map[string]int

func (Service) RegistryImage

func (s Service) RegistryImage(appName, buildId string, outputs map[string]string) string

func (*Service) SyncPaths

func (s *Service) SyncPaths() (map[string]string, error)

func (Service) TCPPorts

func (s Service) TCPPorts() []Port

TCPPorts returns a collection of Port structs from the Service which are TCP

func (*Service) Tag

func (s *Service) Tag(appName string) string

Tag generates a string used to tag an image.

func (Service) UDPPorts

func (s Service) UDPPorts() []Port

UDPPorts returns a collection of Port structs from the Service which are UDP

func (Service) UseSecureEnvironment

func (s Service) UseSecureEnvironment() bool

UseSecureEnvironment - Determines if the service intends to use a secure environment

type Services

type Services []Service

Services are a list of Services

func (Services) Len

func (ss Services) Len() int

func (Services) Less

func (ss Services) Less(i, j int) bool

func (Services) Swap

func (ss Services) Swap(i, j int)

type Stream

type Stream chan string

Jump to

Keyboard shortcuts

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