sous

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 37 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// NotService is an advisory that this container is not a service, but
	// instead a support container of some kind and should not itself be
	// deployed.
	NotService = AdvisoryName(`support container`)
	// IsBuilder is an advisory that this container was used to build a finished
	// image, and should not itself be deployed.
	IsBuilder = AdvisoryName(`is a build image`)
	// UnknownRepo is an advisory that the source workspace is not a repo.
	// TODO: Disambiguate text from NoRepoAdv, they seem like the same thing.
	UnknownRepo = AdvisoryName(`source workspace lacked repo`)
	// NoRepoAdv means there is no repository.
	// TODO: Disambiguate text from UnknownRepo.
	NoRepoAdv = AdvisoryName(`no repository`)
	// NotRequestedRevision means that a different revision was built from that
	// which was requested.
	NotRequestedRevision = AdvisoryName(`requested revision not built`)
	// Unversioned means that there was no tag at the currently checked out
	// revision, or that the tag was not a semver tag, or the tag was 0.0.0.
	Unversioned = AdvisoryName(`no versioned tag`)
	// TagMismatch means that a different tag to the one which was requested was
	// built.
	TagMismatch = AdvisoryName(`tag mismatch`)
	// TagNotHead means that the requested tag exists in the history, but there
	// were more commits since, which were part of this build.
	TagNotHead = AdvisoryName(`tag not on built revision`)
	// EphemeralTag means the tag was an ephemeral tag rather than an annotated
	// tag.
	EphemeralTag = AdvisoryName(`ephemeral tag`)
	// UnpushedRev means the revision that was build is not pushed to any
	// remote.
	UnpushedRev = AdvisoryName(`unpushed revision`)
	// BogusRev means that the revision was bogus.
	// TODO: Find out what "bogus" means.
	BogusRev = AdvisoryName(`bogus revision`)
	// DirtyWS means that the workspace was dirty, which means there were
	// untracked files present, or that one or more tracked files were modified
	// since the last commit.
	DirtyWS = AdvisoryName(`dirty workspace`)
	// DeveloperBuild means image was built with the dev flag true, only enables
	// local image detection at the moment.
	DeveloperBuild = AdvisoryName(`developer build`)
	// AddedArtifact means artifact was added to Sous manually and may not have
	// been built by sous.
	AddedArtifact = AdvisoryName(`added artifact`)
)
View Source
const (
	// StableDiff - the active deployment is the intended deployment
	StableDiff = ResolutionType("unchanged")
	// ComingDiff - the intended deployment is pending, assumed will be come active
	ComingDiff = ResolutionType("coming")
	// CreateDiff - the intended deployment was missing and had to be created.
	CreateDiff = ResolutionType("created")
	// ModifyDiff - there was a deployment that differed from the intended was changed.
	ModifyDiff = ResolutionType("updated")
	// DeleteDiff - a deployment was active that wasn't intended at all, and was deleted.
	DeleteDiff = ResolutionType("deleted")
)
View Source
const ClusterNameLabel = "com.opentable.sous.clustername"

SingularityDeployMetadataClusterName defines the namespace for storing a Sous ClusterName in SingularityDeploy metadata.

View Source
const DefaultDelim = ","

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

View Source
const FlavorLabel = "com.opentable.sous.flavor"

SingularityDeployMetadataFlavor defines the namespace for storing a Sous Flavor in SingularityDeploy metadata.

View Source
const FlavorSeparator = "~"

FlavorSeparator separates the flavor part of a ManifestID from the SourceLocation part.

View Source
const MaxRefsPerR11nQueue = 100

MaxRefsPerR11nQueue is the maximum number of rectifications to cache in memory.

View Source
const PathLabel = "com.opentable.sous.repo_offset"

PathLabel is the metadata fieldname that records the subdirectory under a RepoLabel of a Sous-controlled service.

View Source
const PollTimeout = 500 * time.Millisecond

PollTimeout is the pause between each polling request to /status.

View Source
const R11nQueueCapDefault = 10

R11nQueueCapDefault is the default capacity for a new R11nQueue.

View Source
const RepoLabel = "com.opentable.sous.repo_url"

RepoLabel is the metadata fieldname that records the version control repository URL of a Sous-controlled service.

View Source
const RevisionLabel = "com.opentable.sous.revision"

RevisionLabel is a metadata fieldname that records the git revision ID of a Sous-controlled service.

View Source
const SingularityDeployTimeout = 10 * 60

SingularityDeployTimeout sets the number of seconds to wait for a SingularityDeploy before it is marked failed. Increasing this number from the stock 120sec is helpful when dealing with a slow connection to a Docker registry.

View Source
const VersionLabel = "com.opentable.sous.version"

VersionLabel is a metadata fieldname that records the semver tag of a Sous-controlled service.

Variables

View Source
var ZeroVersion = semv.MustParse("0.0.0-unversioned")

ZeroVersion is a "zero" version.

Functions

func AllAdvisoryStrings added in v1.0.1

func AllAdvisoryStrings() []string

AllAdvisoryStrings is similar to AllAdvisories except it casts them to strings.

func AnyTransientResolveErrors added in v1.0.1

func AnyTransientResolveErrors(err error) bool

AnyTransientResolveErrors returns true for transient resolve errors (see code for details). The intention is to filter Resolver.Begin(...).Wait() results for loops, so that transient errors can be retried.

func DBNameForTest added in v1.0.1

func DBNameForTest(t *testing.T, optidx ...int) string

DBNameForTest returns a database name based on the test name.

func DumpDeployStatuses added in v1.0.1

func DumpDeployStatuses(writer io.Writer, ds DeployStates)

DumpDeployStatuses prints a bunch of DeployStates to writer.

func DumpDeployments

func DumpDeployments(writer io.Writer, ds Deployments)

DumpDeployments prints a bunch of Deployments to writer.

func HandlePairsByRegistry added in v1.0.1

func HandlePairsByRegistry(r Registry, dp *DeployablePair, ls logging.LogSink) (*DeployablePair, *DiffResolution)

func IsTransientResolveError added in v0.1.7

func IsTransientResolveError(err error) bool

IsTransientResolveError returns true for resolve errors which might resolve on their own. All other errors, it returns false

func JSONDeployments added in v1.0.1

func JSONDeployments(writer io.Writer, ds Deployments)

JSONDeployments prints deployments, one JSON document per line of output.

func NewDeployablePairSubmessage added in v1.0.1

func NewDeployablePairSubmessage(pair *DeployablePair) logging.Submessage

NewDeployablePairSubmessage returns a new deployablePairSubmessage.

func NewDeployableSubmessage added in v1.0.1

func NewDeployableSubmessage(prefix string, dep *Deployable) logging.EachFielder

NewDeployableSubmessage creates a new EachFielder that produces fields for a Deployable..

func NewDeploymentSubmessage added in v1.0.1

func NewDeploymentSubmessage(prefix string, dep *Deployment) logging.EachFielder

NewDeploymentSubmessage returns an EachFielder that produces fields based on a Deployment

func NewStateManagerSpy added in v1.0.1

func NewStateManagerSpy() (StateManager, StateManagerController)

NewStateManagerSpy creates a StateManager spy.

func NewStateManagerSpyFor added in v1.0.1

func NewStateManagerSpyFor(state *State) (StateManager, StateManagerController)

NewStateManagerSpyFor returns a spy/controller pair that will return the given state for calls to Read

func NormalizedOffset added in v1.0.1

func NormalizedOffset(root, workdir string) (string, error)

NormalizedOffset returns a relative path from root that is based on workdir. Notably, it handles the case where the workdir is in the same physical path as root, but via symlinks

func ReleaseDB added in v1.0.1

func ReleaseDB(t *testing.T, optidx ...int)

ReleaseDB should be called in any test that called SetupDB (even indirectly)

func SetupDB added in v1.0.1

func SetupDB(t *testing.T, optidx ...int) *sql.DB

SetupDB makes a test DB in a local postgres database. It assumes the existence of a properly migrated 'sous_test_template' directory. Each test should provide a unique name for its DB instance so that they'll be independent.

func SetupDBNamed added in v1.0.1

func SetupDBNamed(t *testing.T, name string) (*sql.DB, error)

SetupDBNamed is like SetupDB except it takes an explicit name.

func TabbedDeployStatusHeaders added in v1.0.1

func TabbedDeployStatusHeaders() string

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

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

Advisories are the advisory tokens that apply to a build

func AllAdvisories added in v1.0.1

func AllAdvisories() Advisories

AllAdvisories returns all advisories.

func (Advisories) Contains added in v1.0.1

func (as Advisories) Contains(a AdvisoryName) bool

Contains returns true if as contains a.

func (Advisories) Strings added in v1.0.1

func (as Advisories) Strings() []string

Strings returns as as a slice of strings.

type AdvisoryName

type AdvisoryName string

An AdvisoryName is the type for advisory tokens.

type AutoResolver added in v0.0.3

type AutoResolver struct {
	UpdateTime time.Duration
	StateReader
	GDM Deployments
	*Resolver
	logging.LogSink

	sync.RWMutex
	// contains filtered or unexported fields
}

An AutoResolver sets up the interactions to automatically run an infinite loop of resolution cycles.

func NewAutoResolver added in v0.0.3

func NewAutoResolver(rez *Resolver, sr StateReader, ls logging.LogSink) *AutoResolver

NewAutoResolver creates a new AutoResolver.

func (*AutoResolver) Kickoff added in v0.0.3

func (ar *AutoResolver) Kickoff() TriggerChannel

Kickoff starts the auto-resolve cycle.

func (*AutoResolver) StandardListeners added in v0.0.3

func (ar *AutoResolver) StandardListeners()

StandardListeners adds the usual listeners into the auto-resolve cycle.

func (*AutoResolver) Statuses added in v0.0.3

func (ar *AutoResolver) Statuses() (stable, live *ResolveStatus)

Statuses returns the current status of the resolution underway. The returned statuses are "stable" - the unchanging, complete status of the previous resolve and "live" - the current status of the running resolution

type BuildArtifact

type BuildArtifact struct {
	Type            string
	VersionName     string
	DigestReference string
	Qualities       Qualities
}

BuildArtifact describes the actual built binary Sous will deploy

func (BuildArtifact) EachField added in v1.0.1

func (ba BuildArtifact) EachField(f logging.FieldReportFn)

EachField implements EachFielder on BuildArtifact

type BuildConfig

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

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

func (*BuildConfig) Advisories

func (c *BuildConfig) Advisories(ctx *BuildContext) Advisories

Advisories returns a list of advisories that apply to ctx.

func (*BuildConfig) GuardRegister

func (c *BuildConfig) GuardRegister(br *BuildResult) 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) Resolve added in v0.0.3

func (c *BuildConfig) Resolve()

Resolve settles configurations so that e.g. captured version tags are used in the absence of user input

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 Advisories
}

BuildContext contains all the data required to perform a build.

func (*BuildContext) RevID added in v1.0.1

func (bc *BuildContext) RevID() string

RevID returns bc.Source.Revision.

func (*BuildContext) ShouldPullDuringBuild added in v1.0.1

func (bc *BuildContext) ShouldPullDuringBuild() bool

ShouldPullDuringBuild determines if Sous should pull updates to base images during 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
	LogSink logging.LogSink
}

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

func (*BuildManager) OffsetFromWorkdir added in v0.0.3

func (m *BuildManager) OffsetFromWorkdir(offset string) error

OffsetFromWorkdir sets the offset for the BuildManager to be the indicated directory. It's a convenience for command line users who can `sous build <dir>` (and therefore get tab-completion etc)

