Documentation
¶
Index ¶
- Constants
- Variables
- func AcquireApplicationLock(appName string, owner string, reason string) (bool, error)
- func CreateApp(app *App, user *auth.User) error
- func Delete(app *App) error
- func Deploy(opts DeployOptions) error
- func Enqueue(msgs ...queue.Message)
- func ListDeploys(s *service.Service) ([]deploy, error)
- func LogRemove(a *App) error
- func PlatformAdd(name string, args map[string]string, w io.Writer) error
- func PlatformUpdate(name string, args map[string]string, w io.Writer) error
- func ReleaseApplicationLock(appName string)
- func Swap(app1, app2 *App) error
- type App
- func (app *App) AddUnits(n uint) error
- func (app *App) AddUnitsToDB(units []provision.Unit) error
- func (app *App) Available() bool
- func (app *App) Envs() map[string]bind.EnvVar
- func (app *App) GetDeploys() uint
- func (app *App) GetIp() string
- func (app *App) GetMemory() int
- func (app *App) GetName() string
- func (app *App) GetPlatform() string
- func (app *App) GetSwap() int
- func (app *App) GetTeams() []auth.Team
- func (app *App) GetUnits() []bind.Unit
- func (app *App) GetUpdatePlatform() bool
- func (app *App) Grant(team *auth.Team) error
- func (app *App) InstanceEnv(name string) map[string]bind.EnvVar
- func (app *App) LastLogs(lines int, filterLog Applog) ([]Applog, error)
- func (app *App) ListDeploys() ([]deploy, error)
- func (app *App) Log(message, source, unit string) error
- func (app *App) MarshalJSON() ([]byte, error)
- func (app *App) Ready() error
- func (app *App) RemoveUnits(n uint) error
- func (app *App) Restart(w io.Writer) error
- func (app *App) Revoke(team *auth.Team) error
- func (app *App) Run(cmd string, w io.Writer, once bool) error
- func (app *App) SerializeEnvVars() error
- func (app *App) SetCName(cname string) error
- func (app *App) SetEnvs(envs []bind.EnvVar, publicOnly bool) error
- func (app *App) SetTeams(teams []auth.Team)
- func (app *App) SetUpdatePlatform(check bool) error
- func (app *App) Start(w io.Writer) error
- func (app *App) Stop(w io.Writer) error
- func (app *App) Units() []provision.Unit
- func (app *App) UnsetCName() error
- func (app *App) UnsetEnvs(variableNames []string, publicOnly bool) error
- type AppCreationError
- type AppLock
- type Applog
- type DeployOptions
- type DuplicatePlatformError
- type InvalidPlatformError
- type LogListener
- type LogWriter
- type Logger
- type ManyTeamsError
- type NoTeamsError
- type Platform
Constants ¶
const (
BindService = "bind-service"
)
const (
InternalAppName = "tsr"
)
Variables ¶
var ( ErrAppAlreadyExists = errors.New("there is already an app with this name.") ErrAppNotFound = errors.New("App not found") )
var AuthScheme auth.Scheme
var IncrementDeploy = action.Action{ Name: "increment-deploy", Forward: func(ctx action.FWContext) (action.Result, error) { opts, ok := ctx.Params[0].(DeployOptions) if !ok { return nil, errors.New("First parameter must be DeployOptions") } err := incrementDeploy(opts.App) return nil, err }, Backward: func(ctx action.BWContext) { }, MinParams: 1, }
Increment is an actions that increments the deploy number.
var Provisioner provision.Provisioner
var ProvisionerDeploy = action.Action{ Name: "provisioner-deploy", Forward: func(ctx action.FWContext) (action.Result, error) { opts, ok := ctx.Params[0].(DeployOptions) if !ok { return nil, errors.New("First parameter must be DeployOptions") } writer, ok := ctx.Params[1].(io.Writer) if !ok { return nil, errors.New("Second parameter must be an io.Writer") } if opts.ArchiveURL != "" { if deployer, ok := Provisioner.(provision.ArchiveDeployer); ok { return nil, deployer.ArchiveDeploy(opts.App, opts.ArchiveURL, writer) } } err := Provisioner.(provision.GitDeployer).GitDeploy(opts.App, opts.Version, writer) return nil, err }, Backward: func(ctx action.BWContext) { }, MinParams: 2, }
ProvisionerDeploy is an actions that call the Provisioner.Deploy.
var UnsupportedPubSubErr = fmt.Errorf("Your queue backend doesn't support pubsub required for log streaming. Using redis as queue is recommended.")
Functions ¶
func AcquireApplicationLock ¶
Acquire an application lock by setting the lock field in the database. This method is already called by a connection middleware on requests with :app or :appname params that have side-effects.
func CreateApp ¶
CreateApp creates a new app.
Creating a new app is a process composed of four steps:
- Save the app in the database
- Create IAM credentials for the app
- Create the git repository using gandalf
- Provision units within the provisioner
func Delete ¶
Delete deletes an app.
Delete an app is a process composed of three steps:
- Destroy the app unit
- Unbind all service instances from the app
- Remove the app from the database
func Deploy ¶
func Deploy(opts DeployOptions) error
Deploy runs a deployment of an application. It will first try to run an archive based deploy (if opts.ArchiveURL is not empty), and then fallback to the Git based deployment.
func Enqueue ¶
Enqueue puts the given message in the queue. The app queue is able to handle only messages defined in this package.
Here is a functional example for this function:
msg := queue.Message{Action: app.regenerateApprc, Args: []string{"myapp"}} app.Enqueue(msg)
func ListDeploys ¶
func PlatformAdd ¶
PlatformAdd add a new platform to tsuru
func ReleaseApplicationLock ¶
func ReleaseApplicationLock(appName string)
Releases a lock hold on an app, currently it's called by a middleware, however, ideally, it should be called individually by each handler since they might be doing operations in background.
Types ¶
type App ¶
type App struct { Env map[string]bind.EnvVar Platform string `bson:"framework"` Name string Ip string CName string Teams []string TeamOwner string Owner string State string Deploys uint Memory int `json:",string"` Swap int `json:",string"` UpdatePlatform bool Lock AppLock quota.Quota // contains filtered or unexported fields }
App is the main type in tsuru. An app represents a real world application. This struct holds information about the app: its name, address, list of teams that have access to it, used platform, etc.
func List ¶
List returns the list of apps that the given user has access to.
If the user does not have acces to any app, this function returns an empty list and a nil error.
func (*App) AddUnits ¶
AddUnits creates n new units within the provisioner, saves new units in the database and enqueues the apprc serialization.
func (*App) AddUnitsToDB ¶
Add provisioned units to database and enqueue messages to bind services and regenerate apprc. It's called as one of the steps started by AddUnits(). It doesn't call the provisioner.
func (*App) Available ¶
Available returns true if at least one of N units is started or unreachable.
func (*App) GetDeploys ¶
func (*App) GetPlatform ¶
GetPlatform returns the platform of the app.
func (*App) GetUpdatePlatform ¶
func (*App) Grant ¶
Grant allows a team to have access to an app. It returns an error if the team already have access to the app.
func (*App) InstanceEnv ¶
InstanceEnv returns a map of environment variables that belongs to the given service instance (identified by the name only).
TODO(fss): this method should not be exported.
func (*App) LastLogs ¶
LastLogs returns a list of the last `lines` log of the app, matching the fields in the log instance received as an example.
func (*App) ListDeploys ¶
func (*App) Log ¶
Log adds a log message to the app. Specifying a good source is good so the user can filter where the message come from.
func (*App) MarshalJSON ¶
MarshalJSON marshals the app in json format. It returns a JSON object with the following keys: name, framework, teams, units, repository and ip.
func (*App) RemoveUnits ¶
RemoveUnits removes n units from the app. It's a process composed of x steps:
- Remove units from the provisioner
- Remove units from the app list
- Update quota
func (*App) Revoke ¶
Revoke removes the access from a team. It returns an error if the team do not have access to the app.
func (*App) SerializeEnvVars ¶
SerializeEnvVars serializes the environment variables of the app. The environment variables will be written the the file /home/application/apprc in all units of the app.
func (*App) SetCName ¶
SetCName defines the CName of the app. It updates the attribute, calls the SetCName function on the provisioner and saves the app in the database, returning an error when it cannot save the change in the database or set the CName on the provisioner.
func (*App) SetEnvs ¶
SetEnvs saves a list of environment variables in the app. The publicOnly parameter indicates whether only public variables can be overridden (if set to false, SetEnvs may override a private variable).
func (*App) SetTeams ¶
SetTeams sets the values of the internal te
TODO(fss): this method should not be exported.
func (*App) SetUpdatePlatform ¶
func (*App) Start ¶
Start starts the app calling the provisioner.Start method and changing the units state to StatusStarted.
func (*App) UnsetCName ¶
func (*App) UnsetEnvs ¶
UnsetEnvs removes environment variables from an app, serializing the remaining list of environment variables to all units of the app.
Besides the slice with the name of the variables, this method also takes the parameter publicOnly, which indicates whether only public variables can be overridden (if set to false, setEnvsToApp may override a private variable).
type AppCreationError ¶
type AppCreationError struct { Err error // contains filtered or unexported fields }
func (*AppCreationError) Error ¶
func (e *AppCreationError) Error() string
type DeployOptions ¶
type DuplicatePlatformError ¶
type DuplicatePlatformError struct{}
func (DuplicatePlatformError) Error ¶
func (DuplicatePlatformError) Error() string
type InvalidPlatformError ¶
type InvalidPlatformError struct{}
func (InvalidPlatformError) Error ¶
func (InvalidPlatformError) Error() string
type LogListener ¶
type LogListener struct { C <-chan Applog // contains filtered or unexported fields }
func NewLogListener ¶
func NewLogListener(a *App, filterLog Applog) (*LogListener, error)
func (*LogListener) Close ¶
func (l *LogListener) Close() (err error)
type ManyTeamsError ¶
type ManyTeamsError struct{}
ManyTeamsError is the error returned when the user has more than one team and tries to create an app without specify a app team owner.
func (ManyTeamsError) Error ¶
func (err ManyTeamsError) Error() string
type NoTeamsError ¶
type NoTeamsError struct{}
NoTeamsError is the error returned when one tries to create an app without any team.
func (NoTeamsError) Error ¶
func (err NoTeamsError) Error() string