sous

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2016 License: MIT Imports: 18 Imported by: 10

Documentation

Index

Constants

View Source
const (
	UnknownRepo          = AdvisoryName(`source workspace lacked repo`)
	NoRepoAdv            = AdvisoryName(`no repository`)
	NotRequestedRevision = AdvisoryName(`requested revision not built`)
	Unversioned          = AdvisoryName(`no versioned tag`)
	TagMismatch          = AdvisoryName(`tag mismatch`)
	TagNotHead           = AdvisoryName(`tag not on built revision`)
	EphemeralTag         = AdvisoryName(`ephemeral tag`)
	UnpushedRev          = AdvisoryName(`unpushed revision`)
	BogusRev             = AdvisoryName(`bogus revision`)
	DirtyWS              = AdvisoryName(`dirty workspace`)
)
View Source
const DefaultDelim = ","

DefaultDelim is the default delimiter between parts of the string representation of a SourceID or a SourceLocation.

Variables

View Source
var (
	// Log collects various loggers to use for different levels of logging
	Log = func() LogSet {
		warnLogger := log.New(os.Stderr, "warn: ", 0)
		return LogSet{

			Vomit:  log.New(ioutil.Discard, "vomit: ", log.Lshortfile),
			Debug:  log.New(ioutil.Discard, "debug: ", log.Lshortfile),
			Info:   warnLogger,
			Notice: warnLogger,
			Warn:   warnLogger,
		}
	}()
)

Functions

func DumpDeployments

func DumpDeployments(io io.Writer, ds Deployments)

func SetupLogging

func SetupLogging(il ILogger)

SetupLogging sets up an ILogger to log into the Sous logging regime

func TabbedDeploymentHeaders

func TabbedDeploymentHeaders() string

TabbedDeploymentHeaders returns the names of the fields for Tabbed, suitable for use with text/tabwriter.

Types

type Advisories

type Advisories []AdvisoryName

type AdvisoryName

type AdvisoryName string

An AdvisoryName is the type for advisory tokens

type Annotation

type Annotation struct {
	// RequestID stores the Singularity Request ID that was used for this
	// deployment.
	RequestID string
}

An Annotation stores notes about data available from the source of of a Deployment. For instance, the Id field from the source SingularityRequest for a Deployment can be stored to refer to the source post-diff. They don't participate in equality checks on the deployment.

type BuildArtifact

type BuildArtifact struct {
	Name, Type string
	Qualities  []Quality
}

BuildArtifact describes the actual built binary Sous will deploy

type BuildConfig

type BuildConfig struct {
	Repo, Offset, Tag, Revision string
	Strict, ForceClone          bool
	Context                     *BuildContext
}

BuildConfig captures the user's intent as they build a repo

func (*BuildConfig) Advisories

func (c *BuildConfig) Advisories(ctx *BuildContext) (advs []string)

Advisories does this:

func (*BuildConfig) GuardRegister

func (c *BuildConfig) GuardRegister(bc *BuildContext) error

GuardRegister returns an error if any development-only advisories exist

func (*BuildConfig) GuardStrict

func (c *BuildConfig) GuardStrict(bc *BuildContext) error

GuardStrict returns an error if there are imperfections in the proposed build

func (*BuildConfig) NewContext

func (c *BuildConfig) NewContext() *BuildContext

NewContext returns a new BuildContext updated based on the user's intent as expressed in the Config

func (*BuildConfig) Validate

func (c *BuildConfig) Validate() error

Validate checks that the Config is well formed

type BuildContext

type BuildContext struct {
	Sh         shell.Shell
	Source     SourceContext
	Scratch    ScratchContext
	Machine    Machine
	User       user.User
	Changes    Changes
	Advisories []string
}

BuildContext contains all the data required to perform a build.

func (*BuildContext) Version

func (bc *BuildContext) Version() SourceID

Version returns the SourceID for this build

type BuildManager

type BuildManager struct {
	BuildConfig *BuildConfig
	Selector
	Labeller
	Registrar
}

BuildManager collects and orchestrates the various components that are involved with making a build happen

func (*BuildManager) Build

func (m *BuildManager) Build() (*BuildResult, error)

Build implements sous.Builder.Build

type BuildResult

type BuildResult struct {
	ImageID                   string
	VersionName, RevisionName string
	Advisories                []string
	Elapsed                   time.Duration
}

BuildResult represents the result of a build made with a Buildpack.

func (*BuildResult) String

func (br *BuildResult) String() string

type Buildpack

type Buildpack interface {
	Detect(*BuildContext) (*DetectResult, error)
	Build(*BuildContext) (*BuildResult, error)
}

Buildpack is a set of instructions used to build a particular kind of project.

type ChangeError

type ChangeError struct {
	Deployments *DeploymentPair
	Err         error
}

ChangeError describes an error that occurred while trying to change one deployment into another

func (*ChangeError) Error

func (e *ChangeError) Error() string

func (*ChangeError) ExistingDeployment

func (e *ChangeError) ExistingDeployment() *Deployment