func (*BuildManager) RegisterAndWarnAdvisories added in v0.0.3

func (m *BuildManager) RegisterAndWarnAdvisories(br *BuildResult) error

RegisterAndWarnAdvisories registers the image if there are no blocking advisories; warns about the advisories and does not register otherwise.

type BuildProduct added in v1.0.1

type BuildProduct struct {
	// Source and Kind identify the build - the source inputs and the kind of build product
	Source SourceID
	Kind   string

	RevID string

	// ID is the artifact identifier - specific to product kind; e.g. docker
	// products have image ids.
	// Advisories contain the QA advisories determined on the build, and convey
	// prescriptive advice about how the image might be deployed.
	ID         string // was ImageID
	Advisories Advisories

	// VersionName and RevisionName cache computations about how to refer to the image.
	VersionName  string
	RevisionName string
	DigestName   string
}

A BuildProduct is one of the individual outputs of a buildpack. XXX why are there BuildArtifacts and BuildProducts instead of a single type?

func (BuildProduct) BuildArtifact added in v1.0.1

func (bp BuildProduct) BuildArtifact() BuildArtifact

BuildArtifact produces an equivalent BuildArtifact

func (*BuildProduct) String added in v1.0.1

func (bp *BuildProduct) String() string

type BuildResult

type BuildResult struct {
	Elapsed  time.Duration
	Products []*BuildProduct
}

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

func (*BuildResult) Contextualize added in v1.0.1

func (br *BuildResult) Contextualize(c *BuildContext)

Contextualize records details from the BuildContext into the BuildResult

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 ClientInserter added in v1.0.1

type ClientInserter struct{ Inserter }

ClientInsert, Client version of Inserter, differenciates between Server for graph

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
	// Startup in the default Startup health config for this region.
	Startup Startup
	// 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.

func ClusterFixture added in v1.0.1

func ClusterFixture(name string) *Cluster

ClusterFixture returns a fixtured Cluster.

func DefaultCluster added in v1.0.1

func DefaultCluster() *Cluster

DefaultCluster returns the default cluster definition. It has no name.

func (Cluster) Clone added in v0.0.3

func (c Cluster) Clone() *Cluster

Clone returns a deep copy of this Cluster.

func (*Cluster) Diff added in v1.0.1

func (c *Cluster) Diff(oc *Cluster) []string

Diff reports the differences between two Clusters.

type ClusterManager added in v1.0.1

type ClusterManager interface {
	ReadCluster(clusterName string) (Deployments, error)
	WriteCluster(clusterName string, deps Deployments, user User) error
}

ClusterManager reads and writes deployments as scoped by cluster

func MakeClusterManager added in v1.0.1

func MakeClusterManager(sm StateManager, ls logging.LogSink) ClusterManager

MakeClusterManager wraps a StateManager in a ClusterManager. This is the easy way to get a ClusterManager; It's assumed that more effecient ClusterManager implementations could be added to specific StateManagers.

func NewClusterManagerSpy added in v1.0.1

func NewClusterManagerSpy() (ClusterManager, *spies.Spy)

NewClusterManagerSpy produces a spy/controller pair for ClusterManager

type Clusters

type Clusters map[string]*Cluster

Clusters is a collection of Cluster

func GenerateClusters added in v1.0.1

func GenerateClusters(count int, gen func(idx int) *Cluster) Clusters

GenerateClusters calls gen count times and returns all the generate clusters. gen is passed values from 0 to count-1. You should ensure the Name of each cluster is unique, otherwise it will panic. If you leave the name blank, clusters will be named "clusterN" where N is in the range 1..count.

func (Clusters) Clone added in v0.0.3

func (cs Clusters) Clone() Clusters

Clone returns a deep copy of this Clusters.

func (Clusters) Names added in v0.0.3

func (cs Clusters) Names() []string

Names returns a slice of names of these clusters.

func (Clusters) String added in v0.0.3

func (cs Clusters) String() string

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 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 FieldDefinitions
	// Metadata contains the definitions for metadata fields
	Metadata FieldDefinitions
}

Defs holds definitions for organisation-level objects.

func (Defs) Clone added in v0.0.3

func (d Defs) Clone() Defs

Clone returns a deep copy of this Defs.

func (*Defs) Diff added in v1.0.1

func (ds *Defs) Diff(o *Defs) []string

Diff reports differences between two Defs.

func (*Defs) EmptyReceiver added in v1.0.1

func (ds *Defs) EmptyReceiver() restful.Comparable

EmptyReceiver implements Comparable on Defs

func (*Defs) VariancesFrom added in v1.0.1

func (ds *Defs) VariancesFrom(other restful.Comparable) restful.Variances

