provision

package
v0.0.0-...-df9d84e Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2014 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package provision provides interfaces that need to be satisfied in order to implement a new provisioner on tsuru.

Index

Constants

View Source
const (
	// StatusBuilding is the status for units being provisined by the
	// provisioner, like in the deployment.
	StatusBuilding = Status("building")

	// StatusError is the status for units that failed to start, because of
	// an application error.
	StatusError = Status("error")

	// StatusDown is the status for units that failed to start, because of
	// some internal error on tsuru.
	StatusDown = Status("down")

	// StatusUnreachable is the case where the process is up and running,
	// but the unit is not reachable. Probably because it's not bound to
	// the right host ("0.0.0.0") and/or right port ($PORT).
	StatusUnreachable = Status("unreachable")

	// StatusStarted is for cases where the unit is up and running, and
	// bound to the proper status.
	StatusStarted = Status("started")

	// StatusStopped is for cases where the unit has been stopped.
	StatusStopped = Status("stopped")
)

Variables

View Source
var ErrEmptyApp = errors.New("no units for this app")
View Source
var ErrInvalidStatus = errors.New("invalid status")

Functions

func Register

func Register(name string, p Provisioner)

Register registers a new provisioner in the Provisioner registry.

Types

type App

type App interface {
	Named
	// Log should be used to log messages in the app.
	Log(message, source, unit string) error

	// GetPlatform returns the platform (type) of the app. It is equivalent
	// to the Unit `Type` field.
	GetPlatform() string

	// GetDeploy returns the deploys that an app has.
	GetDeploys() uint

	Units() []Unit

	// Run executes the command in app units. Commands executed with this
	// method should have access to environment variables defined in the
	// app.
	Run(cmd string, w io.Writer, once bool) error

	Restart(io.Writer) error

	Envs() map[string]bind.EnvVar

	// Ready marks the app as ready for deployment.
	Ready() error

	GetMemory() int
	GetSwap() int
	GetUpdatePlatform() bool
}

App represents a tsuru app.

It contains only relevant information for provisioning.

type ArchiveDeployer

type ArchiveDeployer interface {
	ArchiveDeploy(app App, archiveURL string, w io.Writer) error
}

ArchiveDeployer is a provisioner that can deploy archives.

type CNameManager

type CNameManager interface {
	SetCName(app App, cname string) error
	UnsetCName(app App, cname string) error
}

CNameManager represents a provisioner that supports cname on applications.

type CustomizedDeployPipelineProvisioner

type CustomizedDeployPipelineProvisioner interface {
	DeployPipeline() *action.Pipeline
}

CustomizedDeployPipelineProvisioner is a provisioner with a customized deploy pipeline.

type Error

type Error struct {
	Reason string
	Err    error
}

Error represents a provisioning error. It encapsulates further errors.

func (*Error) Error

func (e *Error) Error() string

Error is the string representation of a provisioning error.

type ExtensibleProvisioner

type ExtensibleProvisioner interface {
	PlatformAdd(name string, args map[string]string, w io.Writer) error
	PlatformUpdate(name string, args map[string]string, w io.Writer) error
	PlatformRemove(name string) error
}

ExtensibleProvisioner is a provisioner where administrators can manage platforms (automatically adding, removing and updating platforms).

type GitDeployer

type GitDeployer interface {
	GitDeploy(app App, version string, w io.Writer) error
}

GitDeployer is a provisioner that can deploy the application from a Git repository.

type Named

type Named interface {
	GetName() string
}

Named is something that has a name, providing the GetName method.

type Provisioner

type Provisioner interface {
	// Provision is called when tsuru is creating the app.
	Provision(App) error

	// Destroy is called when tsuru is destroying the app.
	Destroy(App) error

	// AddUnits adds units to an app. The first parameter is the app, the
	// second is the number of units to be added.
	//
	// It returns a slice containing all added units
	AddUnits(App, uint) ([]Unit, error)

	// RemoveUnits "undoes" AddUnits, removing the given number of units
	// from the app.
	RemoveUnits(App, uint) error

	// RemoveUnit removes a unit from the app. It receives the unit to be
	// removed.
	RemoveUnit(Unit) error

	// SetUnitStatus changes the status of a unit.
	SetUnitStatus(Unit, Status) error

	// ExecuteCommand runs a command in all units of the app.
	ExecuteCommand(stdout, stderr io.Writer, app App, cmd string, args ...string) error

	// ExecuteCommandOnce runs a command in one unit of the app.
	ExecuteCommandOnce(stdout, stderr io.Writer, app App, cmd string, args ...string) error

	Restart(App) error
	Stop(App) error

	// Start start the app units.
	Start(App) error

	// Addr returns the address for an app.
	//
	// tsuru will use this method to get the IP (although it might not be
	// an actual IP, collector calls it "IP") of the app from the
	// provisioner.
	Addr(App) (string, error)

	// Swap change the router between two apps.
	Swap(App, App) error

	// Units returns information about units by App.
	Units(App) []Unit
}

Provisioner is the basic interface of this package.

Any tsuru provisioner must implement this interface in order to provision tsuru apps.

func Get

func Get(name string) (Provisioner, error)

Get gets the named provisioner from the registry.

func Registry

func Registry() []Provisioner

Registry returns the list of registered provisioners.

type Status

type Status string

Status represents the status of a unit in tsuru.

func ParseStatus

func ParseStatus(status string) (Status, error)

func (Status) String

func (s Status) String() string

type Unit

type Unit struct {
	Name    string
	AppName string
	Type    string
	Ip      string
	Status  Status
}

Unit represents a provision unit. Can be a machine, container or anything IP-addressable.

func (*Unit) Available

func (u *Unit) Available() bool

Available returns true if the unit status is started or unreachable.

func (*Unit) GetIp

func (u *Unit) GetIp() string

GetIp returns the Unit.IP.

Directories

Path Synopsis
Package docker provides a provisioner implementation that use Docker containers.
Package docker provides a provisioner implementation that use Docker containers.

Jump to

Keyboard shortcuts

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