ExistingDeployment returns the deployment that was already existent in a change error

func (*ChangeError) IntendedDeployment

func (e *ChangeError) IntendedDeployment() *Deployment

IntendedDeployment returns the deployment that was intended in a ChangeError

type Changes

type Changes struct {
	SousUpdated, NewCommit, NewTag, NewFiles, ChangedFiles []string
}

Changes represents a set of changes that have happened since this project was last built on the current machine by the current user.

type Cluster

type Cluster struct {
	// Name is the unique name of this cluster.
	Name string
	// Kind is the kind of cluster. Currently the only legal value is
	// "singularity"
	Kind string
	// BaseURL is the main entrypoint URL for interacting with this cluster.
	BaseURL string
	// Env is the default environment for all deployments in this region.
	Env EnvDefaults
	// AllowedAdvisories lists the artifact advisories which are permissible in
	// this cluster
	AllowedAdvisories []string
}

Cluster is a logical deployment target, often named for its region, purpose, etc.

type Clusters

type Clusters map[string]*Cluster

Clusters is a collection of Cluster

type CreateError

type CreateError struct {
	Deployment *Deployment
	Err        error
}

CreateError is returned when there's an error trying to create a deployment

func (*CreateError) Error

func (e *CreateError) Error() string

func (*CreateError) ExistingDeployment

func (e *CreateError) ExistingDeployment() *Deployment

ExistingDeployment returns the deployment that was already existent in a change error

func (*CreateError) IntendedDeployment

func (e *CreateError) IntendedDeployment() *Deployment

IntendedDeployment returns the deployment that was intended in a ChangeError

type Debug

type Debug struct{ Message }

type Defs

type Defs struct {
	// DockerRepo is the host:port (no schema) to connect to the Docker repository
	DockerRepo string
	// Clusters is a collection of logical deployment environments.
	Clusters Clusters
	// EnvVars contains definitions for global environment variables.
	EnvVars EnvDefs
	// Resources contains definitions for resource types available to
	// deployment manifests.
	Resources ResDefs
}

Defs holds definitions for organisation-level objects.

type DeleteError

type DeleteError struct {
	Deployment *Deployment
	Err        error
}

DeleteError is returned when there's an error while trying to delete a deployment

func (*DeleteError) Error

func (e *DeleteError) Error() string

func (*DeleteError) ExistingDeployment

func (e *DeleteError) ExistingDeployment() *Deployment

ExistingDeployment returns the deployment that was already existent in a change error

func (*DeleteError) IntendedDeployment

func (e *DeleteError) IntendedDeployment() *Deployment

IntendedDeployment returns the deployment that was intended in a ChangeError

type DeployConfig

type DeployConfig struct {
	// Resources represents the resources each instance of this software
	// will be given by the execution environment.
	Resources Resources `yaml:",omitempty" validate:"keys=nonempty,values=nonempty"`
	// Env is a list of environment variables to set for each instance of
	// of this deployment. It will be checked for conflict with the
	// definitions found in State.Defs.EnvVars, and if not in conflict
	// assumes the greatest priority.
	Args []string `yaml:",omitempty" validate:"values=nonempty"`
	Env  `yaml:",omitempty" validate:"keys=nonempty,values=nonempty"`
	// NumInstances is a guide to the number of instances that should be
	// deployed in this cluster, note that the actual number may differ due
	// to decisions made by Sous. If set to zero, Sous will decide how many
	// instances to launch.
	NumInstances int

	// Volumes lists the volume mappings for this deploy
	Volumes Volumes
}

DeployConfig represents the configuration of a deployment's tasks, in a specific cluster. i.e. their resources, environment, and the number of instances.

func (*DeployConfig) Equal

func (dc *DeployConfig) Equal(o DeployConfig) bool

Equal is used to compare DeployConfigs

func (*DeployConfig) String

func (dc *DeployConfig) String() string

type DeployID

type DeployID struct {
	Cluster string
	Source  SourceLocation
}

A DeployID identifies a deployment.

type DeploySpec

type DeploySpec struct {
	// DeployConfig contains config information for this deployment, see
	// DeployConfig.
	DeployConfig `yaml:",inline"`
	// Version is a semantic version with the following properties:
	//
	//     1. The major/minor/patch/pre-release fields exist as a tag in
	//        the source code repository containing this application.
	//     2. The metadata field is the full revision ID of the commit
	//        which the tag in 1. points to.
	Version semv.Version `validate:"nonzero"`
	// contains filtered or unexported fields
}

DeploySpec is the interface to describe a cluster-wide deployment of an application described by a Manifest. Together with the manifest, one can assemble full Deployments.

Unexported fields in DeploymentSpec are not intended to be serialised to/from yaml, but are useful when set internally.

func (DeploySpec) Equal

func (spec DeploySpec) Equal(other DeploySpec) bool

Equal returns true if other equals spec.

type DeploySpecs

type DeploySpecs map[string]DeploySpec

DeploySpecs is a collection of Deployments associated with a manifest.

type Deployer