VariancesFrom implements Comparable on Defs

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"`
	// Metadata stores values about deployments for outside applications to use
	Metadata Metadata `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.
	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.
	NumInstances int
	// Volumes lists the volume mappings for this deploy.
	Volumes Volumes
	// Startup containts healthcheck options for this deploy.
	Startup Startup `yaml:",omitempty"`
	// Schedule is a cronjob-format schedule for jobs.
	Schedule string

	// SingularityRequestID is the ID of the request representing this
	// deployment in a Singularity scheduler.
	SingularityRequestID string `yaml:",omitempty"`
}

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

func DeployConfigFixture added in v1.0.1

func DeployConfigFixture(name string) DeployConfig

DeployConfigFixture returns a fixtured DeployConfig. There are no defined stereotypes of this fixture yet.

func (DeployConfig) Clone added in v0.0.3

func (dc DeployConfig) Clone() DeployConfig

Clone returns a deep copy of this DeployConfig.

func (*DeployConfig) Diff added in v0.0.3

func (dc *DeployConfig) Diff(o DeployConfig) (bool, []string)

Diff returns a list of differences between this and the other DeployConfig.

func (*DeployConfig) Equal

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

Equal is used to compare DeployConfigs

func (*DeployConfig) Repair added in v0.0.3

func (dc *DeployConfig) Repair(fs []Flaw) error

Repair implements Flawed for State

func (*DeployConfig) String

func (dc *DeployConfig) String() string

func (*DeployConfig) Validate added in v0.0.3

func (dc *DeployConfig) Validate() []Flaw

Validate returns a slice of Flaws.

type DeployConfigs added in v0.0.3

type DeployConfigs map[string]DeployConfig

A DeployConfigs is a map from cluster name to DeployConfig

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) Clone added in v0.0.3

func (spec DeploySpec) Clone() DeploySpec

Clone returns a deep copy of this DeploySpec.

func (DeploySpec) Diff added in v0.0.3

func (spec DeploySpec) Diff(other DeploySpec) (bool, []string)

Diff returns true and a list of differences if spec is different to other. Otherwise returns false, nil.

func (DeploySpec) Equal

func (spec DeploySpec) Equal(other DeploySpec) bool

Equal returns true if other equals spec.

func (DeploySpec) Repair added in v0.0.3

func (spec DeploySpec) Repair(fs []Flaw) error

Repair implements Flawed for State

func (DeploySpec) String added in v1.0.1

func (spec DeploySpec) String() string

func (DeploySpec) Validate added in v0.0.3

func (spec DeploySpec) Validate() []Flaw

Validate implements Flawed for State

type DeploySpecs

type DeploySpecs map[string]DeploySpec

DeploySpecs is a collection of Deployments associated with a manifest.

func (DeploySpecs) ClusterNames added in v1.0.1

func (specs DeploySpecs) ClusterNames() []string

ClusterNames returns the cluster names of each deployment, sorted alphabetically.

type DeployState added in v1.0.1

type DeployState struct {
	Deployment
	Status          DeployStatus
	ExecutorMessage string
	ExecutorData    interface{}
	SchedulerURL    string
}

A DeployState represents the state of a deployment in an external cluster. It wraps Deployment and adds Status.

func (DeployState) Clone added in v1.0.1

func (ds DeployState) Clone() *DeployState

Clone returns an independent clone of this DeployState.

func (*DeployState) Diff added in v1.0.1

func (ds *DeployState) Diff(o *DeployState) (bool, []string)

Diff computes the list of differences between two DeployStates and returns "true" if they're different, along with a list of differences

func (DeployState) Final added in v1.0.1

func (ds DeployState) Final() bool

Final reports whether we should expect this DeployState to be finished - in other words, DeployState.Final() -> false implies that a subsequent DeployState will have a different status; polling components will want to poll again.

func (DeployState) String added in v1.0.1

func (ds DeployState) String() string

func (*DeployState) Tabbed added in v1.0.1

func (ds *DeployState) Tabbed() string

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

type DeployStates added in v1.0.1

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

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

func MakeDeployStates added in v1.0.1

func MakeDeployStates(capacity int) DeployStates

MakeDeployStates creates a new DeployStates with capacity set.

func NewDeployStates added in v1.0.1

func NewDeployStates(from ...(*DeployState)) DeployStates

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

func NewDeployStatesFromMap added in v1.0.1

func NewDeployStatesFromMap(from ...map[DeploymentID](*DeployState)) DeployStates

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

func (DeployStates) Add added in v1.0.1

func (m DeployStates) Add(v *DeployState) (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 (DeployStates) AddAll added in v1.0.1

func (m DeployStates) AddAll(from DeployStates) (conflicting DeploymentID, success bool)

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

func (DeployStates) Any added in v1.0.1

func (m DeployStates) Any(predicate func(*DeployState) bool) (*DeployState, bool)

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

func (DeployStates) Clone added in v1.0.1

func (m DeployStates) Clone() DeployStates

Clone returns a pairwise copy of DeployStates.

func (DeployStates) Diff added in v1.0.1

func (d DeployStates) Diff(other Deployments) *DeployableChans

Diff computes the differences between two sets of DeployStates

func (DeployStates) Filter added in v1.0.1

func (m DeployStates) Filter(predicate func(*DeployState) bool) DeployStates

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

func (DeployStates) FilteredSnapshot added in v1.0.1

func (m DeployStates) FilteredSnapshot(predicate func(*DeployState) bool) map[DeploymentID](*DeployState)

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

func (DeployStates) Get added in v1.0.1

func (m DeployStates) Get(key DeploymentID) (v *DeployState, ok bool)

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

func (DeployStates) GetAll added in v1.0.1

func (m DeployStates) GetAll() map[DeploymentID](*DeployState)

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

func (DeployStates) IgnoringStatus added in v1.0.1

func (ds DeployStates) IgnoringStatus() Deployments

IgnoringStatus returns a Deployments containing all the nested deployments in this DeployStates.

func (DeployStates) Keys added in v1.0.1

func (m DeployStates) Keys() []DeploymentID

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

func (DeployStates) Len added in v1.0.1

func (m DeployStates) Len() int

Len returns number of elements in a map.

func (DeployStates) Merge added in v1.0.1

func (m DeployStates) Merge(other DeployStates) DeployStates

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

func (DeployStates) MustAdd added in v1.0.1

func (m DeployStates) MustAdd(v *DeployState)

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

func (DeployStates) Remove added in v1.0.1

func (m DeployStates) Remove(key DeploymentID)

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

func (DeployStates) Set added in v1.0.1

func (m DeployStates) Set(key DeploymentID, value *DeployState)

Set sets the value of index k to v.

func (*DeployStates) SetAll added in v1.0.1

func (m *DeployStates) SetAll(v map[DeploymentID](*DeployState))

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

func (DeployStates) Single added in v1.0.1

func (m DeployStates) Single(predicate func(*DeployState) bool) (*DeployState, bool)

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

func (DeployStates) Snapshot added in v1.0.1

func (m DeployStates) Snapshot() map[DeploymentID](*DeployState)

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

type DeployStatus added in v1.0.1

type DeployStatus int

DeployStatus represents the status of a deployment in an external cluster.

const (
	// DeployStatusAny represents any deployment status.
	DeployStatusAny DeployStatus = iota
	// DeployStatusPending means the deployment has been requested in the
	// cluster, but is not yet running.
	DeployStatusPending
	// DeployStatusActive means the deployment is up and running.
	DeployStatusActive
	// DeployStatusFailed means the deployment has failed.
	DeployStatusFailed
)

func (DeployStatus) Failed added in v1.0.1

func (ds DeployStatus) Failed() bool

Failed reports whether a DeployStatus represents a failed state.

func (DeployStatus) String added in v1.0.1

func (i DeployStatus) String() string

type Deployable added in v0.0.3

type Deployable struct {
	Status DeployStatus
	*Deployment
	*BuildArtifact
}

A Deployable is the pairing of a Deployment and the resolved image that can (or has) be used to deploy it.

func DeployableFixture added in v1.0.1

func DeployableFixture(name string) *Deployable

DeployableFixture returns a fixtured Deployment. There are no defined stereotypes of this fixture yet.

func (Deployable) EachField added in v1.0.1

func (d Deployable) EachField(f logging.FieldReportFn)

EachField ... you get the idea by now

type DeployableChans added in v0.0.3

type DeployableChans struct {
	Pairs chan *DeployablePair
	Errs  chan *DiffResolution
	sync.WaitGroup
}

A DeployableChans is a bundle of channels describing actions to take on a cluster

func NewDeployableChans added in v0.0.3

func NewDeployableChans(size ...int) *DeployableChans

NewDeployableChans returns a new DeployableChans with channels buffered to size.

func (*DeployableChans) Close added in v1.0.1

func (d *DeployableChans) Close()

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

func (*DeployableChans) Collect added in v1.0.1

func (d *DeployableChans) Collect() DeployablePairs

Collect returns a collected list of DeployablePairs represented by this DeployableChans

func (*DeployableChans) Log added in v1.0.1

Log adds a logging pipeline step onto a DeployableChans

func (*DeployableChans) Pipeline added in v1.0.1

Pipeline attaches a DeployableProcessor to the DeployableChans, and returns a new DeployableChans. Each segment of a pipeline consumes from

a channel of DeployablePairs and
a channel of error

and likewise produceds into a similar pair of channels. Each 'Pair that comes over the channel is handled to the DeployableProcessor to be processed. Processed pairs are put into the output channel,

and errors from the processing go into the output error channel.

Incoming errors are repeated onto the output error channel as well. The DeployableProcessor can optionally provide a HandleResolution method, in which case processing errors (both its own and from upstream) will be provided to that method. HandleResolution, by interface, has no return: the errors proceed unconditionally to the output error channel regardless.

func (*DeployableChans) ResolveNames added in v0.0.3

func (d *DeployableChans) ResolveNames(ctx context.Context, r Registry, ls logging.LogSink) *DeployableChans

ResolveNames resolves diffs.

type DeployablePair added in v0.0.3

type DeployablePair struct {
	Prior, Post *Deployable

	ExecutorData interface{}
	// Allows us to track a deployable pair over time and across API requests.
	UUID uuid.UUID
	// contains filtered or unexported fields
}

A DeployablePair is a pair of deployables, describing a "before and after" situation, where the Prior Deployable is the known state and the Post Deployable is the desired state.

func (*DeployablePair) Diffs added in v1.0.1

func (dp *DeployablePair) Diffs() Differences

Diffs returns the differences from Prior to Post.

func (*DeployablePair) EachField added in v1.0.1

func (dp *DeployablePair) EachField(fn logging.FieldReportFn)

EachField implements logging.EachFielder on DeployablePair.

func (*DeployablePair) ID added in v0.0.3

func (dp *DeployablePair) ID() DeploymentID

ID returns the ID of this DeployablePair.

func (*DeployablePair) Kind added in v1.0.1

Kind returns the kind of the pair.

func (*DeployablePair) SameResolution added in v1.0.1

func (dp *DeployablePair) SameResolution() DiffResolution

SameResolution returns a DiffResolution indicating that there is no intended change. The deployment may either be stable or in the process of being deployed.

func (*DeployablePair) SetID added in v1.0.1

func (dp *DeployablePair) SetID(did DeploymentID)

SetID sets the ID of this DeployablePair. Do not use except in tests.

type DeployablePairKind added in v1.0.1

type DeployablePairKind int

DeployablePairKind describes the disposition of a DeployablePair

const (
	// SameKind prior is unchanged from post
	SameKind DeployablePairKind = iota
	// AddedKind means an added deployable - there's no prior
	AddedKind
	// RemovedKind means a removed deployable - no post
	RemovedKind
	// ModifiedKind means modified deployable - post and prior are different
	ModifiedKind
)

func (DeployablePairKind) ExpectedResolutionType added in v1.0.1

func (kind DeployablePairKind) ExpectedResolutionType() ResolutionType

ExpectedResolutionType returns the expected resolution for this kind. This is used for logging purposes, when we drop a diff and don't attempt to rectify it.

func (DeployablePairKind) ResolveVerb added in v1.0.1

func (kind DeployablePairKind) ResolveVerb() string

ResolveVerb provides an imperative verb describing the resolution action required to resolve this kind of deployable pair.

func (DeployablePairKind) String added in v1.0.1

func (kind DeployablePairKind) String() string

type DeployablePairs added in v1.0.1

type DeployablePairs []*DeployablePair

DeployablePairs is a list of DeployablePair

type DeployablePassThrough added in v1.0.1

type DeployablePassThrough struct{}

DeployablePassThrough implements DeployableProcessor trivially: each method simply passes its argument on It is intended as an anonymous embed for Processors that e.g. don't care about Stable

func (DeployablePassThrough) Stable added in v1.0.1

Stable returns its argument

func (DeployablePassThrough) Start added in v1.0.1

Start returns its argument

func (DeployablePassThrough) Stop added in v1.0.1

Stop returns its argument

func (DeployablePassThrough) Update added in v1.0.1

Update returns its argument

type DeployableProcessor added in v1.0.1

type DeployableProcessor interface {
	HandlePairs(dp *DeployablePair) (*DeployablePair, *DiffResolution)
}

DeployableProcessor processes DeployablePairs off of a DeployableChans channel

type DeployableResolutionHandler added in v1.0.1

type DeployableResolutionHandler interface {
	HandleResolution(err *DiffResolution)
}

DeployableResolutionHandler handles the resolution of a single DiffResolution.

type Deployer

type Deployer interface {
	RunningDeployments(reg Registry, from Clusters) (DeployStates, error)
	Rectify(*DeployablePair) DiffResolution
	Status(Registry, Clusters, *DeployablePair) (*DeployState, error)
}

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

func NewDeployerSpy added in v1.0.1

func NewDeployerSpy() (Deployer, *spies.Spy)

NewDeployerSpy returns a spy implementation of Deployer.

func NewDummyDeployer added in v0.0.3

func NewDummyDeployer() Deployer

NewDummyDeployer creates a DummyDeployer

type DeployerSpy added in v1.0.1

type DeployerSpy struct {
	*spies.Spy
}

DeployerSpy is a noop deployer.

func (*DeployerSpy) Rectify added in v1.0.1

func (dd *DeployerSpy) Rectify(p *DeployablePair) DiffResolution

Rectify implements Deployer

func (*DeployerSpy) RunningDeployments added in v1.0.1

func (dd *DeployerSpy) RunningDeployments(reg Registry, from Clusters) (DeployStates, error)

RunningDeployments implements Deployer

func (*DeployerSpy) Status added in v1.0.1

func (dd *DeployerSpy) Status(r Registry, c Clusters, p *DeployablePair) (*DeployState, error)

Status implements Deployer

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
	// Flavor is the flavor of this deployment. See ManifestID for a fuller
	// description.
	Flavor string
	// 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
	// User
	User User
}

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(m *Manifest, nick string, cluster *Cluster, spec DeploySpec, inherit []DeploySpec) (*Deployment, error)

BuildDeployment constructs a deployment out of a Manifest.

func DeploymentFixture added in v1.0.1

func DeploymentFixture(name string) *Deployment

DeploymentFixture returns a fixtured Deployment. Stereotypes: * (default) a repeating "example" repo * sequenced-repo - uses sequences to return distinct deployments

func (Deployment) Clone added in v0.0.3

func (d Deployment) Clone() *Deployment

Clone returns a deep copy of this deployment.

func (*Deployment) DeploySpec added in v1.0.1

func (d *Deployment) DeploySpec() DeploySpec

DeploySpec returns a DeploySpec based on a Deployment

func (*Deployment) Diff added in v0.0.3

func (d *Deployment) Diff(o *Deployment) (bool, Differences)

Diff returns the differences between this deployment and another.

func (Deployment) EachField added in v1.0.1

func (d Deployment) EachField(f logging.FieldReportFn)

EachField implements EachFielder

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() DeploymentID

ID returns the DeployID of this deployment.

func (*Deployment) ManifestID added in v0.0.2

func (d *Deployment) ManifestID() ManifestID

ManifestID returns the ID of the Manifest describing this deployment.

func (*Deployment) Name

func (d *Deployment) Name() DeploymentID

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.

func (*Deployment) Validate added in v1.0.1

func (d *Deployment) Validate() []Flaw

Validate implements Flawed for State

type DeploymentID added in v1.0.1

type DeploymentID struct {
	ManifestID ManifestID
	Cluster    string
}

A DeploymentID identifies a deployment.

func ParseDeploymentID added in v1.0.1

func ParseDeploymentID(s string) (DeploymentID, error)

ParseDeploymentID parses a DeploymentID from s. The string provided must be in the same format as emitted by DeploymentID.String.

func (*DeploymentID) Digest added in v1.0.1

func (did *DeploymentID) Digest() []byte

Digest genrates an MD5 sum generated by the combination of Git repo, project flavor, and the name of the cluster separted by null bytes.

func (DeploymentID) EachField added in v1.0.1

func (did DeploymentID) EachField(fn logging.FieldReportFn)

EachField implements logging.EachFielder on DeploymentID.

func (DeploymentID) QueryMap added in v1.0.1

func (did DeploymentID) QueryMap() map[string]string

QueryMap returns a map suitable to use as an HTTP get parameter map to idenitfy a deployment.

func (DeploymentID) String added in v1.0.1

func (did DeploymentID) String() string

type DeploymentIDSlice added in v1.0.1

type DeploymentIDSlice []DeploymentID

DeploymentIDSlice is a slice of DeploymentID, named so that it can be sort-able

func (DeploymentIDSlice) Len added in v1.0.1

func (dids DeploymentIDSlice) Len() int

Len implements sort.Interface on []DeploymentID

func (DeploymentIDSlice) Less added in v1.0.1

func (dids DeploymentIDSlice) Less(i, j int) bool

Less implements sort.Interface on []DeploymentID

func (DeploymentIDSlice) Swap added in v1.0.1

func (dids DeploymentIDSlice) Swap(i, j int)

Swap implements sort.Interface on []DeploymentID

type DeploymentManager added in v1.0.1

type DeploymentManager interface {
	ReadDeployment(did DeploymentID) (*Deployment, error)
	WriteDeployment(dep *Deployment, user User) error
}

A DeploymentManager allows the loading and storing of individual Deployments.

func MakeDeploymentManager added in v1.0.1

func MakeDeploymentManager(sm StateManager, ls logging.LogSink) DeploymentManager

MakeDeploymentManager wraps a StateManager such that it fulfills the DeploymentManager interface

func NewDeploymentManagerSpy added in v1.0.1

func NewDeploymentManagerSpy() (DeploymentManager, *spies.Spy)

NewDeploymentManagerSpy returns a spy for testing purposes.

type DeploymentPair

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

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

func (*DeploymentPair) Diffs added in v1.0.1

func (dp *DeploymentPair) Diffs() Differences

Diffs returns the diffs in this pair, from prior to post. TODO: Cache the result.

func (*DeploymentPair) ID added in v0.0.3

func (dp *DeploymentPair) ID() DeploymentID

ID returns the DeployID of this deployment pair.

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 DeploymentsFromManifest added in v1.0.1

func DeploymentsFromManifest(defs Defs, 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 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[DeploymentID](*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 DeploymentID, 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) *DeployableChans

Diff computes the differences between two sets of Deployments

func (*Deployments) EmptyReceiver added in v1.0.1

func (ds *Deployments) EmptyReceiver() restful.Comparable

EmptyReceiver implements Comparable on 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[DeploymentID](*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 DeploymentID) (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[DeploymentID](*Deployment)

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

func (Deployments) Keys

func (m Deployments) Keys() []DeploymentID

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) 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) Only added in v0.0.3

func (ds *Deployments) Only() (*Deployment, error)

Only returns the single Manifest in a Manifests

XXX consider for inclusion in CMap
c&p from manifests.go - absolutely consider for CMap

func (Deployments) PutbackManifests added in v1.0.1

func (ds Deployments) PutbackManifests(defs Defs, olds Manifests, log logging.LogSink) (Manifests, error)

PutbackManifests creates manifests from deployments.

func (Deployments) RawManifests added in v1.0.1

func (ds Deployments) RawManifests(defs Defs, log logging.LogSink) (Manifests, error)

RawManifests creates manifests from deployments. "raw" because it's brand new - it doesn't maintain certain essential state over time. For almost all uses, you want PutbackManifests

func (Deployments) Remove

func (m Deployments) Remove(key DeploymentID)

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

func (Deployments) Set

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

Set sets the value of index k to v.

func (*Deployments) SetAll

func (m *Deployments) SetAll(v map[DeploymentID](*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[DeploymentID](*Deployment)

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

func (*Deployments) VariancesFrom added in v1.0.1

func (ds *Deployments) VariancesFrom(other restful.Comparable) restful.Variances

VariancesFrom implements Comparable on Deployments

type DetectResult

type DetectResult struct {
	// Compatible is true when the buildpack is compatible with the source
	// context.
	Compatible bool
	// Description is a human-readable description of what will be built.
	// It may for instance report back the base image that will be used,
	// or detected runtime version etc.
	Description string
	// Data is an arbitrary value. It can be used to pass interesting
	// detected information to the build step.
	Data interface{}
}

DetectResult represents the result of a detection.

type DiffResolution added in v0.0.3

type DiffResolution struct {
	// DeployID is the ID of the deployment being resolved
	DeploymentID
	// Desc describes the difference and its resolution
	Desc ResolutionType
	// Error captures the error (if any) encountered during diff resolution
	Error *ErrorWrapper

	// DeployState is the state of this deployment as running.
	DeployState *DeployState

	// SchedulerURL is a URL where this deployment can be seen.
	SchedulerURL string
}

DiffResolution is the result of applying a single diff.

func (DiffResolution) EachField added in v1.0.1

func (rez DiffResolution) EachField(f logging.FieldReportFn)

EachField implements EachFielder on DiffResolution.

func (DiffResolution) String added in v1.0.1

func (rez DiffResolution) String() string

type Differences added in v1.0.1

type Differences []string

Differences records the differences between two Deployments

func (Differences) String added in v1.0.1

func (diffs Differences) String() string

type DispatchStateManager added in v1.0.1

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

A DispatchStateManager handles dispatching data requests to local or remote datastores.

func NewDispatchStateManager added in v1.0.1

func NewDispatchStateManager(
	localCluster string,
	clusters []string,
	local StateManager,
	remote ClusterManager,
	ls logging.LogSink,
) *DispatchStateManager

NewDispatchStateManager builds a DispatchStateManager.

func (*DispatchStateManager) ReadCluster added in v1.0.1

func (dsm *DispatchStateManager) ReadCluster(clusterName string) (Deployments, error)

ReadCluster implements ClusterManager on DispatchStateManager.

func (*DispatchStateManager) ReadState added in v1.0.1

func (dsm *DispatchStateManager) ReadState() (*State, error)

ReadState implements StateManager on DispatchStateManager.

func (*DispatchStateManager) WriteCluster added in v1.0.1

func (dsm *DispatchStateManager) WriteCluster(clusterName string, deps Deployments, user User) error

WriteCluster implements ClusterManager on DispatchStateManager.

func (*DispatchStateManager) WriteState added in v1.0.1

func (dsm *DispatchStateManager) WriteState(state *State, user User) error

WriteState implements StateManager on DispatchStateManager.

type DummyRectificationClient added in v0.0.3

type DummyRectificationClient struct {
	Created  []Deployable
	Deployed []Deployable
	Deleted  []dummyDelete
	// contains filtered or unexported fields
}

DummyRectificationClient implements RectificationClient but doesn't act on the Mesos scheduler; instead it collects the changes that would be performed and options

func NewDummyRectificationClient added in v0.0.3

func NewDummyRectificationClient() *DummyRectificationClient

NewDummyRectificationClient builds a new DummyRectificationClient

func (*DummyRectificationClient) DeleteRequest added in v0.0.3

func (drc *DummyRectificationClient) DeleteRequest(
	cluster, reqid, message string) error

DeleteRequest (cluster url, request id, instance count, message)

func (*DummyRectificationClient) Deploy added in v0.0.3

func (drc *DummyRectificationClient) Deploy(d Deployable, reqID, depID string) error

Deploy implements part of the RectificationClient interface

func (*DummyRectificationClient) PostRequest added in v0.0.3

func (drc *DummyRectificationClient) PostRequest(d Deployable, id string) error

PostRequest (cluster, request id, instance count)

func (*DummyRectificationClient) SetLogger added in v0.0.3

func (drc *DummyRectificationClient) SetLogger(l logging.LogSink)

SetLogger sets the logger for the client

type DummyRegistry

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

DummyRegistry 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)

FeedArtifact accepts one artifact and associated error.

func (*DummyRegistry) FeedSourceID

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

FeedSourceID accepts a SourceID and associated error.

func (*DummyRegistry) FeedSourceIDList

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

FeedSourceIDList accepts a slice of SourceIDs and associated error.

func (*DummyRegistry) GetArtifact

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

GetArtifact implements Registry.GetArtifact.

func (*DummyRegistry) GetSourceID

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

GetSourceID implements part of ImageMapper

func (*DummyRegistry) ImageLabels added in v0.0.3

func (dc *DummyRegistry) ImageLabels(in string) (map[string]string, error)

ImageLabels gets the labels for an image name

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 DummyStateManager added in v0.0.3

type DummyStateManager struct {
	*State
	ReadCount, WriteCount int
	WriteErr              error
	ReadErr               error
}

DummyStateManager is used for testing

func NewDummyStateManager added in v1.0.1

func NewDummyStateManager() *DummyStateManager

NewDummyStateManager returns a dummy StateManager, suitable for testing.

func (*DummyStateManager) ReadState added in v0.0.3

func (sm *DummyStateManager) ReadState() (*State, error)

ReadState implements StateManager

func (*DummyStateManager) WriteState added in v0.0.3

func (sm *DummyStateManager) WriteState(s *State, u User) error

WriteState implements StateManager

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 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) Clone added in v1.0.1

func (e Env) Clone() Env

Clone returns an independent copy of e.

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.

func (EnvDef) Diff added in v1.0.1

func (ed EnvDef) Diff(o EnvDef) []string

Diff reports the differences.

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

func (EnvDefs) Clone added in v0.0.3

func (evs EnvDefs) Clone() EnvDefs

Clone returns a deep copy of this EnvDefs.

func (EnvDefs) Diff added in v1.0.1

func (evs EnvDefs) Diff(os EnvDefs) []string

Diff reports the differences.

type ErrorWrapper added in v1.0.1

type ErrorWrapper struct {
	MarshallableError
	// contains filtered or unexported fields
}

ErrorWrapper wraps an error so that it can be marshalled and unmarshalled to JSON

func WrapResolveError added in v1.0.1

func WrapResolveError(err error) *ErrorWrapper

WrapResolveError wraps an error inside an *ErrorWrapper for marshaling.

func (ErrorWrapper) Error added in v1.0.1

func (ew ErrorWrapper) Error() string

func (ErrorWrapper) MarshalJSON added in v1.0.1

func (ew ErrorWrapper) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller on ErrorWrapper. It makes sure that the embedded MarshallableError is populated and then marshals that. The upshot is that errors can be successfully marshalled into JSON for review by the client.

type FailedStatusError added in v1.0.1

type FailedStatusError struct{} // XXX maybe handy to have the root Singularity non-SUCCEEDED status?

A FailedStatusError reports that the the deploy has reported as failed on singularity

func (*FailedStatusError) Error added in v1.0.1

func (e *FailedStatusError) Error() string

type FieldDefinition added in v0.0.3

type FieldDefinition struct {
	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

	// Default adds a GDM wide default for a key.
	// It's assumed that if this is left empty, the field must be set
	Default string `yaml:",omitempty"`

	// If the zero value is the intended default value for a field,
	// you can mark it Optional: true.
	Optional bool `yaml:",omitempty"`
}

A FieldDefinition describes the requirements for a Metadata field.

func (FieldDefinition) Diff added in v1.0.1

func (fd FieldDefinition) Diff(o FieldDefinition) []string

Diff reports the differences.

type FieldDefinitions added in v0.0.3

type FieldDefinitions []FieldDefinition

FieldDefinitions is just a type alias for a slice of FieldDefinition-s

func (FieldDefinitions) Clone added in v0.0.3

func (rdf FieldDefinitions) Clone() FieldDefinitions

Clone returns a deep copy of this ResDefs.

func (FieldDefinitions) Diff added in v1.0.1

func (fds FieldDefinitions) Diff(os FieldDefinitions) []string

Diff reports the differences.

type Flaw added in v0.0.3

type Flaw interface {
	AddContext(string, interface{})
	Repair() error
}

A Flaw captures the digression from a validation rule

func RepairAll added in v0.0.3

func RepairAll(in []Flaw) ([]Flaw, []error)

RepairAll attempts to repair all the flaws in a slice, and returns errors and flaws when any of the flaws return errors

type FlawMessage added in v1.0.1

type FlawMessage struct {
	Flaws []Flaw
}

FlawMessage struct to hold flaws message

func (FlawMessage) ReturnFlawMsg added in v1.0.1

func (msg FlawMessage) ReturnFlawMsg() string

ReturnFlawMsg takes the flaws and creates a string for logging

type Flawed added in v0.0.3

type Flawed interface {
	// Validate returns a list of flaws that enumerate problems with the Flawed
	Validate() []Flaw
}

Flawed covers types that can be validated and have flaws Be kind to them, because aren't we all flawed somehow?

type GenericFlaw added in v0.0.3

type GenericFlaw struct {
	Desc       string
	RepairFunc func() error
}

GenericFlaw is a generic Flaw.

func FatalFlaw added in v1.0.1

func FatalFlaw(frmt string, vals ...interface{}) GenericFlaw

FatalFlaw constructs a Flaw that cannot be fixed.

func NewFlaw added in v0.0.3

func NewFlaw(desc string, repair func() error) GenericFlaw

NewFlaw returns a new generic flaw with the given description and repair function

func (GenericFlaw) AddContext added in v0.0.3

func (gf GenericFlaw) AddContext(name string, thing interface{})

AddContext discards the context - if you need the context, you should build a specialized Flaw

func (GenericFlaw) Error added in v0.0.3

func (gf GenericFlaw) Error() error

func (GenericFlaw) Repair added in v0.0.3

func (gf GenericFlaw) Repair() error

Repair implements Flaw.Repair.

func (GenericFlaw) String added in v0.0.3

func (gf GenericFlaw) String() string

type GenericHost added in v0.0.2

type GenericHost struct{}

GenericHost implements SourceHost, and is used as a fallback when none of the other SourceHosts are compatible with a SourceID.

func (GenericHost) CanParseSourceLocation added in v0.0.2

func (h GenericHost) CanParseSourceLocation(string) bool

CanParseSourceLocation always returns true.

func (GenericHost) GetSource added in v0.0.2

func (h GenericHost) GetSource(id SourceID) (Source, error)

GetSource always returns an error, since there is no generic way to get source code.

func (GenericHost) Owns added in v0.0.2

Owns always returns true.

func (GenericHost) ParseSourceLocation added in v0.0.2

func (h GenericHost) ParseSourceLocation(s string) (SourceLocation, error)

ParseSourceLocation defers to the global ParseSourceLocation.

type HTTPNameInserter added in v0.0.3

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

An HTTPNameInserter sends its inserts to the configured HTTP server

func NewHTTPNameInserter added in v0.0.3

func NewHTTPNameInserter(client restful.HTTPClient, tid TraceID, log logging.LogSink) *HTTPNameInserter

NewHTTPNameInserter creates a new HTTPNameInserter

func (*HTTPNameInserter) Insert added in v0.0.3

func (hni *HTTPNameInserter) Insert(sid SourceID, ba BuildArtifact) error

Insert implements Inserter for HTTPNameInserter

type HTTPStateManager added in v0.0.3

type HTTPStateManager struct {
	restful.HTTPClient

	User User
	// contains filtered or unexported fields
}

An HTTPStateManager gets state from a Sous server and transmits updates back to that server.

func NewHTTPStateManager added in v0.0.3

func NewHTTPStateManager(client restful.HTTPClient, tid TraceID, ls logging.LogSink) *HTTPStateManager

NewHTTPStateManager creates a new HTTPStateManager.

func (*HTTPStateManager) ReadCluster added in v1.0.1

func (hsm *HTTPStateManager) ReadCluster(clusterName string) (Deployments, error)

ReadCluster implements ClusterManager on HTTPStateManager.

func (*HTTPStateManager) ReadState added in v0.0.3

func (hsm *HTTPStateManager) ReadState() (*State, error)

ReadState implements StateReader for HTTPStateManager.

func (*HTTPStateManager) WriteCluster added in v1.0.1

func (hsm *HTTPStateManager) WriteCluster(clusterName string, deps Deployments, user User) error

WriteCluster implements ClusterManager on HTTPStateManager.

func (*HTTPStateManager) WriteState added in v0.0.3

func (hsm *HTTPStateManager) WriteState(s *State, u User) error

WriteState implements StateWriter for HTTPStateManager.

type ImageLabeller added in v1.0.1

type ImageLabeller interface {
	//ImageLabels finds the (docker) labels for a given image name
	ImageLabels(imageName string) (labels map[string]string, err error)
}

ImageLabeller can get the image labels for a given imageName

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 Inserter added in v0.0.3

type Inserter interface {
	// Insert pairs a SourceID with a build artifact.
	Insert(sid SourceID, ba BuildArtifact) error
}

An Inserter puts data into a registry.

type InserterSpy added in v1.0.1

type InserterSpy struct {
	*spies.Spy
}

An InserterSpy is a spy implementation of the Inserter interface

func NewInserterSpy added in v1.0.1

func NewInserterSpy() (InserterSpy, *spies.Spy)

NewInserterSpy returns a spy inserter for testing

func (InserterSpy) Insert added in v1.0.1

func (is InserterSpy) Insert(sid SourceID, ba BuildArtifact) error

Insert implements Inserter on InserterSpy

type Labeller

type Labeller interface {
	ApplyMetadata(*BuildResult) error
}

Labeller defines a container-based build system.

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"`
	// Flavor is an optional string, used to allow a single SourceLocation
	// to have multiple deployments defined per cluster. The empty Flavor
	// is perfectly valid. The pair (SourceLocation, Flavor) identifies a
	// manifest.
	Flavor string `yaml:",omitempty"`
	// 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 DefaultManifest added in v1.0.1

