sous

package
v0.0.3-prerelease3 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2017 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 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`)
)
View Source
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 = "worker"
	// ManifestKindOnDemand represents an on-demand service.
	ManifestKindOnDemand = "on-demand"
	// ManifestKindScheduled represents a scheduled task.
	ManifestKindScheduled = "scheduled"
	// ManifestKindOnce represents a one-off job.
	ManifestKindOnce = "once"
	// ScheduledJob represents a process which starts on some schedule, and
	// exits when it completes its task.
	ScheduledJob = "scheduled-job"
)
View Source
const DefaultDelim = ","

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

View Source
const FlavorSeparator = "~"

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

Variables

View Source
var (
	// Log collects various loggers to use for different levels of logging
	Log = func() LogSet {
		return *(NewLogSet(os.Stderr, ioutil.Discard, ioutil.Discard))
	}()
)

Functions

func DumpDeployments

func DumpDeployments(io io.Writer, ds Deployments)

func SetupLogging

func SetupLogging(il ILogger)

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

func TabbedDeploymentHeaders

func TabbedDeploymentHeaders() string

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

Types

type Advisories

type Advisories []AdvisoryName

Advisories are the advisory tokens that apply to a build

type AdvisoryName

type AdvisoryName string

An AdvisoryName is the type for advisory tokens.

type Annotation

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

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

type AutoResolver added in v0.0.3

type AutoResolver struct {
	UpdateTime time.Duration
	StateReader
	*Resolver
	*LogSet

	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 *LogSet) *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 {
	Name, Type string
	Qualities  []Quality
}

BuildArtifact describes the actual built binary Sous will deploy

func GuardImage added in v0.0.3

func GuardImage(r Registry, d *Deployment) (art *BuildArtifact, err error)

GuardImage checks that a deployment is valid before deploying it

func NewBuildArtifact added in v0.0.3

func NewBuildArtifact(imageName string, qstrs Strpairs) *BuildArtifact

NewBuildArtifact creates a new BuildArtifact representing a Docker image.

type BuildConfig

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

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

func (*BuildConfig) Advisories

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

Advisories returns a list of advisories that apply to ctx.

func (*BuildConfig) GuardRegister

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

GuardRegister returns an error if any development-only advisories exist

func (*BuildConfig) GuardStrict

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

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

func (*BuildConfig) NewContext

func (c *BuildConfig) NewContext() *BuildContext

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

func (*BuildConfig) 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 []string
}

BuildContext contains all the data required to perform a build.

func (*BuildContext) Version

func (bc *BuildContext) Version() SourceID

Version returns the SourceID for this build

type BuildManager

type BuildManager struct {
	BuildConfig *BuildConfig
	Selector
	Labeller
	Registrar
}

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

func (*BuildManager) Build

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

Build implements sous.Builder.Build

func (*BuildManager) OffsetFromWorkdir added in v0.0.3

func (m *BuildManager) OffsetFromWorkdir(workdir, 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, bc *BuildContext) error

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

type BuildResult

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

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

func (*BuildResult) String

func (br *BuildResult) String() string

type Buildpack

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

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

type ChangeError

type ChangeError struct {
	Deployments *DeploymentPair
	Err         error
}

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

func (*ChangeError) Error

func (e *ChangeError) Error() string

func (*ChangeError) ExistingDeployment

func (e *ChangeError) ExistingDeployment() *Deployment

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

func (*ChangeError) IntendedDeployment

func (e *ChangeError) IntendedDeployment() *Deployment

IntendedDeployment returns the deployment that was intended in a ChangeError

type Changes

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

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

type Cluster

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

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

func (Cluster) Clone added in v0.0.3

func (c Cluster) Clone() *Cluster

Clone returns a deep copy of this Cluster.

type Clusters

type Clusters map[string]*Cluster

Clusters is a collection of Cluster

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

type Comparable interface {
	// EmptyReceiver should return a pointer to an "zero value" for the recieving type.
	// For example:
	//   func (x *X) EmptyReceiver() { return &X{} }
	EmptyReceiver() Comparable

	// VariancesFrom returns a list of differences from another Comparable.
	// If the two structs are equivalent, it should return an empty list.
	// Usually, the first check will be for identical type, and return "types differ."
	VariancesFrom(Comparable) Variances
}

Comparable is a required interface for Update and Delete, which provides the mechanism for comparing the remote resource to the local data.

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.

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.
	Args []string `yaml:",omitempty" validate:"values=nonempty"`
	Env  `yaml:",omitempty" validate:"keys=nonempty,values=nonempty"`
	// NumInstances is a guide to the number of instances that should be
	// deployed in this cluster, note that the actual number may differ due
	// to decisions made by Sous. If set to zero, Sous will decide how many
	// instances to launch.
	NumInstances int

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

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

func (DeployConfig) Clone added in v0.0.3

func (dc DeployConfig) Clone() (c 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 DeployID

type DeployID struct {
	ManifestID ManifestID
	Cluster    string
}

A DeployID identifies a deployment.

type DeploySpec

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

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

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

func (DeploySpec) 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) 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.

type Deployable added in v0.0.3

type Deployable struct {
	*Deployment
	*BuildArtifact
}

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

type DeployableChans added in v0.0.3

type DeployableChans struct {
	Start, Stop, Stable chan *Deployable
	Update              chan *DeployablePair
	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) ResolveNames added in v0.0.3

func (dc *DeployableChans) ResolveNames(r Registry, diff *DiffChans, errs chan error)

ResolveNames resolves diffs.

type DeployablePair added in v0.0.3

type DeployablePair struct {
	Prior, Post *Deployable
	// 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) ID added in v0.0.3

func (dp *DeployablePair) ID() DeployID

ID returns the ID of this DeployablePair.

type Deployer

type Deployer interface {
	RunningDeployments(reg Registry, from Clusters) (Deployments, error)
	RectifyCreates(<-chan *Deployable, chan<- DiffResolution)
	RectifyDeletes(<-chan *Deployable, chan<- DiffResolution)
	RectifyModifies(<-chan *DeployablePair, chan<- DiffResolution)
}

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

type Deployment

type Deployment struct {
	// DeployConfig contains configuration info for this deployment,
	// including environment variables, resources, suggested instance count.
	DeployConfig `yaml:"inline"`
	// ClusterNickname is the human name for a cluster - it's taken from the
	// hash key that defines the cluster and is used in manifests to configure
	// cluster-local deployment config.
	ClusterName string
	// Cluster is the name of the cluster this deployment belongs to. Upon
	// parsing the Manifest, this will be set to the key in
	// Manifests.Deployments which points at this Deployment.
	Cluster *Cluster
	// SourceID is the precise version of the software to be deployed.
	SourceID SourceID
	// 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

	// Volumes enumerates the volume mappings required.
	Volumes Volumes

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

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

func BuildDeployment

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

BuildDeployment constructs a deployment out of a Manifest.

func (Deployment) Clone added in v0.0.3

func (d Deployment) Clone() *Deployment

Clone returns a deep copy of this deployment.

func (*Deployment) Diff added in v0.0.3

func (d *Deployment) Diff(o *Deployment) (bool, []string)

Diff returns the differences between this deployment and another.

func (*Deployment) Equal

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

Equal returns true if two Deployments are equal.

func (*Deployment) ID

func (d *Deployment) ID() DeployID

ID returns the DeployID of this deployment.

func (*Deployment) 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() DeployID

Name returns the DeployID.

func (*Deployment) String

func (d *Deployment) String() string

func (*Deployment) Tabbed

func (d *Deployment) Tabbed() string

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

type DeploymentPair

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

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

func (*DeploymentPair) ID added in v0.0.3

func (dp *DeploymentPair) ID() DeployID

ID returns the DeployID of this deployment pair.

type DeploymentPairs

type DeploymentPairs []*DeploymentPair

DeploymentPairs is a list of DeploymentPair

type DeploymentPredicate

type DeploymentPredicate func(*Deployment) bool

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

type Deployments

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

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

func MakeDeployments

func MakeDeployments(capacity int) Deployments

MakeDeployments creates a new Deployments with capacity set.

func NewDeployments

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

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

func NewDeploymentsFromMap

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

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

func (Deployments) Add

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

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

func (Deployments) AddAll

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

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

func (Deployments) Any

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

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

func (Deployments) Clone

func (m Deployments) Clone() Deployments

Clone returns a pairwise copy of Deployments.

func (Deployments) Diff

func (d Deployments) Diff(other Deployments) DiffChans

Diff computes the differences between two sets of Deployments

func (Deployments) Filter

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

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

func (Deployments) FilteredSnapshot

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

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

func (Deployments) Get

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

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

func (Deployments) GetAll

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

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

func (Deployments) Keys

func (m Deployments) Keys() []DeployID

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

func (Deployments) Len

func (m Deployments) Len() int

Len returns number of elements in a map.

func (Deployments) Manifests

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

Manifests creates manifests from deployments.

func (Deployments) Merge

func (m Deployments) Merge(other Deployments) Deployments

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

func (Deployments) MustAdd

func (m Deployments) MustAdd(v *Deployment)

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

func (*Deployments) 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) Remove

func (m Deployments) Remove(key DeployID)

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

func (Deployments) Set

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

Set sets the value of index k to v.

func (*Deployments) SetAll

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

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

func (Deployments) Single

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

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

func (Deployments) Snapshot

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

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

type DetectResult

type DetectResult struct {
	// Compatible 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 DiffChans

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

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

func NewDiffChans

func NewDiffChans(sizes ...int) DiffChans

NewDiffChans constructs a DiffChans

func (*DiffChans) Close

func (d *DiffChans) Close()

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

func (DiffChans) Concentrate added in v0.0.3

func (d DiffChans) Concentrate(defs Defs) DiffConcentrator

Concentrate returns a DiffConcentrator set up to concentrate the deployment changes in a DiffChans into manifest changes.

type DiffConcentrator added in v0.0.3

type DiffConcentrator struct {
	Defs
	Errors                     chan error
	Created, Deleted, Retained chan *Manifest
	Modified                   chan *ManifestPair
}

A DiffConcentrator wraps deployment DiffChans in order to produce differences in terms of *manifests*

func NewConcentrator added in v0.0.3

func NewConcentrator(defs Defs, s DiffChans, sizes ...int) DiffConcentrator

NewConcentrator constructs a DiffConcentrator.

type DiffResolution added in v0.0.3

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

DiffResolution is the result of applying a single diff.

type DummyDeployer added in v0.0.3

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

DummyDeployer is a noop deployer.

func NewDummyDeployer added in v0.0.3

func NewDummyDeployer() *DummyDeployer

NewDummyDeployer creates a DummyDeployer

func (*DummyDeployer) RectifyCreates added in v0.0.3

func (dd *DummyDeployer) RectifyCreates(<-chan *Deployable, chan<- DiffResolution)

RectifyCreates implements Deployer

func (*DummyDeployer) RectifyDeletes added in v0.0.3

func (dd *DummyDeployer) RectifyDeletes(<-chan *Deployable, chan<- DiffResolution)

RectifyDeletes implements Deployer

func (*DummyDeployer) RectifyModifies added in v0.0.3

func (dd *DummyDeployer) RectifyModifies(<-chan *DeployablePair, chan<- DiffResolution)

RectifyModifies implements Deployer

func (*DummyDeployer) RunningDeployments added in v0.0.3

func (dd *DummyDeployer) RunningDeployments(reg Registry, from Clusters) (Deployments, error)

RunningDeployments implements Deployer

type DummyRectificationClient added in v0.0.3

type DummyRectificationClient struct {
	Created  []dummyRequest
	Deployed []dummyDeploy
	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 (t *DummyRectificationClient) DeleteRequest(
	cluster, reqid, message string) error

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

func (*DummyRectificationClient) Deploy added in v0.0.3

func (t *DummyRectificationClient) Deploy(
	cluster, depID, reqID, imageName string, res Resources, e Env, vols Volumes) error

Deploy implements part of the RectificationClient interface

func (*DummyRectificationClient) PostRequest added in v0.0.3

func (t *DummyRectificationClient) PostRequest(
	cluster, id string, count int,
	kind ManifestKind,
	owners OwnerSet,
) error

PostRequest (cluster, request id, instance count)

func (*DummyRectificationClient) SetLogger added in v0.0.3

func (t *DummyRectificationClient) SetLogger(l *log.Logger)

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
}

DummyStateManager is used 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) 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 EchoSelector

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

EchoSelector wraps a buildpack Factory. But why?

func (*EchoSelector) SelectBuildpack

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

SelectBuildpack tries to select a buildpack for this BuildContext.

type Env

type Env map[string]string

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

func (Env) Equal

func (e Env) Equal(o Env) bool

Equal compares Envs

type EnvDef

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

EnvDef is an environment variable definition.

type EnvDefaults

type EnvDefaults map[string]Var

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

type EnvDefs

type EnvDefs []EnvDef

EnvDefs is a collection of EnvDef

func (EnvDefs) Clone added in v0.0.3

func (evs EnvDefs) Clone() EnvDefs

Clone returns a deep copy of this EnvDefs.

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.

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.

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

type HTTPClient struct {
	http.Client
	// contains filtered or unexported fields
}

HTTPClient interacts with a Sous http server.

It's designed to handle basic CRUD operations in a safe and restful way.

func NewClient added in v0.0.3

func NewClient(serverURL string) (*HTTPClient, error)

NewClient returns a new HTTPClient for a particular serverURL.

func (*HTTPClient) Create added in v0.0.3

func (client *HTTPClient) Create(urlPath string, qParms map[string]string, qBody interface{}) error

Create uses the contents of qBody to create a new resource at the server at urlPath/qParms It issues a PUT with "If-No-Match: *", so if a resource already exists, it'll return an error.

func (*HTTPClient) Delete added in v0.0.3

func (client *HTTPClient) Delete(urlPath string, qParms map[string]string, from Comparable) error

Delete removes a resource from the server, granted that we know the resource that we're removing. It functions similarly to Update, but issues DELETE requests.

func (*HTTPClient) Retrieve added in v0.0.3

func (client *HTTPClient) Retrieve(urlPath string, qParms map[string]string, rzBody interface{}) error

Retrieve makes a GET request on urlPath, after transforming qParms into ?&= style query params. It deserializes the returned JSON into rzBody. Errors are returned if anything goes wrong, including a non-Success HTTP result (but note that there may be a response anyway.

func (*HTTPClient) Update added in v0.0.3

func (client *HTTPClient) Update(urlPath string, qParms map[string]string, from, qBody Comparable) error

Update changes the representation of a given resource. It compares the known value to from, and rejects if they're different (on the grounds that the client is going to clobber a value it doesn't know about.) Then it issues a PUT with "If-Match: <etag of from>" so that the server can check that we're changing from a known value.

type HTTPNameInserter added in v0.0.3

type HTTPNameInserter struct {
	http.Client
	// contains filtered or unexported fields
}

An HTTPNameInserter sends its inserts to the configured HTTP server

func NewHTTPNameInserter added in v0.0.3

func NewHTTPNameInserter(server string) (*HTTPNameInserter, error)

NewHTTPNameInserter creates a new HTTPNameInserter

func (*HTTPNameInserter) Insert added in v0.0.3

func (hni *HTTPNameInserter) Insert(sid SourceID, in, etag string, qs []Quality) error

Insert implements Inserter for HTTPNameInserter

type HTTPStateManager added in v0.0.3

type HTTPStateManager struct {
	*HTTPClient
	// 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 *HTTPClient) *HTTPStateManager

NewHTTPStateManager creates a new HTTPStateManager.

func (*HTTPStateManager) ReadState added in v0.0.3

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

ReadState implements StateReader for HTTPStateManager.

func (*HTTPStateManager) WriteState added in v0.0.3

func (hsm *HTTPStateManager) WriteState(s *State) error

WriteState implements StateWriter for HTTPStateManager.

type ILogger

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

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

type IncludesVersion

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

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

func (*IncludesVersion) Error

func (err *IncludesVersion) Error() string

type Inserter added in v0.0.3

type Inserter interface {
	// Insert pairs a SourceID with an imagename, and tags the pairing with Qualities
	// The etag can be (usually will be) the empty string
	Insert(sid SourceID, in, etag string, qs []Quality) error
}

An Inserter puts data into a registry.

type Labeller

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

Labeller defines a container-based build system.

type LogSet

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

LogSet is the stopgap for a decent injectable logger

func NewLogSet added in v0.0.3

func NewLogSet(warn, debug, vomit io.Writer) *LogSet

NewLogSet builds a new Logset that feeds to the listed writers

func SilentLogSet added in v0.0.3

func SilentLogSet() *LogSet

SilentLogSet returns a logset that discards everything by default

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 (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() 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 Comparable) (vs 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 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) 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) 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 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.

func (ManifestKind) Validate added in v0.0.3

func (mk ManifestKind) Validate() []Flaw

Validate returns a list of flaws with this ManifestKind.

type ManifestPair added in v0.0.3

type ManifestPair struct {
	Prior, Post *Manifest
	// contains filtered or unexported fields
}

ManifestPair is a pair of manifests.

type ManifestPairs added in v0.0.3

type ManifestPairs []*ManifestPair

ManifestPairs is a slice of *ManifestPair.

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

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

func (e 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
}

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)

func (OwnerSet) Equal

func (os OwnerSet) Equal(o OwnerSet) bool

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

func (OwnerSet) Remove

func (os OwnerSet) Remove(owner string)

Remove removes an owner from an ownerset.

func (OwnerSet) Slice added in v0.0.3

func (os OwnerSet) Slice() []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 ReadDebugger added in v0.0.3

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

ReadDebugger wraps a ReadCloser and logs the data as it buffers past.

func NewReadDebugger added in v0.0.3

func NewReadDebugger(rc io.ReadCloser, log func([]byte, int, error)) *ReadDebugger

NewReadDebugger creates a new ReadDebugger that wraps a ReadCloser.

func (*ReadDebugger) Close added in v0.0.3

func (rd *ReadDebugger) Close() error

Close implements Closer on ReadDebugger.

func (*ReadDebugger) Read added in v0.0.3

func (rd *ReadDebugger) Read(p []byte) (int, error)

Read implements Reader on ReadDebugger.

type RectificationError

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

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

type Registrar

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

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

type Registry

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

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

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

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

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

type RegistryDumper

type RegistryDumper struct {
	Registry
}

RegistryDumper dumps the contents of artifact registries

func NewRegistryDumper

func NewRegistryDumper(r Registry) *RegistryDumper

NewRegistryDumper constructs a RegistryDumper

func (*RegistryDumper) AsTable

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

AsTable writes a tabular dump of the registry to a Writer

func (*RegistryDumper) Entries

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

Entries emits the list of entries for the Resgistry

func (*RegistryDumper) TabbedHeaders

func (rd *RegistryDumper) TabbedHeaders() string

TabbedHeaders outputs the headers for the dump

type ResolveErrors

type ResolveErrors struct {
	Causes []error
}

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

func (*ResolveErrors) Error

func (re *ResolveErrors) Error() string

type ResolveFilter added in v0.0.3

type ResolveFilter struct {
	Repo     string
	Offset   string
	Tag      string
	Revision string
	Flavor   string
	Cluster  string
}

A ResolveFilter filters Deployments 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) 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) 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) String added in v0.0.3

func (rf *ResolveFilter) String() string

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(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
	// ResolvedNotVersion 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
	// ResolveErred conveys that the resolution returned an error. This might be transient.
	ResolveErred
	// ResolveComplete is the success state: the server knows about our intended
	// deployment, and that deployment has returned as having been stable.
	ResolveComplete
)

func (ResolveState) String added in v0.0.3

func (rs ResolveState) String() string

type ResolveStatus added in v0.0.3

type ResolveStatus struct {
	// Phase reports the current phase of resolution
	Phase string
	// 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
}

Resolver is responsible for resolving intended and actual deployment states.

func NewResolver

func NewResolver(d Deployer, r Registry, rf *ResolveFilter) *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 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
	NearestTagName, NearestTagRevision   string
	PrimaryRemoteURL                     string
	RemoteURL                            string
	RemoteURLs                           []string
	DirtyWorkingTree                     bool
	RevisionUnpushed                     bool
}

SourceContext contains contextual information about the source code being built.

func (*SourceContext) AbsDir

func (sc *SourceContext) AbsDir() string

AbsDir returns the absolute path of this source code.

func (*SourceContext) SourceLocation

func (sc *SourceContext) SourceLocation() SourceLocation

SourceLocation returns the source location in this context.

func (*SourceContext) Version

func (sc *SourceContext) Version() SourceID

Version returns the SourceID.

type 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 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.

func ParseSourceID

func ParseSourceID(s string) (SourceID, error)

ParseSourceID parses an entire SourceID.

func (SourceID) Equal

func (sid SourceID) Equal(o SourceID) bool

Equal tests the equality between this SourceID and another.

func (SourceID) QueryValues added in v0.0.3

func (sid SourceID) QueryValues() url.Values

QueryValues returns the url.Values for this SourceIDs

func (SourceID) RevID

func (sid SourceID) RevID() string

RevID returns the revision id for this SourceID.

func (SourceID) String

func (sid SourceID) String() string

func (SourceID) Tag

func (sid SourceID) Tag() string

Tag returns the version tag for this source ID.

type SourceLocation

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

	Dir string
}

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

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

MarshalText implements encoding.TextMarshaler.

func (SourceLocation) MarshalYAML

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

MarshalYAML serializes this SourceLocation to a YAML document.

func (SourceLocation) SourceID

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

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

func (SourceLocation) String

func (sl SourceLocation) String() string

func (*SourceLocation) UnmarshalText

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

UnmarshalText implements encoding.TextMarshaler.

func (*SourceLocation) UnmarshalYAML

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

UnmarshalYAML deserializes a YAML document into this SourceLocation

type State

type State struct {
	// Defs contains global definitions for this organisation.
	Defs Defs `hy:"defs"`
	// Manifests contains a mapping of source code repositories to global
	// deployment configurations for artifacts built using that source code.
	Manifests Manifests `hy:"manifests/"`
}

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

func NewState

func NewState() *State

NewState returns a valid empty state.

func (*State) BaseURLs

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

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

func (State) 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) DeploymentsFromManifest

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

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

func (*State) Repair added in v0.0.3

func (s *State) Repair(fs []Flaw) error

Repair implements Flawed for State

func (*State) UpdateDeployments added in v0.0.3

func (s *State) UpdateDeployments(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 StateManager added in v0.0.3

type StateManager interface {
	StateReader
	StateWriter
}

A StateManager can read and write state

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

StateWriter knows how to write state.

type StatusPoller added in v0.0.3

type StatusPoller struct {
	*HTTPClient
	*ResolveFilter
}

StatusPoller polls servers for status.

func NewStatusPoller added in v0.0.3

func NewStatusPoller(cl *HTTPClient, rf *ResolveFilter) *StatusPoller

func (*StatusPoller) Start added in v0.0.3

func (sp *StatusPoller) Start() (ResolveState, error)

Start begins the process of polling for cluster statuses.

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

type Variances []string

Variances is a list of differences between two structs.

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