type Deployer interface {
	RunningDeployments(from Clusters) (Deployments, error)
	RectifyCreates(<-chan *Deployment, chan<- RectificationError)
	RectifyDeletes(<-chan *Deployment, chan<- RectificationError)
	RectifyModifies(<-chan *DeploymentPair, chan<- RectificationError)
}

Deployer describes a complete deployment system, which is able to create, read, update, and delete deployments.

type Deployment

type Deployment struct {
	// DeployConfig contains configuration info for this deployment,
	// including environment variables, resources, suggested instance count.
	DeployConfig `yaml:"inline"`
	// ClusterNickname is the human name for a cluster - it's taken from the
	// hash key that defines the cluster and is used in manifests to configure
	// cluster-local deployment config.
	ClusterName string
	// Cluster is the name of the cluster this deployment belongs to. Upon
	// parsing the Manifest, this will be set to the key in
	// Manifests.Deployments which points at this Deployment.
	Cluster *Cluster
	// SourceID is the precise version of the software to be deployed.
	SourceID SourceID
	// Owners is a map of named owners of this repository. The type of this
	// field is subject to change.
	Owners OwnerSet
	// Kind is the kind of software that SourceRepo represents.
	Kind ManifestKind

	// Volumes enumerates the volume mappings required.
	Volumes Volumes

	// Notes collected from the deployment's source.
	Annotation
}

Deployment is a completely configured deployment of a piece of software. It contains all the data necessary for Sous to create a single deployment, which is a single version of a piece of software, running in a single cluster.

func BuildDeployment

func BuildDeployment(s *State, m *Manifest, nick string, spec DeploySpec, inherit []DeploySpec) (*Deployment, error)

BuildDeployment constructs a deployment out of a Manifest.

func (*Deployment) Equal

func (d *Deployment) Equal(o *Deployment) bool

Equal returns true if two Deployments are equal.

func (*Deployment) ID

func (d *Deployment) ID() DeployID

ID returns the DeployID of this deployment.

func (*Deployment) Name

func (d *Deployment) Name() DeployID

Name returns the DeployID.

func (*Deployment) String

func (d *Deployment) String() string

func (*Deployment) Tabbed

func (d *Deployment) Tabbed() string

Tabbed returns the fields of a deployment formatted in a tab delimited list.

type DeploymentPair

type DeploymentPair struct {
	Prior, Post *Deployment
	// contains filtered or unexported fields
}

DeploymentPair is a pair of deployments that represent a "before and after" style relationship

type DeploymentPairs

type DeploymentPairs []*DeploymentPair

DeploymentPairs is a list of DeploymentPair

type DeploymentPredicate

type DeploymentPredicate func(*Deployment) bool

DeploymentPredicate takes a *Deployment and returns true if the deployment matches the predicate. Used by Filter to select a subset of a Deployments.

type Deployments

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

Deployments is a wrapper around map[DeployID]*Deployment which is safe for concurrent read and write.

func MakeDeployments

func MakeDeployments(capacity int) Deployments

MakeDeployments creates a new Deployments with capacity set.

func NewDeployments

func NewDeployments(from ...(*Deployment)) Deployments

NewDeployments creates a new Deployments. You may optionally pass any number of *Deployments, which will be added to this map.

func NewDeploymentsFromMap

func NewDeploymentsFromMap(from ...map[DeployID](*Deployment)) Deployments

NewDeploymentsFromMap creates a new Deployments. You may optionally pass any number of map[DeployID]*Deployments, which will be merged key-wise into the new Deployments, with keys from the right-most map taking precedence.

func (Deployments) Add

func (m Deployments) Add(v *Deployment) (ok bool)

Add adds a (k, v) pair into a map if it is not already there. Returns true if the value was added, false if not.

func (Deployments) AddAll

func (m Deployments) AddAll(from Deployments) (conflicting DeployID, success bool)

AddAll returns (zero DeployID, true) if all entries from the passed in Deployments have different keys and all are added to this Deployments. If any of the keys conflict, nothing will be added to this Deployments and AddAll will return the conflicting DeployID and false.

func (Deployments) Any

func (m Deployments) Any(predicate func(*Deployment) bool) (*Deployment, bool)

Any returns (a single *Deployment matching predicate, true), if there are any *Deployments matching predicate in Deployments. Otherwise returns (zero *Deployment, false).

func (Deployments) Clone

func (m Deployments) Clone() Deployments

Clone returns a pairwise copy of Deployments.

func (Deployments) Diff

func (d Deployments) Diff(other Deployments) DiffChans

Diff computes the differences between two sets of Deployments

func (Deployments) Filter

func (m Deployments) Filter(predicate func(*Deployment) bool) Deployments

Filter returns a new Deployments containing only the entries where the predicate returns true for the given value. A nil predicate is equivalent to calling Clone.

func (Deployments) FilteredSnapshot

func (m Deployments) FilteredSnapshot(predicate func(*Deployment) bool) map[DeployID](*Deployment)

FilteredSnapshot returns a moment-in-time filtered copy of the current underlying map[DeployID]*Deployment. (DeployID, *Deployment) pairs are included if they satisfy predicate.