func DefaultManifest(mid ManifestID) *Manifest

DefaultManifest returns the default manifest.

func ManifestFixture added in v1.0.1

func ManifestFixture(name string) *Manifest

ManifestFixture returns a fixtured Manifest. Stereotypes are: * simple * with-metadata

func (Manifest) Clone added in v0.0.3

func (m Manifest) Clone() (c *Manifest)

Clone returns a deep copy of this Manifest.

func (*Manifest) Diff added in v0.0.3

func (m *Manifest) Diff(o *Manifest) (bool, []string)

Diff returns true and a list of differences if m and o are not equal. Otherwise returns false and nil.

func (*Manifest) EmptyReceiver added in v0.0.3

func (m *Manifest) EmptyReceiver() restful.Comparable

EmptyReceiver implements Comparable on Manifest

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() ManifestID

ID returns the SourceLocation.

func (*Manifest) Repair added in v0.0.3

func (m *Manifest) Repair(fs []Flaw) error

Repair implements Flawed for State

func (*Manifest) SetID added in v0.0.2

func (m *Manifest) SetID(mid ManifestID)

SetID sets the Source and Flavor fields of this Manifest to those of the supplied ManifestID.

func (*Manifest) Validate added in v0.0.3

func (m *Manifest) Validate() []Flaw

