Documentation ¶
Overview ¶
Package provision provides interfaces that need to be satisfied in order to implement a new provisioner on tsuru.
Index ¶
- Constants
- Variables
- func AddPool(opts AddPoolOptions) error
- func AddTeamsToPool(poolName string, teams []string) error
- func GetPoolsNames(pools []Pool) []string
- func PoolUpdate(poolName string, query bson.M, forceDefault bool) error
- func Register(name string, p Provisioner)
- func RemovePool(poolName string) error
- func RemoveTeamsFromPool(poolName string, teams []string) error
- type AddPoolOptions
- type App
- type ArchiveDeployer
- type CNameManager
- type Error
- type ExtensibleProvisioner
- type GitDeployer
- type ImageDeployer
- type InitializableProvisioner
- type InvalidProcessError
- type MessageProvisioner
- type Named
- type PlatformOptions
- type Pool
- type Provisioner
- type ShellOptions
- type Status
- type TsuruYamlData
- type TsuruYamlHealthcheck
- type TsuruYamlHooks
- type TsuruYamlRestartHooks
- type Unit
- type UnitNotFoundError
- type UploadDeployer
Constants ¶
const ( // StatusCreated is the initial status of a unit in the database, // it should transition shortly to a more specific status StatusCreated = Status("created") // StatusBuilding is the status for units being provisioned 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") // StatusStarting is set when the container is started in docker. StatusStarting = Status("starting") // StatusStarted is for cases where the unit is up and running, and bound // to the proper status, it's set by RegisterUnit and SetUnitStatus. StatusStarted = Status("started") // StatusStopped is for cases where the unit has been stopped. StatusStopped = Status("stopped") )
Flow:
+----------+ Start +---------+ | Building | +---------------------+| Stopped | +----------+ | +---------+
^ | ^ | | | deploy unit | Stop | | | + v RegisterUnit + +---------+ app unit +----------+ SetUnitStatus +---------+ | Created | +---------> | Starting | +-------------> | Started | +---------+ +----------+ +---------+ + ^ + | | | SetUnitStatus | | | | | v | | +-------+ SetUnitStatus | | | Error | +-------------------+ | +-------+ <---------------------+
Variables ¶
var ( ErrInvalidStatus = errors.New("invalid status") ErrEmptyApp = errors.New("no units for this app") )
var ErrDefaultPoolAlreadyExists = errors.New("Default pool already exists.")
var ErrPublicDefaultPollCantHaveTeams = errors.New("Public/Default pool can't have teams.")
Functions ¶
func AddPool ¶
func AddPool(opts AddPoolOptions) error
func AddTeamsToPool ¶
func GetPoolsNames ¶
GetPoolsNames find teams by a list of team names.
func Register ¶
func Register(name string, p Provisioner)
Register registers a new provisioner in the Provisioner registry.
func RemovePool ¶
func RemoveTeamsFromPool ¶
Types ¶
type AddPoolOptions ¶
type App ¶
type App interface { Named BindUnit(*Unit) error UnbindUnit(*Unit) error // 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, error) // 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 Envs() map[string]bind.EnvVar GetMemory() int64 GetSwap() int64 GetUpdatePlatform() bool GetRouter() (string, error) GetPool() string GetTeamOwner() string GetTeamsName() []string GetQuota() quota.Quota SetQuotaInUse(int) error }
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) (string, 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 ExtensibleProvisioner ¶
type ExtensibleProvisioner interface { PlatformAdd(PlatformOptions) error PlatformUpdate(PlatformOptions) error PlatformRemove(name string) error }
ExtensibleProvisioner is a provisioner where administrators can manage platforms (automatically adding, removing and updating platforms).
type GitDeployer ¶
GitDeployer is a provisioner that can deploy the application from a Git repository.
type ImageDeployer ¶
ImageDeployer is a provisioner that can deploy the application from a previously generated image.
type InitializableProvisioner ¶
type InitializableProvisioner interface {
Initialize() error
}
InitializableProvisioner is a provisioner that provides an initialization method that should be called when the app is started
type InvalidProcessError ¶
type InvalidProcessError struct {
Msg string
}
func (InvalidProcessError) Error ¶
func (e InvalidProcessError) Error() string
type MessageProvisioner ¶
type Named ¶
type Named interface {
GetName() string
}
Named is something that has a name, providing the GetName method.
type PlatformOptions ¶
PlatformOptions is the set of options provided to PlatformAdd and PlatformUpdate, in the ExtensibleProvisioner.
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, string, io.Writer) ([]Unit, error) // RemoveUnits "undoes" AddUnits, removing the given number of units // from the app. RemoveUnits(App, uint, string, io.Writer) 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 restarts the units of the application, with an optional // string parameter represeting the name of the process to start. When // the process is empty, Restart will restart all units of the // application. Restart(App, string, io.Writer) error // Start starts the units of the application, with an optional string // parameter represeting the name of the process to start. When the // process is empty, Start will start all units of the application. Start(App, string) error // Stop stops the units of the application, with an optional string // parameter represeting the name of the process to start. When the // process is empty, Stop will stop all units of the application. Stop(App, string) 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, error) // RoutableUnits returns information about routable units by App. RoutableUnits(App) ([]Unit, error) // Register a unit after the container has been created or restarted. RegisterUnit(Unit, map[string]interface{}) error // Open a remote shel in one of the units in the application. Shell(ShellOptions) error // Returns list of valid image names for app, these can be used for // rollback. ValidAppImages(string) ([]string, error) // Returns the metric backend environs for the app. MetricEnvs(App) map[string]string }
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.
type ShellOptions ¶
type ShellOptions struct { App App Conn io.ReadWriteCloser Width int Height int Unit string Term string }
ShellOptions is the set of options that can be used when calling the method Shell in the provisioner.
type Status ¶
type Status string
Status represents the status of a unit in tsuru.
func ParseStatus ¶
type TsuruYamlData ¶
type TsuruYamlData struct { Hooks TsuruYamlHooks Healthcheck TsuruYamlHealthcheck }
type TsuruYamlHealthcheck ¶
type TsuruYamlHooks ¶
type TsuruYamlHooks struct { Restart TsuruYamlRestartHooks Build []string }
type TsuruYamlRestartHooks ¶
type Unit ¶
type Unit struct { ID string Name string AppName string ProcessName string Type string Ip string Status Status Address *url.URL }
Unit represents a provision unit. Can be a machine, container or anything IP-addressable.
type UnitNotFoundError ¶
type UnitNotFoundError struct {
ID string
}
func (*UnitNotFoundError) Error ¶
func (e *UnitNotFoundError) Error() string
type UploadDeployer ¶
type UploadDeployer interface {
UploadDeploy(app App, file io.ReadCloser, w io.Writer) (string, error)
}
UploadDeployer is a provisioner that can deploy the application from an uploaded file.
Directories ¶
Path | Synopsis |
---|---|
Package docker provides a provisioner implementation that use Docker containers.
|
Package docker provides a provisioner implementation that use Docker containers. |