func (Deployments) Get

func (m Deployments) Get(key DeployID) (v *Deployment, ok bool)

Get returns (value, true) if k is in the map, or (zero value, false) otherwise.

func (Deployments) GetAll

func (m Deployments) GetAll() map[DeployID](*Deployment)

GetAll returns SnapShot (it allows hy to marshal Deployments).

func (Deployments) Keys

func (m Deployments) Keys() []DeployID

Keys returns a slice containing all the keys in the map.

func (Deployments) Len

func (m Deployments) Len() int

Len returns number of elements in a map.

func (Deployments) Manifests

func (ds Deployments) Manifests(defs Defs) (Manifests, error)

Manifests creates manifests from deployments.

func (Deployments) Merge

func (m Deployments) Merge(other Deployments) Deployments

Merge returns a new Deployments with all entries from this Deployments and the other. If any keys in other match keys in this *Deployments, keys from other will appear in the returned *Deployments.

func (Deployments) MustAdd

func (m Deployments) MustAdd(v *Deployment)

MustAdd is a wrapper around Add which panics whenever Add returns false.

func (Deployments) Remove

func (m Deployments) Remove(key DeployID)

Remove value for a key k if present, a no-op otherwise.

func (Deployments) Set

func (m Deployments) Set(key DeployID, value *Deployment)

Set sets the value of index k to v.

func (*Deployments) SetAll

func (m *Deployments) SetAll(v map[DeployID](*Deployment))

SetAll sets the internal map (it allows hy to unmarshal Deployments). Note: SetAll is the only method that is not safe for concurrent access.

func (Deployments) Single

func (m Deployments) Single(predicate func(*Deployment) bool) (*Deployment, bool)

Single returns (the single *Deployment satisfying predicate, true), if there is exactly one *Deployment satisfying predicate in Deployments. Otherwise, returns (zero *Deployment, false).

func (Deployments) Snapshot

func (m Deployments) Snapshot() map[DeployID](*Deployment)

Snapshot returns a moment-in-time copy of the current underlying map[DeployID]*Deployment.

type DetectResult

type DetectResult struct {
	Compatible  bool
	Description string
	Data        interface{}
}

DetectResult represents the result of a detection.

type DiffChans

type DiffChans struct {
	Created, Deleted, Retained chan *Deployment
	Modified                   chan *DeploymentPair
}

DiffChans is a set of channels that represent differences between two sets of Deployments as they're discovered

func NewDiffChans

func NewDiffChans(sizes ...int) DiffChans

NewDiffChans constructs a DiffChans

func (*DiffChans) Close

func (d *DiffChans) Close()

Close closes all the channels in a DiffChans in a single action

type DummyRegistry

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

DummyNameCache implements the Builder interface by returning a computed image name for a given source ID.

func NewDummyRegistry

func NewDummyRegistry() *DummyRegistry

NewDummyRegistry builds a new DummyNameCache.

func (*DummyRegistry) FeedArtifact

func (dc *DummyRegistry) FeedArtifact(ba *BuildArtifact, e error)

func (*DummyRegistry) FeedSourceID

func (dc *DummyRegistry) FeedSourceID(sid SourceID, e error)

func (*DummyRegistry) FeedSourceIDList

func (dc *DummyRegistry) FeedSourceIDList(sids []SourceID, e error)

func (*DummyRegistry) GetArtifact

func (dc *DummyRegistry) GetArtifact(sid SourceID) (*BuildArtifact, error)

func (*DummyRegistry) GetSourceID

func (dc *DummyRegistry) GetSourceID(*BuildArtifact) (SourceID, error)

GetSourceID implements part of ImageMapper

func (*DummyRegistry) ListSourceIDs

func (dc *DummyRegistry) ListSourceIDs() ([]SourceID, error)

ListSourceIDs implements Registry

func (*DummyRegistry) Warmup

func (dc *DummyRegistry) Warmup(string) error

Warmup implements Registry

type DumperEntry

type DumperEntry struct {
	SourceID
	*BuildArtifact
}

DumperEntry is a single entry from the dump

func (*DumperEntry) Tabbed

func (de *DumperEntry) Tabbed() string

Tabbed emits a tab-delimited string representing the entry

type EchoSelector

type EchoSelector struct {
	Factory func(*BuildContext) (Buildpack, error)
}

EchoSelector wraps a buildpack Factory. But why?

func (*EchoSelector) SelectBuildpack

func (s *EchoSelector) SelectBuildpack(c *BuildContext) (Buildpack, error)

SelectBuildpack tries to select a buildpack for this BuildContext.

type Engine

type Engine struct {
	MessageHandler func(Message)
}

func (*Engine) GetSourceContext

func (e *Engine) GetSourceContext() (*SourceContext, error)

type Env

type Env map[string]string

Env is a mapping of environment variable name to value, used to provision single instances of an application.

func (Env) Equal

func (e Env) Equal(o Env) bool

Equal compares Envs

type EnvDef