Validate implements Flawed for State

func (*Manifest) VariancesFrom added in v0.0.3

func (m *Manifest) VariancesFrom(c restful.Comparable) (vs restful.Variances)

VariancesFrom implements Comparable on Manifest

type ManifestID added in v0.0.2

type ManifestID struct {
	// Source is the SourceLocation of deployments described in this Manifest.
	Source SourceLocation
	// Flavor is an optional string which can be appended if multiple different
	// deployments of code from this SourceLocation need to be deployed in the
	// same cluster.
	Flavor string
}

ManifestID identifies a manifest by its SourceLocation and optional Flavor.

func GenerateManifestID added in v1.0.1

func GenerateManifestID(idx int, o ManifestIDOpts) ManifestID

GenerateManifestID generates a ManifestID using the supplied options.

func MustParseManifestID added in v0.0.2

func MustParseManifestID(s string) ManifestID

MustParseManifestID wraps ParseManifestID and panics if it returns an error.

func ParseManifestID added in v0.0.2

func ParseManifestID(s string) (ManifestID, error)

ParseManifestID parses a ManifestID from a SourceLocation.

func (ManifestID) EachField added in v1.0.1

func (mid ManifestID) EachField(fn logging.FieldReportFn)

EachField implements logging.EachFielder on DeploymentID.

func (ManifestID) MarshalText added in v0.0.2

func (mid ManifestID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. This is important for serialising maps that use ManifestID as a key.

func (ManifestID) MarshalYAML added in v0.0.2

func (mid ManifestID) MarshalYAML() (interface{}, error)

MarshalYAML serializes this ManifestID to a YAML string. It implements the github.com/go-yaml/yaml.Marshaler interface.

func (ManifestID) QueryMap added in v1.0.1

func (mid ManifestID) QueryMap() map[string]string

QueryMap returns a map suitable for use with the HTTP API.

func (ManifestID) String added in v0.0.2

func (mid ManifestID) String() string

func (*ManifestID) UnmarshalText added in v0.0.2

func (mid *ManifestID) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextMarshaler. This is important for deserialising maps that use ManifestID as a key.

func (*ManifestID) UnmarshalYAML added in v0.0.2

func (mid *ManifestID) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML deserializes a YAML string into this ManifestID. It implements the github.com/go-yaml/yaml.Unmarshaler interface.

type ManifestIDOpts added in v1.0.1

type ManifestIDOpts struct {
	// RepoFmt, DirFmt, FlavorFmt are the names of the repo, dir and flavor
	// respectively. If they contain the %d formatting directive, it will be
	// replaced with the index of the generated ID. They may only contain it
	// once each.
	RepoFmt, DirFmt, FlavorFmt string
}

ManifestIDOpts is used to control manifest ID generation.

func DefaultManifestIDOpts added in v1.0.1

func DefaultManifestIDOpts(except ...func(*ManifestIDOpts)) ManifestIDOpts

DefaultManifestIDOpts returns the default opts. If you supply one of more except funcs they are run on the default opts in order before it is returned.

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 ManifestKind = "scheduled-job"
)

func (ManifestKind) Validate added in v0.0.3

func (mk ManifestKind) Validate() []Flaw

Validate returns a list of flaws with this ManifestKind.

type Manifests

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

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

func DefaultManifests added in v1.0.1

func DefaultManifests(count int, except ...func(int, *Manifest)) Manifests

DefaultManifests returns count default manifests. If you pass except functions, they are each run in order on every manifest created, passing in also the index of that manifest.

func GenerateManifests added in v1.0.1

func GenerateManifests(count int, gen func(idx int) *Manifest) Manifests

GenerateManifests generates count manifests using the gen function to create each one, with the index from 0..count-1 passed in.

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[ManifestID](*Manifest)) Manifests

NewManifestsFromMap creates a new Manifests. You may optionally pass any number of map[ManifestID]*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 ManifestID, success bool)

AddAll returns (zero ManifestID, 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 ManifestID 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) Deployments added in v1.0.1

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

Deployments returns all deployments described by these Manifests.

func (Manifests) Diff added in v1.0.1

func (ms Manifests) Diff(other Manifests) (bool, []string)

Diff returns a true and a list of differences if ms and other are different. Otherwise it returns (false, nil).

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[ManifestID](*Manifest)

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

func (Manifests) Flavors added in v1.0.1

func (ms Manifests) Flavors() []string

Flavors returns all the flavors of manifests in this set of manifests.

func (Manifests) Get

func (m Manifests) Get(key ManifestID) (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[ManifestID](*Manifest)

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

func (Manifests) Keys

func (m Manifests) Keys() []ManifestID

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) Only added in v0.0.3

func (ms *Manifests) Only() (*Manifest, error)

Only returns the single Manifest in a Manifests

XXX consider for inclusion in CMap

func (Manifests) Remove

func (m Manifests) Remove(key ManifestID)

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

func (Manifests) Set

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

Set sets the value of index k to v.

func (*Manifests) SetAll