type EnvDef struct {
	Name, Desc, Scope string
	Type              VarType
}

EnvDef is an environment variable definition.

type EnvDefaults

type EnvDefaults map[string]Var

EnvDefaults is a list of named environment variables along with their values.

type EnvDefs

type EnvDefs []EnvDef

EnvDefs is a collection of EnvDef

type Error

type Error struct{ Message }

type ILogger

type ILogger interface {
	SetLogFunc(func(...interface{}))
	SetDebugFunc(func(...interface{}))
}

ILogger is like this: XXX This is a complete placeholder for work in the ilog branch I needed some extra logging for config process, and didn't want to double down on a process we knew we were going to abandon XXX Further thought: I really think we should look log15 (or something) as our logging platform. It won't be perfect, but it also won't suck up work

type IncludesVersion

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

IncludesVersion indicates that Sous couldn't determine what version was intended for this SL

func (*IncludesVersion) Error

func (err *IncludesVersion) Error() string

type Info

type Info struct{ Message }

type Labeller

type Labeller interface {
	ApplyMetadata(*BuildResult, *BuildContext) error
}

Labeller defines a container-based build system.

type LogSet

type LogSet struct {
	Debug  *log.Logger
	Info   *log.Logger
	Warn   *log.Logger
	Notice *log.Logger
	Vomit  *log.Logger
}

LogSet is the stopgap for a decent injectable logger

type Machine

type Machine struct {
	Host, FullHost string
}

Machine represents a specific computer.

type Manifest

type Manifest struct {
	// Source is the location of the source code for this piece of software.
	Source SourceLocation `validate:"nonzero"`
	// Owners is a list of named owners of this repository. The type of this
	// field is subject to change.
	Owners []string
	// Kind is the kind of software that SourceRepo represents.
	Kind ManifestKind `validate:"nonzero"`
	// Deployments is a map of cluster names to DeploymentSpecs
	Deployments DeploySpecs `validate:"keys=nonempty,values=nonzero"`
}

Manifest is a minimal representation of the global deployment state of a particular named application. It is designed to be written and read by humans as-is, and expanded into full Deployments internally. It is a DTO, which can be stored in YAML files.

Manifest has a direct two-way mapping to/from Deployments.

func (*Manifest) Equal

func (m *Manifest) Equal(o *Manifest) bool

Equal returns true iff o is equal to m.

func (*Manifest) FileLocation

func (m *Manifest) FileLocation() string

FileLocation returns the path that the manifest should be saved to.

func (*Manifest) ID

func (m *Manifest) ID() SourceLocation

ID returns the SourceLocation.

type ManifestKind

type ManifestKind string

ManifestKind describes the broad category of a piece of software, such as a long-running HTTP service, or a scheduled task, etc. It is used to determine resource sets and contracts that can be run on this application.

const (
	// ManifestKindService represents an HTTP service which is a long-running process,
	// and listens and responds to HTTP requests.
	ManifestKindService (ManifestKind) = "http-service"
	// ManifestKindWorker represents a worker process.
	ManifestKindWorker (ManifestKind) = "worker"
	// ManifestKindOnDemand represents an on-demand service.
	ManifestKindOnDemand (ManifestKind) = "on-demand"
	// ManifestKindScheduled represents a scheduled task.
	ManifestKindScheduled (ManifestKind) = "scheduled"
	// ManifestKindOnce represents a one-off job.
	ManifestKindOnce (ManifestKind) = "once"
	// ScheduledJob represents a process which starts on some schedule, and
	// exits when it completes its task.
	ScheduledJob = "scheduled-job"
)

type Manifests

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

Manifests is a wrapper around map[SourceLocation]*Manifest which is safe for concurrent read and write.

func MakeManifests

func MakeManifests(capacity int) Manifests

MakeManifests creates a new Manifests with capacity set.

func NewManifests

func NewManifests(from ...(*Manifest)) Manifests

NewManifests creates a new Manifests. You may optionally pass any number of *Manifests, which will be added to this map.

func NewManifestsFromMap

func NewManifestsFromMap(from ...map[SourceLocation](*Manifest)) Manifests

NewManifestsFromMap creates a new Manifests. You may optionally pass any number of map[SourceLocation]*Manifests, which will be merged key-wise into the new Manifests, with keys from the right-most map taking precedence.

func (Manifests) Add

func (m Manifests) Add(v *Manifest) (ok bool)

Add adds a (k, v) pair into a map if it is not already there. Returns true if the value was added, false if not.

func (Manifests) AddAll

func (m Manifests) AddAll(from Manifests) (conflicting SourceLocation, success bool)

AddAll returns (zero SourceLocation, true) if all entries from the passed in Manifests have different keys and all are added to this Manifests. If any of the keys conflict, nothing will be added to this Manifests and AddAll will return the conflicting SourceLocation and false.

func (Manifests) Any

func (m Manifests) Any(predicate func(*Manifest) bool) (*Manifest, bool)

Any returns (a single *Manifest matching predicate, true), if there are any *Manifests matching predicate in Manifests. Otherwise returns (zero *Manifest, false).