func (m *Manifests) SetAll(v map[ManifestID](*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[ManifestID](*Manifest)

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

func (Manifests) String added in v1.0.1

func (ms Manifests) String() string

type MarshallableError added in v1.0.1

type MarshallableError struct {
	Type, String string
}

MarshallableError captures parts of an error that can be serialized successfully

type Metadata added in v0.0.3

type Metadata map[string]string

Metadata represents an opaque map of metadata - Sous is agnostic about its contents, except to validate it against the top level schema.

func (Metadata) Clone added in v1.0.1

func (m Metadata) Clone() Metadata

Clone returns an independent copy of m.

func (Metadata) Equal added in v0.0.3

func (m Metadata) Equal(o Metadata) bool

Equal compares Metadatas

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 MissingResourceFlaw added in v0.0.3

type MissingResourceFlaw struct {
	Resources

	ClusterName    string
	Field, Default string
	// contains filtered or unexported fields
}

A MissingResourceFlaw captures the absence of a required resource field, and tries to repair it from the state defaults

func (*MissingResourceFlaw) AddContext added in v0.0.3

func (f *MissingResourceFlaw) AddContext(name string, i interface{})

AddContext implements Flaw.AddContext.

func (*MissingResourceFlaw) Repair added in v0.0.3

func (f *MissingResourceFlaw) Repair() error

Repair adds all missing fields set to default values.

func (*MissingResourceFlaw) String added in v0.0.3

func (f *MissingResourceFlaw) String() 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 NilVolumeFlaw added in v0.0.3

type NilVolumeFlaw struct {
	*DeployConfig
}

NilVolumeFlaw is used when DeployConfig.Volumes contains a nil.

func (*NilVolumeFlaw) AddContext added in v0.0.3

func (nvf *NilVolumeFlaw) AddContext(string, interface{})

AddContext simply discards all context - NilVolumeFlaw doesn't need it.

func (*NilVolumeFlaw) Repair added in v0.0.3

func (nvf *NilVolumeFlaw) Repair() error

Repair removes any nil entries in DeployConfig.Volumes.

type OwnerSet

type OwnerSet map[string]struct{}

OwnerSet collects the names of the owners of a deployment.

func NewOwnerSet added in v0.0.2

func NewOwnerSet(owners ...string) OwnerSet

NewOwnerSet creates a new owner set from the provided list of owners.

func (OwnerSet) Add

func (os OwnerSet) Add(owner string)

Add adds an owner to an ownerset.

func (OwnerSet) Clone added in v0.0.3

func (os OwnerSet) Clone() OwnerSet

Clone returns a deep copy of this OwnerSet.

func (OwnerSet) Diff added in v0.0.3

func (os OwnerSet) Diff(o OwnerSet) (bool, []string)

Diff returns (false, nil) if os == o. Otherwise it returns false and a list of short descriptions of each difference.

func (OwnerSet) Equal

func (os OwnerSet) Equal(o OwnerSet) bool

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

func (OwnerSet) Merge added in v1.0.1

func (os OwnerSet) Merge(other OwnerSet)

Merge adds the owners from other to this OwnerSet

func (OwnerSet) Remove

func (os OwnerSet) Remove(owner string)

Remove removes an owner from an ownerset.

func (OwnerSet) Slice added in v0.0.3

func (os OwnerSet) Slice() []string

Slice returns this set as a slice of unique strings, in alphabetical order.

type Qualities added in v1.0.1

type Qualities []Quality

Qualities is a list of Quality

func (Qualities) EachField added in v1.0.1

func (qs Qualities) EachField(f logging.FieldReportFn)

EachField implements EachFielder on BuildArtifact

func (Qualities) String added in v1.0.1

func (qs Qualities) String() string

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 QueueSet added in v1.0.1

type QueueSet interface {
	PushIfEmpty(r *Rectification) (*QueuedR11n, bool)
	Push(r *Rectification) (*QueuedR11n, bool)
	Wait(did DeploymentID, id R11nID) (DiffResolution, bool)
	Queues() map[DeploymentID]*R11nQueue
}

QueueSet is the interface for a set of queues

func NewQueueSetSpy added in v1.0.1

func NewQueueSetSpy() (QueueSet, *spies.Spy)

NewQueueSetSpy builds a spy/controller pair

type QueueSetSpy added in v1.0.1

type QueueSetSpy struct {
	*spies.Spy
}

QueueSetSpy is a spy for the QueueSet interface.

func (QueueSetSpy) Push added in v1.0.1

func (s QueueSetSpy) Push(r *Rectification) (*QueuedR11n, bool)

Push is a spy implementation of QueueSet

func (QueueSetSpy) PushIfEmpty added in v1.0.1

func (s QueueSetSpy) PushIfEmpty(r *Rectification) (*QueuedR11n, bool)

PushIfEmpty is a spy implementation of QueueSet

func (QueueSetSpy) Queues added in v1.0.1

func (s QueueSetSpy) Queues() map[DeploymentID]*R11nQueue

Queues is a spy implementation of QueueSet

func (QueueSetSpy) Wait added in v1.0.1

func (s QueueSetSpy) Wait(did DeploymentID, id R11nID) (DiffResolution, bool)

Wait is a spy implementation of QueueSet

type QueuedR11n added in v1.0.1

type QueuedR11n struct {
	ID            R11nID
	Pos           int
	Rectification *Rectification
	// contains filtered or unexported fields
}

QueuedR11n is a queue item wrapping a Rectification with an ID and position.

type R11nID added in v1.0.1

type R11nID string

R11nID is a QueuedR11n identifier.

func NewR11nID added in v1.0.1

func NewR11nID() R11nID

NewR11nID returns a new random R11nID.

type R11nQueue added in v1.0.1

type R11nQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

R11nQueue is a queue of rectifications.

func NewR11nQueue added in v1.0.1

func NewR11nQueue(opts ...R11nQueueOpt) *R11nQueue

NewR11nQueue creates a freshly initialised R11nQueue.

func (*R11nQueue) ByID added in v1.0.1

func (rq *R11nQueue) ByID(id R11nID) (*QueuedR11n, bool)

ByID returns the queued rectification matching ID and true if it exists, nil and false otherwise.

func (*R11nQueue) Len added in v1.0.1

func (rq *R11nQueue) Len() int

Len returns the current number of items in the queue.

func (*R11nQueue) Push added in v1.0.1

func (rq *R11nQueue) Push(r *Rectification) (*QueuedR11n, bool)

Push adds r to the queue, wrapped in a *QueuedR11n. It returns the wrapper. If the push was successful, it returns the wrapper and true, otherwise it returns nil and false.

func (*R11nQueue) PushIfEmpty added in v1.0.1

func (rq *R11nQueue) PushIfEmpty(r *Rectification) (*QueuedR11n, bool)

PushIfEmpty adds an item to the queue if it is empty, and returns the wrapper added and true if successful. If the queue is not empty, or is full, it returns nil, false.

func (*R11nQueue) Snapshot added in v1.0.1

func (rq *R11nQueue) Snapshot() []QueuedR11n

Snapshot returns a slice of items to be processed in the queue ordered by their queue position. It includes the item being worked on at the head of the queue.

func (*R11nQueue) Start added in v1.0.1

func (rq *R11nQueue) Start(handler func(*QueuedR11n) DiffResolution)

Start starts applying handler to each item on the queue in order.

func (*R11nQueue) Wait added in v1.0.1

func (rq *R11nQueue) Wait(id R11nID) (DiffResolution, bool)

Wait waits for a particular rectification to be processed then returns its result. If that rectification is not in this queue, it immediately returns a zero DiffResolution and false.

type R11nQueueOpt added in v1.0.1

type R11nQueueOpt func(*R11nQueue)

R11nQueueOpt is an option for configuring an R11nQueue.

func R11nQueueCap added in v1.0.1

func R11nQueueCap(cap int) R11nQueueOpt

R11nQueueCap sets the max capacity of an R11nQueue to the supplied cap.

func R11nQueueStartWithHandler added in v1.0.1

func R11nQueueStartWithHandler(handler func(*QueuedR11n) DiffResolution) R11nQueueOpt

R11nQueueStartWithHandler starts processing the queue using the supplied handler.

type R11nQueueSet added in v1.0.1

type R11nQueueSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

R11nQueueSet is a concurrency-safe mapping of DeploymentID to R11nQueue.

func NewR11nQueueSet added in v1.0.1

func NewR11nQueueSet(opts ...R11nQueueOpt) *R11nQueueSet

NewR11nQueueSet returns a ready to use R11nQueueSet.

func (*R11nQueueSet) Push added in v1.0.1

func (rqs *R11nQueueSet) Push(r *Rectification) (*QueuedR11n, bool)

Push creates a queue for the DeploymentID of r if it does not already exist. It calls Push on that R11nQueue passing r.

func (*R11nQueueSet) PushIfEmpty added in v1.0.1

func (rqs *R11nQueueSet) PushIfEmpty(r *Rectification) (*QueuedR11n, bool)

PushIfEmpty creates a queue for the DeploymentID of r if it does not already exist. It calls PushIfEmpty on that R11nQueue passing r.

func (*R11nQueueSet) Queues added in v1.0.1

func (rqs *R11nQueueSet) Queues() map[DeploymentID]*R11nQueue

Queues returns a snapshot of queues in this set.

func (*R11nQueueSet) Wait added in v1.0.1

func (rqs *R11nQueueSet) Wait(did DeploymentID, id R11nID) (DiffResolution, bool)

Wait waits for the r11n with id id to complete, if it is found in the queue for did. If there is no queue for did or it exists but does not contain id, then it returns zero DiffResolution, false.

type Rectification added in v1.0.1

type Rectification struct {
	// Pair is not a pointer as it's considered an immutable instruction.
	Pair DeployablePair
	// Resolution is the final resolution of this single rectification.
	sync.RWMutex
	Resolution DiffResolution
	// contains filtered or unexported fields
}

Rectification represents the rectification of a single DeployablePair.

func NewRectification added in v1.0.1

func NewRectification(dp DeployablePair, l logging.LogSink) *Rectification

NewRectification is used to rectify differences on a single Deployment. After this its useful life is over.

func (*Rectification) Begin added in v1.0.1

func (r *Rectification) Begin(d Deployer, reg Registry, rf *ResolveFilter, stateReader StateReader)

Begin begins applying sr.Pair using d Deployer. Call Result to get the result. Begin can be called multiple times but performs its function only once.

func (*Rectification) EachField added in v1.0.1

func (r *Rectification) EachField(fn logging.FieldReportFn)

EachField implements logging.EachFielder on Rectification.

func (*Rectification) Wait added in v1.0.1

func (r *Rectification) Wait() DiffResolution

Wait must be called after Begin. It waits for and returns the result.

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) error
}

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

type Registry

type Registry interface {
	ImageLabeller
	// 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
	// contains filtered or unexported fields
}

RegistryDumper dumps the contents of artifact registries

func NewRegistryDumper

func NewRegistryDumper(r Registry, ls logging.LogSink) *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 RegistrySpy added in v1.0.1

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

A RegistrySpy is a spy implementation of the Registry interface

func NewRegistrySpy added in v1.0.1

func NewRegistrySpy() (RegistrySpy, *spies.Spy)

NewRegistrySpy returns a spy Registry for testing.

func (RegistrySpy) GetArtifact added in v1.0.1

func (spy RegistrySpy) GetArtifact(sid SourceID) (*BuildArtifact, error)

GetArtifact implements Registry on RegistrySpy.

func (RegistrySpy) GetSourceID added in v1.0.1

func (spy RegistrySpy) GetSourceID(art *BuildArtifact) (SourceID, error)

GetSourceID implements Registry on RegistrySpy.

func (RegistrySpy) ImageLabels added in v1.0.1

func (spy RegistrySpy) ImageLabels(imageName string) (labels map[string]string, err error)

ImageLabels implements Registry on RegistrySpy.

func (RegistrySpy) ListSourceIDs added in v1.0.1

func (spy RegistrySpy) ListSourceIDs() ([]SourceID, error)

ListSourceIDs implements Registry on RegistrySpy.

func (RegistrySpy) Warmup added in v1.0.1

func (spy RegistrySpy) Warmup(name string) error