func (Manifests) Clone

func (m Manifests) Clone() Manifests

Clone returns a pairwise copy of Manifests.

func (Manifests) Filter

func (m Manifests) Filter(predicate func(*Manifest) bool) Manifests

Filter returns a new Manifests containing only the entries where the predicate returns true for the given value. A nil predicate is equivalent to calling Clone.

func (Manifests) FilteredSnapshot

func (m Manifests) FilteredSnapshot(predicate func(*Manifest) bool) map[SourceLocation](*Manifest)

FilteredSnapshot returns a moment-in-time filtered copy of the current underlying map[SourceLocation]*Manifest. (SourceLocation, *Manifest) pairs are included if they satisfy predicate.

func (Manifests) Get

func (m Manifests) Get(key SourceLocation) (v *Manifest, ok bool)

Get returns (value, true) if k is in the map, or (zero value, false) otherwise.

func (Manifests) GetAll

func (m Manifests) GetAll() map[SourceLocation](*Manifest)

GetAll returns SnapShot (it allows hy to marshal Manifests).

func (Manifests) Keys

func (m Manifests) Keys() []SourceLocation

Keys returns a slice containing all the keys in the map.

func (Manifests) Len

func (m Manifests) Len() int

Len returns number of elements in a map.

func (Manifests) Merge

func (m Manifests) Merge(other Manifests) Manifests

Merge returns a new Manifests with all entries from this Manifests and the other. If any keys in other match keys in this *Manifests, keys from other will appear in the returned *Manifests.

func (Manifests) MustAdd

func (m Manifests) MustAdd(v *Manifest)

MustAdd is a wrapper around Add which panics whenever Add returns false.

func (Manifests) Remove

func (m Manifests) Remove(key SourceLocation)

Remove value for a key k if present, a no-op otherwise.

func (Manifests) Set

func (m Manifests) Set(key SourceLocation, value *Manifest)

Set sets the value of index k to v.

func (*Manifests) SetAll

func (m *Manifests) SetAll(v map[SourceLocation](*Manifest))

SetAll sets the internal map (it allows hy to unmarshal Manifests). Note: SetAll is the only method that is not safe for concurrent access.

func (Manifests) Single

func (m Manifests) Single(predicate func(*Manifest) bool) (*Manifest, bool)

Single returns (the single *Manifest satisfying predicate, true), if there is exactly one *Manifest satisfying predicate in Manifests. Otherwise, returns (zero *Manifest, false).

func (Manifests) Snapshot

func (m Manifests) Snapshot() map[SourceLocation](*Manifest)

Snapshot returns a moment-in-time copy of the current underlying map[SourceLocation]*Manifest.

type Message

type Message interface {
	Time() time.Time
	Sender() string
	Body() string
}

func Messagef

func Messagef(from, format string, v ...interface{}) Message

type Messenger

type Messenger struct {
	Owner   string
	Queue   chan Message
	Handler func(Message)
}

Messenger creates and sends messages. It has an internal queue, and tries hard not to block.

func NewMessenger

func NewMessenger(owner string, handler func(Message)) *Messenger

func (*Messenger) Errorf

func (m *Messenger) Errorf(format string, v ...interface{})

type MissingImageNameError

type MissingImageNameError struct {
	Cause error
}

MissingImageNameError reports that we couldn't get names for one or more source IDs.

func (*MissingImageNameError) Error

func (e *MissingImageNameError) Error() string

type MissingPath

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

MissingPath indicates that Sous couldn't determine what repo offset was intended for this SL

func (*MissingPath) Error

func (err *MissingPath) Error() string

type MissingRepo

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

MissingRepo indicates that Sous couldn't determine which repo was intended for this SL

func (*MissingRepo) Error

func (err *MissingRepo) Error() string

type MissingVersion

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

MissingVersion indicates that Sous couldn't determine what version was intended for this SL

func (*MissingVersion) Error

func (err *MissingVersion) Error() string

type OwnerSet

type OwnerSet map[string]struct{}

OwnerSet collects the names of the owners of a deployment.

func (OwnerSet) Add

func (os OwnerSet) Add(owner string)

Add adds an owner to an ownerset.

func (OwnerSet) Equal

func (os OwnerSet) Equal(o OwnerSet) bool

Equal returns true if two ownersets contain the same owner names.

func (OwnerSet) Remove

func (os OwnerSet) Remove(owner string)

Remove removes an owner from an ownerset.

type Quality

type Quality struct {
	Name string
	// Kind is the the kind of this quality
	// Known kinds include: advisory
	Kind string
}

A Quality represents a characteristic of a BuildArtifact that needs to be recorded.

type RectificationError

type RectificationError interface {
	error
	ExistingDeployment() *Deployment
	IntendedDeployment() *Deployment
}

RectificationError is an interface that extends error with methods to get the deployments the preceeded and were intended when the error occurred

type Registrar

type Registrar interface {
	// Register takes a BuildResult and makes it available for the deployment
	// target system to find during deployment
	Register(*BuildResult, *BuildContext) error
}

Registrar defines the interface to register build results to be deployed later

type Registry

type Registry interface {
	// GetArtifact gets the build artifact address for a source ID.
	// It does not guarantee that that artifact exists.
	GetArtifact(SourceID) (*BuildArtifact, error)
	// GetSourceID gets the source ID associated with the
	// artifact, regardless of the existence of the artifact.
	GetSourceID(*BuildArtifact) (SourceID, error)

	// ListSourceIDs returns a list of known SourceIDs
	ListSourceIDs() ([]SourceID, error)

	// Warmup requests that the registry check specific artifact names for existence
	// the details of this behavior will vary by implementation. For Docker, for instance,
	// the corresponding repo is enumerated
	Warmup(string) error
}

Registry describes a system for mapping SourceIDs to BuildArtifacts and vice versa

type RegistryDumper

type RegistryDumper struct {
	Registry
}

RegistryDumper dumps the contents of artifact registries

func NewRegistryDumper

func NewRegistryDumper(r Registry) *RegistryDumper

NewRegistryDumper constructs a RegistryDumper

func (*RegistryDumper) AsTable

func (rd *RegistryDumper) AsTable(to io.Writer) error

AsTable writes a tabular dump of the registry to a Writer

func (*RegistryDumper) Entries

func (rd *RegistryDumper) Entries() (de []DumperEntry, err error)

Entries emits the list of entries for the Resgistry

func (*RegistryDumper) TabbedHeaders

func (rd *RegistryDumper) TabbedHeaders() string

TabbedHeaders outputs the headers for the dump

type ResDef

type ResDef struct {
	// Name is the name of the resource, e.g. "Memory", "CPU", "NumPorts"
	Name string
	// Type is the type of value used to represent quantities or instances
	// of this resource, e.g. MemorySize, Float, or Int (not yet implemented).
	Type VarType
}

ResDef is a resource type definition.

type ResDefs

type ResDefs []ResDef

ResDefs is a collection of ResDef.

type ResolveErrors

type ResolveErrors struct {
	Causes []error
}

ResolveErrors collect all the errors for a resolve action into a single error to be handled elsewhere

func (*ResolveErrors) Error

func (re *ResolveErrors) Error() string

type Resolver

type Resolver struct {
	Deployer Deployer
	Registry Registry
}

Resolver is responsible for resolving intended and actual deployment states.

func NewResolver

func NewResolver(d Deployer, r Registry) *Resolver

NewResolver creates a new Resolver.

func (*Resolver) Resolve

func (r *Resolver) Resolve(intended Deployments, clusters Clusters) error

Resolve drives the Sous deployment resolution process. It calls out to the appropriate components to compute the intended deployment set, collect the actual set, compute the diffs and then issue the commands to rectify those differences.

type Resources

type Resources map[string]string

Resources is a mapping of resource name to value, used to provision single instances of an application. It is validated against State.Defs.Resources. The keys must match defined resource names, and the values must parse to the defined types.

func (Resources) Cpus

func (r Resources) Cpus() float64

func (Resources) Equal

func (r Resources) Equal(o Resources) bool

Equal checks equivalence between resource maps

func (Resources) Memory

func (r Resources) Memory() float64

func (Resources) Ports

func (r Resources) Ports() int32

type ScratchContext

type ScratchContext struct {
	Sh                 *shell.Sh
	RootDir, OffsetDir string
}

ScratchContext represents an isolated copy of a project's source code somewhere on the host machine running Sous.

type Selector

type Selector interface {
	SelectBuildpack(*BuildContext) (Buildpack, error)
}

A Selector selects the buildpack for a given build context

type SourceContext

type SourceContext struct {
	RootDir, OffsetDir, Branch, Revision string
	Files, ModifiedFiles, NewFiles       []string
	Tags                                 []Tag
	NearestTagName, NearestTagRevision   string
	PrimaryRemoteURL                     string
	RemoteURL                            string
	RemoteURLs                           []string
	DirtyWorkingTree                     bool
	RevisionUnpushed                     bool
}

SourceContext contains contextual information about the source code being built.

func (*SourceContext) AbsDir

func (sc *SourceContext) AbsDir() string

AbsDir returns the absolute path of this source code.

func (*SourceContext) SourceLocation

func (sc *SourceContext) SourceLocation() SourceLocation

SourceLocation returns the source location in this context.

func (*SourceContext) Version

func (sc *SourceContext) Version() SourceID

Version returns the SourceID.

type SourceID

type SourceID struct {
	// Repo: see SourceLocation.Repo.
	Repo string
	// Version identifies a specific version of the source code at Repo/Dir.
	Version semv.Version
	// Dir: See SourceLocation.Dir.
	Dir string `yaml:",omitempty"`
}

SourceID identifies a specific snapshot of a body of source code, including its location and version.

func MustParseSourceID

func MustParseSourceID(s string) SourceID

MustParseSourceID wraps ParseSourceID and panics if it returns an error.

func ParseSourceID