Warmup implements Registry on RegistrySpy.

type ResolutionType added in v1.0.1

type ResolutionType string

ResolutionType marks the kind of a DiffResolution XXX should be made an int and generate with gostringer

type ResolveErrors

type ResolveErrors struct {
	Causes []ErrorWrapper
}

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 ResolveFieldMatcher added in v1.0.1

type ResolveFieldMatcher struct {
	Match *string
}

A ResolveFieldMatcher matches against any particular string, or All strings.

func NewResolveFieldMatcher added in v1.0.1

func NewResolveFieldMatcher(match string) ResolveFieldMatcher

NewResolveFieldMatcher wraps a string in a ResolveFieldMatcher that matches that string.

func (ResolveFieldMatcher) All added in v1.0.1

func (matcher ResolveFieldMatcher) All() bool

All returns true if this Matcher matches all values, or false if it matches a specific value.

func (ResolveFieldMatcher) Value added in v1.0.1

func (matcher ResolveFieldMatcher) Value() (string, error)

Value returns the match value or else returns a descriptive error.

func (ResolveFieldMatcher) ValueOr added in v1.0.1

func (matcher ResolveFieldMatcher) ValueOr(def string) string

ValueOr returns the match value for this matcher, or the default value provided if the matcher matches all values.

type ResolveFilter added in v0.0.3

type ResolveFilter struct {
	//       xxx type-per-field? value?
	Repo     ResolveFieldMatcher
	Offset   ResolveFieldMatcher
	Tag      ResolveFieldMatcher
	Revision ResolveFieldMatcher
	Flavor   ResolveFieldMatcher
	Cluster  ResolveFieldMatcher
	Status   DeployStatus
}

A ResolveFilter filters Deployments, DeployStates and Clusters for the purpose of Resolve.resolve().

func (*ResolveFilter) All added in v0.0.3

func (rf *ResolveFilter) All() bool

All returns true if the ResolveFilter would allow All deployments.

func (*ResolveFilter) DeploymentID added in v1.0.1

func (rf *ResolveFilter) DeploymentID(mid ManifestID) (DeploymentID, error)

DeploymentID returns a DeploymentID based on the ResolveFilter and a ManifestID

func (*ResolveFilter) EachField added in v1.0.1

func (rf *ResolveFilter) EachField(fn logging.FieldReportFn)

EachField implement logging.EachFielder on ResolveFilter.

func (*ResolveFilter) FilterClusterName added in v0.0.3

func (rf *ResolveFilter) FilterClusterName(name string) bool

FilterClusterName returns true if the given string would be matched by this ResolveFilter as a ClusterName.

func (*ResolveFilter) FilterDeployStates added in v1.0.1

func (rf *ResolveFilter) FilterDeployStates(d *DeployState) bool

FilterDeployStates is similar to FilterDeployment, but also filters by DeployStatus.

func (*ResolveFilter) FilterDeployment added in v0.0.3

func (rf *ResolveFilter) FilterDeployment(d *Deployment) bool

FilterDeployment behaves as a DeploymentPredicate, filtering Deployments if they match its criteria.

func (*ResolveFilter) FilterManifest added in v0.0.3

func (rf *ResolveFilter) FilterManifest(m *Manifest) bool

FilterManifest returns true if the Manifest is matched by this ResolveFilter.

func (*ResolveFilter) FilterManifestID added in v0.0.3

func (rf *ResolveFilter) FilterManifestID(m ManifestID) bool

FilterManifestID returns true if the ManifestID is matched by this ResolveFilter.

func (*ResolveFilter) FilteredClusters added in v0.0.3

func (rf *ResolveFilter) FilteredClusters(c Clusters) Clusters

FilteredClusters returns a new Clusters relevant to the Deployments that this ResolveFilter would permit.

func (*ResolveFilter) SetTag added in v1.0.1

func (rf *ResolveFilter) SetTag(tag string) error

SetTag sets the tag based on a tag string - is ensures the tag parses as semver.

func (*ResolveFilter) SourceID added in v1.0.1

func (rf *ResolveFilter) SourceID(mid ManifestID) (SourceID, error)

SourceID returns a SourceID based on the ResolveFilter and a ManifestID

func (*ResolveFilter) SourceLocation added in v1.0.1

func (rf *ResolveFilter) SourceLocation() (SourceLocation, bool)

SourceLocation returns a SourceLocation and true if this ResolveFilter describes a complete specific source location (i.e. it has exact Repo and Offset matches set). Otherwise it returns a zero SourceLocation and false.

func (*ResolveFilter) String added in v0.0.3

func (rf *ResolveFilter) String() string

func (*ResolveFilter) TagVersion added in v1.0.1

func (rf *ResolveFilter) TagVersion() (semv.Version, error)

TagVersion gets the semv parsed from the tag. It returns whatever parsing errors there might be.

type ResolveRecorder added in v0.0.3

type ResolveRecorder struct {

	// Log is a channel of statuses of individual diff resolutions.
	Log chan DiffResolution

	sync.RWMutex
	// contains filtered or unexported fields
}

ResolveRecorder represents the status of a resolve run.

func NewResolveRecorder added in v0.0.3

func NewResolveRecorder(intended Deployments, ls logging.LogSink, f func(*ResolveRecorder)) *ResolveRecorder

NewResolveRecorder creates a new ResolveRecorder and calls f with it as its argument. It then returns that ResolveRecorder immediately.

func (*ResolveRecorder) CurrentStatus added in v0.0.3

func (rr *ResolveRecorder) CurrentStatus() (rs ResolveStatus)

CurrentStatus returns a copy of the current status of the resolve

func (*ResolveRecorder) Done added in v0.0.3

func (rr *ResolveRecorder) Done() bool

Done returns true if the resolution has finished. Otherwise it returns false.

func (*ResolveRecorder) Phase added in v0.0.3

func (rr *ResolveRecorder) Phase() string

Phase returns the name of the current phase.

func (*ResolveRecorder) Wait added in v0.0.3

func (rr *ResolveRecorder) Wait() error

Wait blocks until the resolution is finished.

type ResolveState added in v0.0.3

type ResolveState int

A ResolveState reflects the state of the Sous clusters in regard to resolving a particular SourceID.

const (
	// ResolveNotPolled is the entry state. It means we haven't received data
	// from a server yet.
	ResolveNotPolled ResolveState = iota
	// ResolveNotStarted conveys the condition that the server is not yet working
	// to resolve the SourceLocation in question. Granted that a manifest update
	// has succeeded, expect that once the current auto-resolve cycle concludes,
	// the resolve-subject GDM will be updated, and we'll move past this state.
	ResolveNotStarted
	// ResolveNotVersion conveys that the server knows the SourceLocation
	// already, but is resolving a different version. Again, expect that on the
	// next auto-resolve cycle we'll move past this state.
	ResolveNotVersion
	// ResolvePendingRequest conveys that, while the server has registered the
	// intent for the current resolve cycle, no request has yet been made to
	// Singularity.
	ResolvePendingRequest
	// ResolveInProgress conveys a resolve action has been taken by the server,
	// which implies that the server's intended version (which we've confirmed is
	// the same as our intended version) is different from the
	// Mesos/Singularity's version.
	ResolveInProgress
	// ResolveTasksStarting is the state when the resolution is complete from
	// Sous' point of view, but awaiting tasks starting in the cluster.
	ResolveTasksStarting
	// ResolveErredHTTP  conveys that the HTTP request to the server returned an error
	ResolveErredHTTP
	// ResolveErredRez conveys that the resolving server reported a transient error
	ResolveErredRez
	// ResolveNotIntended indicates that a particular cluster does not intend to
	// deploy the given deployment(s)
	ResolveNotIntended
	// ResolveComplete is the success state: the server knows about our intended
	// deployment, and that deployment has returned as having been stable.
	ResolveComplete
	// ResolveFailed indicates that a particular cluster is in a failed state
	// regarding resolving the deployments, and that resolution cannot proceed.
	ResolveFailed
	// ResolveHTTPFailed indicates that the sous server in a particular cluster
	// has returned HTTP errors 10 consequetive times and is assumed down
	ResolveHTTPFailed
	// ResolveMAX is not a state itself: it marks the top end of resolutions. All
	// other states belong before it.
	ResolveMAX

	// ResolveTERMINALS is not a state itself: it demarks resolution states that
	// might proceed from states that are complete
	ResolveTERMINALS = ResolveNotIntended
)

func (ResolveState) Prose added in v1.0.1

func (rs ResolveState) Prose() string

Prose returns a string that explains what the state means.

func (ResolveState) String added in v0.0.3

func (rs ResolveState) String() string

XXX we might consider using go generate with `stringer` (c.f.)

type ResolveStatus added in v0.0.3

type ResolveStatus struct {
	// Started collects the time that the Status began being collected
	Started,

	Finished time.Time
	// Phase reports the current phase of resolution
	Phase string
	// Intended are the deployments that are the target of this resolution
	Intended []*Deployment
	// logging.Log collects the resolution steps that have been performed
	Log []DiffResolution
	// Errs collects errors during resolution
	Errs ResolveErrors
}

ResolveStatus captures the status of a Resolve

func (*ResolveStatus) Err added in v0.0.3

func (rs *ResolveStatus) Err() error

Err returns any collected error from the course of resolution

type Resolver

type Resolver struct {
	Deployer Deployer
	Registry Registry
	*ResolveFilter

	QueueSet *R11nQueueSet
	// contains filtered or unexported fields
}

Resolver is responsible for resolving intended and actual deployment states.

func NewResolver

func NewResolver(d Deployer, r Registry, rf *ResolveFilter, ls logging.LogSink, qs *R11nQueueSet) *Resolver

NewResolver creates a new Resolver.

func (*Resolver) Begin added in v0.0.3

func (r *Resolver) Begin(intended Deployments, clusters Clusters) *ResolveRecorder

Begin is similar to Resolve, except that it returns a ResolveRecorder almost immediately, which can be queried for information about the ongoing resolution. You can check if resolution is finished by calling Done() on the returned ResolveRecorder.

This process 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) Clone added in v0.0.3

func (r Resources) Clone() Resources

Clone returns a deep copy of this Resources.

func (Resources) Cpus

func (r Resources) Cpus() float64

Cpus returns the number of CPUs.

func (Resources) Equal

func (r Resources) Equal(o Resources) bool

Equal checks equivalence between resource maps

func (Resources) Memory

func (r Resources) Memory() float64

Memory returns memory in MB.

func (Resources) Ports

func (r Resources) Ports() int32

Ports returns the number of ports required.

func (Resources) Validate added in v0.0.3

func (r Resources) Validate() []Flaw

Validate checks that each required resource value is set in this Resources, or in the inherited Resources.

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 Server added in v1.0.1

type Server struct {
	ClusterName string
	URL         string
}

Server copied from server - avoiding coupling to server implemention

type ServerListData added in v1.0.1

type ServerListData struct {
	Servers []Server
}

ServerListData copied from server - avoiding coupling to server implemention

type Source added in v0.0.2

type Source struct {
	// ID is the identity of this source.
	ID SourceID
	// Context contains info about this repo
	Context SourceContext
	// LocalRootDir is the absolute path on the local filesystem to the cloned
	// repository root.
	LocalRootDir string
	// LocalOffsetDir is the absolute path on the local filesystem to the offset
	// matching ID.Location.Dir.
	LocalOffsetDir string
}

Source represents a body of source code.

type SourceContext

type SourceContext struct {
	RootDir, OffsetDir, Branch, Revision string
	Files, ModifiedFiles, NewFiles       []string
	Tags                                 []Tag
	NearestTag                           Tag
	NearestTagName, NearestTagRevision   string
	PrimaryRemoteURL                     string
	RemoteURL                            string
	RemoteURLs                           []string
	DirtyWorkingTree                     bool
	RevisionUnpushed                     bool
	DevBuild                             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) TagVersion added in v1.0.1

func (sc *SourceContext) TagVersion() string

TagVersion returns a semver string if the most recent tag conforms to a semver format. Otherwise it returns an empty string

func (*SourceContext) Version

func (sc *SourceContext) Version() SourceID

Version returns the SourceID.

type SourceHost added in v0.0.2

type SourceHost interface {
	// CanParseSourceLocation returns true if this SourceHost should attempt to
	// parse the string. If CanParseSourceLocation returns true, Sous will not
	// attempt to parse using any other SourceHost.
	CanParseSourceLocation(string) bool
	// ParseSourceLocation parses a SourceLocation from a string.
	ParseSourceLocation(string) (SourceLocation, error)
	// Owns returns true if this SourceHost owns the provided SourceLocation.
	Owns(SourceLocation) bool
	// GetSource returns the source code for this SourceID.
	GetSource(SourceID) (Source, error)
}

SourceHost represents a source code repository host.

type SourceHostChooser added in v0.0.2

type SourceHostChooser struct {
	// SourceHosts is an ordered list of SourceHosts. The order is significant,
	// earlier SourceHosts beat later ones.
	SourceHosts []SourceHost
}

SourceHostChooser wraps a slice of SourceHosts and delegates to the most appropriate one for various tasks.

func (*SourceHostChooser) ParseSourceLocation added in v0.0.2

func (e *SourceHostChooser) ParseSourceLocation(s string) (SourceLocation, error)

ParseSourceLocation tries to parse a SourceLocation using the first SourceHost that returns true for CanParseSourceLocation(s).

It returns an error if the chosen SouceHost returns an error, or if none of the SourceHosts return true for CanParseSourceLocation(s).

type SourceID

type SourceID struct {
	// Location is the repo/dir pair indicating the location of the source
	// code. Note that not all locations will be valid with all Versions.
	Location SourceLocation
	// Version identifies a specific version of the source code at Repo/Dir.
	Version semv.Version
}

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

func MakeSourceID added in v1.0.1

func MakeSourceID(repo, dir, version string) SourceID

MakeSourceID is a convenience function to build a SourceID.

func MustNewSourceID added in v0.0.2

func MustNewSourceID(repo, offset, version string) SourceID

MustNewSourceID wraps NewSourceID and panics if it returns an error.

func MustParseSourceID

func MustParseSourceID(s string) SourceID

MustParseSourceID wraps ParseSourceID and panics if it returns an error.

func NewSourceID added in v0.0.2

func NewSourceID(repo, offset, version string) (SourceID, error)

NewSourceID attempts to create a new SourceID from strings representing the separate components. It expects a repo to be in canonicalised form, e.g. host/some/path. It does not attempt to translate or validate the repo.

func ParseSourceID

func ParseSourceID(s string) (SourceID, error)

ParseSourceID parses an entire SourceID.

func (SourceID) EachField added in v1.0.1

func (sid SourceID) EachField(fn logging.FieldReportFn)

EachField implements logging.EachFielder on SourceID.

func (SourceID) Equal

func (sid SourceID) Equal(o SourceID) bool

Equal tests the equality between this SourceID and another.

func (SourceID) HTTPQueryMap added in v1.0.1

func (sid SourceID) HTTPQueryMap() map[string]string

HTTPQueryMap is similar to QueryValues but returns a flat map.

func (SourceID) QueryValues added in v0.0.3

func (sid SourceID) QueryValues() url.Values

QueryValues returns the url.Values for this SourceIDs

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
}

SourceLocation identifies a directory inside a source code repository. Note that the directory is ambiguous without the addition of a revision ID. N.b. the {M,Unm}arshal* methods - SL doesn't serialize as you might expect

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) EachField added in v1.0.1

func (sl *SourceLocation) EachField(f logging.FieldReportFn)

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) ShortName added in v1.0.1

func (sl SourceLocation) ShortName() (string, error)

ShortName returns the name of the repo without the FQDN or the organization name.

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. n.b.: UnmarshalText is used to deserialize server responses, so it needs to be fairly liberal in how it parses things. If you need specific parse errors, use ParseSourceLocation

func (*SourceLocation) UnmarshalYAML

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

UnmarshalYAML deserializes a YAML document into this SourceLocation

type Startup added in v1.0.1

type Startup struct {
	SkipCheck bool `yaml:",omitempty"`

	ConnectDelay    int `yaml:",omitempty"` // Healthcheck.StartupDelaySeconds
	Timeout         int `yaml:",omitempty"` // Healthcheck.StartupTimeoutSeconds
	ConnectInterval int `yaml:",omitempty"` // Healthcheck.StartupIntervalSeconds

	CheckReadyProtocol        string `yaml:",omitempty"` // Healthcheck.Protocol
	CheckReadyURIPath         string `yaml:",omitempty"` // Healthcheck.URI
	CheckReadyPortIndex       int    `yaml:",omitempty"` // Healthcheck.PortIndex
	CheckReadyFailureStatuses []int  `yaml:",omitempty"` // Healthcheck.FailureStatusCodes
	CheckReadyURITimeout      int    `yaml:",omitempty"` // Healthcheck.ResponseTimeoutSeconds
	CheckReadyInterval        int    `yaml:",omitempty"` // Healthcheck.IntervalSeconds
	CheckReadyRetries         int    `yaml:",omitempty"` // Healthcheck.MaxRetries

}

Startup is the configuration for startup checks for a service deployment. c.f. DeployConfig for use.

func (Startup) Equal added in v1.0.1

func (s Startup) Equal(o Startup) bool

Equal returns true if s == o.

func (Startup) MergeDefaults added in v1.0.1

func (s Startup) MergeDefaults(base Startup) Startup

MergeDefaults merges default values with a Startup and returns the result

func (Startup) UnmergeDefaults added in v1.0.1

func (s Startup) UnmergeDefaults(base, old Startup) Startup

UnmergeDefaults unmerges default values from a Startup based on an old value and returns the result

func (*Startup) Validate added in v1.0.1

func (s *Startup) Validate() []Flaw

Validate implements Flawed on Startup.

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 DefaultStateFixture added in v1.0.1

func DefaultStateFixture() *State

DefaultStateFixture provides a dummy state for tests by calling StateFixture with the following options:

 StateFixtureOpts{
	  ClusterCount:  3,
   ManifestCount: 3,
 }

func DefaultStateFixtureWithFlavorsOffsets added in v1.0.1

func DefaultStateFixtureWithFlavorsOffsets() *State

DefaultStateFixtureWithFlavorsOffsets is similar to DefaultStateFixture but adds flavorN offsetN to each manifest with repoN.

func NewState

func NewState() *State

NewState returns a valid empty state.

func StateFixture added in v1.0.1

func StateFixture(o StateFixtureOpts) *State

StateFixture provides a dummy state for tests.

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) CheckEtag added in v1.0.1

func (s State) CheckEtag(etag string) error

CheckEtag checks that the etag matches the etag on the state (if present).

func (State) Clone added in v0.0.3

func (s State) Clone() *State

Clone returns a deep copy of this State.

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) GetEtag added in v1.0.1

func (s State) GetEtag() (string, error)

GetEtag gets the etag, or returns an error if no etag set.

func (*State) SetEtag added in v1.0.1

func (s *State) SetEtag(etag string)

SetEtag sets an etag on the state.

func (*State) UpdateDeployments added in v0.0.3

func (s *State) UpdateDeployments(log logging.LogSink, ds ...*Deployment) error

UpdateDeployments upserts ds into the State

func (*State) Validate added in v0.0.3

func (s *State) Validate() []Flaw

Validate implements Flawed for State

type StateFixtureOpts added in v1.0.1

type StateFixtureOpts struct {
	ClusterCount  int
	ManifestCount int

	ClusterSuffix string

	ManifestIDOpts *ManifestIDOpts
	ClusterFunc    func() *Cluster
}

StateFixtureOpts allows configuring StateFixture calls.

type StateManager added in v0.0.3

type StateManager interface {
	StateReader
	StateWriter
}

A StateManager can read and write state

type StateManagerController added in v1.0.1

type StateManagerController struct {
	*spies.Spy
}

StateManagerController is the controller for a spy implementation of StateManager.

type StateManagerSpy added in v1.0.1

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

StateManagerSpy is a spy implementation of StateManager.

func (StateManagerSpy) ReadState added in v1.0.1

func (spy StateManagerSpy) ReadState() (*State, error)

ReadState implements StateManager on StateManagerSpy.

func (StateManagerSpy) WriteState added in v1.0.1

func (spy StateManagerSpy) WriteState(s *State, u User) error

WriteState implements StateManager on StateManagerSpy.

type StateReader added in v0.0.3

type StateReader interface {
	ReadState() (*State, error)
}

StateReader knows how to read state.

type StateWriter added in v0.0.3

type StateWriter interface {
	WriteState(*State, User) error
}

StateWriter knows how to write state.

type StatusPoller added in v0.0.3

type StatusPoller struct {
	restful.HTTPClient
	*ResolveFilter
	User User
	// contains filtered or unexported fields
}

StatusPoller polls servers for status.

func NewStatusPoller added in v0.0.3

func NewStatusPoller(cl restful.HTTPClient, rf *ResolveFilter, user User, logs logging.LogSink) *StatusPoller

NewStatusPoller returns a new *StatusPoller.

func (*StatusPoller) Wait added in v1.0.1

func (sp *StatusPoller) Wait(ctx context.Context) (ResolveState, error)

Wait begins the process of polling for cluster statuses, waits for it to complete, and then returns the result, as long as the provided context is not cancelled.

type Strpair added in v0.0.3

type Strpair [2]string

Strpair is a pair of strings.

type Strpairs added in v0.0.3

type Strpairs []Strpair

Strpairs is a slice of Strpair.

type Tag

type Tag struct {
	Name, Revision string
}

Tag represents a revision control commit tag.

type TraceID added in v1.0.1

type TraceID string

A TraceID is the header to add to requests for tracing purposes.

func (TraceID) EachField added in v1.0.1

func (tid TraceID) EachField(fn logging.FieldReportFn)

EachField implements EachFielder on TraceID

type TriggerChannel added in v0.0.3

type TriggerChannel chan TriggerType

TriggerChannel is a channel of TriggerType.

type TriggerType added in v0.0.3

type TriggerType struct{}

TriggerType is an empty struct, representing some kind of trigger.

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 User added in v1.0.1

type User struct {
	// Name is the full name of this user.
	Name string `env:"SOUS_USER_NAME"`
	// Email is the email address of this user.
	Email string `env:"SOUS_USER_EMAIL"`
}

User represents a user of the Sous client.

func (User) Complete added in v1.0.1

func (u User) Complete() bool

Complete returns true only if both Name and Email have a non-empty value

func (User) HTTPHeaders added in v1.0.1

func (u User) HTTPHeaders() map[string]string

HTTPHeaders returns a map suitable to use as HTTP headers to be consumed by the server.

func (User) String added in v1.0.1

func (u User) String() string

String returns the name and email in standard email address format, i.e.:

User Name <email@address.com>

This is used directly by git commit --author, and is reasonable in logs etc.

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) Clone added in v0.0.3

func (vs Volumes) Clone() Volumes

Clone returns a deep copy of this Volumes.

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

Jump to

Keyboard shortcuts

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