func ParseSourceID(s string) (SourceID, error)

ParseSourceID parses an entire SourceID.

func (SourceID) Equal

func (sid SourceID) Equal(o SourceID) bool

Equal tests the equality between this SourceID and another.

func (SourceID) Location

func (sid SourceID) Location() SourceLocation

Location returns the location component of this SourceID.

func (SourceID) RevID

func (sid SourceID) RevID() string

RevID returns the revision id for this SourceID.

func (SourceID) String

func (sid SourceID) String() string

func (SourceID) Tag

func (sid SourceID) Tag() string

Tag returns the version tag for this source ID.

type SourceLocation

type SourceLocation struct {
	// Repo identifies a source code repository.
	Repo,

	Dir string `yaml:",omitempty"`
}

SourceLocation identifies a directory inside a source code repository. Note that the directory is ambiguous without the addition of a revision ID. This type is used as a shorthand for deploy manifests, enabling the logical grouping of deploys of different versions of a particular service.

func MustParseSourceLocation

func MustParseSourceLocation(s string) SourceLocation

MustParseSourceLocation wraps ParseSourceLocation but panics instead of returning a non-nil error.

func NewSourceLocation

func NewSourceLocation(repoURL, repoOffset string) SourceLocation

NewSourceLocation creates a new SourceLocation from strings.

func ParseSourceLocation

func ParseSourceLocation(s string) (SourceLocation, error)

ParseSourceLocation parses an entire SourceLocation.

func (SourceLocation) MarshalText

func (sl SourceLocation) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (SourceLocation) MarshalYAML

func (sl SourceLocation) MarshalYAML() (interface{}, error)

MarshalYAML serializes this SourceLocation to a YAML document.

func (*SourceLocation) SourceID

func (sl *SourceLocation) SourceID(version semv.Version) SourceID

SourceID returns a SourceID built from this location with the addition of a version.

func (SourceLocation) String

func (sl SourceLocation) String() string

func (*SourceLocation) UnmarshalText

func (sl *SourceLocation) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextMarshaler.

func (*SourceLocation) UnmarshalYAML

func (sl *SourceLocation) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML deserializes a YAML document into this SourceLocation

type State

type State struct {

	// Defs contains global definitions for this organisation.
	Defs Defs `hy:"defs"`
	// Manifests contains a mapping of source code repositories to global
	// deployment configurations for artifacts built using that source code.
	Manifests Manifests `hy:"manifests/"`
	// contains filtered or unexported fields
}

State contains the mutable state of an organisation's deployments. State is also known as the "Global Deploy Manifest" or GDM.

func NewState

func NewState() *State

NewState returns a valid empty state.

func (*State) BaseURLs

func (s *State) BaseURLs() []string

BaseURLs returns the urls for all the clusters referred to in this state XXX - deprecate/remove

func (*State) ClusterMap

func (s *State) ClusterMap() map[string]string

ClusterMap returns the nicknames for all the clusters referred to in this state paired with the URL for the named cluster

func (*State) Deployments

func (s *State) Deployments() (Deployments, error)

Deployments returns all deployments described by the state.

func (*State) DeploymentsFromManifest

func (s *State) DeploymentsFromManifest(m *Manifest) (Deployments, error)

DeploymentsFromManifest returns all deployments described by a single manifest, in terms of the wider state (i.e. global and cluster definitions and configuration).

func (*State) OnlyCluster

func (s *State) OnlyCluster(nick string)

OnlyCluster sets a contraint on the State such that it will only consider a particular cluster

type Tag

type Tag struct {
	Name, Revision string
}

Tag represents a revision control commit tag.

type UnacceptableAdvisory

type UnacceptableAdvisory struct {
	Quality
	*SourceID
}

An UnacceptableAdvisory reports that there is an advisory on an image which hasn't been whitelisted on the target cluster

func (*UnacceptableAdvisory) Error

func (e *UnacceptableAdvisory) Error() string

type Var

type Var string

Var is a strongly typed string for use in environment variables and YAML files. It will implement sane YAML marshalling and unmarshalling. (Not yet implemented.)

type VarType

type VarType string

VarType represents the type of a Var (not yet implemented).

type Volume

type Volume struct {
	Host, Container string
	Mode            VolumeMode
}

Volume describes a deployment's volume mapping

func (*Volume) Equal

func (v *Volume) Equal(o *Volume) bool

Equal is used to compare *Volume pairs

type VolumeMode

type VolumeMode string

VolumeMode is either readwrite or readonly

const (
	// ReadOnly specifies that a volume can only be read
	ReadOnly VolumeMode = "RO"
	// ReadWrite specifies that the container can write to the volume
	ReadWrite VolumeMode = "RW"
)

type Volumes

type Volumes []*Volume

Volumes represents a list of volume mappings

func (Volumes) Equal

func (vs Volumes) Equal(o Volumes) bool

Equal is used to compare Volumes pairs

func (Volumes) String

func (vs Volumes) String() string

type Warning

type Warning struct{ Message }

Jump to

Keyboard shortcuts

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