Documentation
¶
Index ¶
- Constants
- Variables
- func AcquireApplicationLock(appName string, owner string, reason string) (bool, error)
- func AcquireApplicationLockWait(appName string, owner string, reason string, timeout time.Duration) (bool, error)
- func AcquireApplicationLockWaitMany(appNames []string, owner string, reason string, timeout time.Duration) error
- func Build(opts DeployOptions) (string, error)
- func ChangeQuota(app *App, limit int) error
- func CreateApp(app *App, user *auth.User) error
- func Delete(app *App, evt *event.Event, requestID string) error
- func Deploy(opts DeployOptions) (string, error)
- func GetAppRouterUpdater() *appRouterUpdater
- func MigrateDeploysToEvents() error
- func PlanService() appTypes.PlanService
- func PlatformService() appTypes.PlatformService
- func ReleaseApplicationLock(appName string)
- func ReleaseApplicationLockMany(appNames []string)
- func RenameTeam(oldName, newName string) error
- func RollbackUpdate(appName, imageID, reason string, disableRollback bool) error
- func Swap(app1, app2 *App, cnameOnly bool) error
- func Units(apps []App) (map[string]AppUnitsResponse, error)
- func ValidateOrigin(origin string) bool
- type App
- func (app *App) AddCName(cnames ...string) error
- func (app *App) AddInstance(addArgs bind.AddInstanceArgs) error
- func (app *App) AddRouter(appRouter appTypes.AppRouter) error
- func (app *App) AddUnits(n uint, process string, w io.Writer) error
- func (app *App) BindUnit(unit *provision.Unit) error
- func (app *App) CleanImage(img string) error
- func (app *App) Envs() map[string]bind.EnvVar
- func (app *App) GetAddresses() ([]string, error)
- func (app *App) GetCertificates() (map[string]map[string]string, error)
- func (app *App) GetCname() []string
- func (app *App) GetCpuShare() int
- func (app *App) GetDeploys() uint
- func (app *App) GetHealthcheckData() (router.HealthcheckData, error)
- func (app *App) GetLock() provision.AppLock
- func (app *App) GetMemory() int64
- func (app *App) GetName() string
- func (app *App) GetPlatform() string
- func (app *App) GetPool() string
- func (app *App) GetQuota() quota.Quota
- func (app *App) GetRouters() []appTypes.AppRouter
- func (app *App) GetRoutersWithAddr() ([]appTypes.AppRouter, error)
- func (app *App) GetSwap() int64
- func (app *App) GetTeamOwner() string
- func (app *App) GetTeams() []authTypes.Team
- func (app *App) GetTeamsName() []string
- func (app *App) GetUnits() ([]bind.Unit, error)
- func (app *App) GetUpdatePlatform() bool
- func (app *App) Grant(team *authTypes.Team) error
- func (app *App) InstanceEnvs(serviceName, instanceName string) map[string]bind.EnvVar
- func (app *App) InternalLock(reason string) (bool, error)
- func (app *App) LastLogs(lines int, filterLog Applog) ([]Applog, error)
- func (app *App) Log(message, source, unit string) error
- func (app *App) MarshalJSON() ([]byte, error)
- func (app *App) MetricEnvs() (map[string]string, error)
- func (app *App) RegisterUnit(unitId string, customData map[string]interface{}) error
- func (app *App) RemoveCName(cnames ...string) error
- func (app *App) RemoveCertificate(name string) error
- func (app *App) RemoveInstance(removeArgs bind.RemoveInstanceArgs) error
- func (app *App) RemoveRouter(name string) error
- func (app *App) RemoveUnits(n uint, process string, w io.Writer) error
- func (app *App) Restart(process string, w io.Writer) error
- func (app *App) Revoke(team *authTypes.Team) error
- func (app *App) RoutableAddresses() ([]url.URL, error)
- func (app *App) Run(cmd string, w io.Writer, args provision.RunArgs) error
- func (app *App) SetCertificate(name, certificate, key string) error
- func (app *App) SetEnvs(setEnvs bind.SetEnvArgs) error
- func (app *App) SetPool() error
- func (app *App) SetQuotaInUse(inUse int) error
- func (app *App) SetUnitStatus(unitName string, status provision.Status) error
- func (app *App) SetUpdatePlatform(check bool) error
- func (app *App) Shell(opts provision.ShellOptions) error
- func (app *App) Sleep(w io.Writer, process string, proxyURL *url.URL) error
- func (app *App) Start(w io.Writer, process string) error
- func (app *App) Stop(w io.Writer, process string) error
- func (app *App) UnbindUnit(unit *provision.Unit) error
- func (app *App) Units() ([]provision.Unit, error)
- func (app *App) Unlock()
- func (app *App) UnsetEnvs(unsetEnvs bind.UnsetEnvArgs) error
- func (app *App) Update(updateData App, w io.Writer) (err error)
- func (app *App) UpdateRouter(appRouter appTypes.AppRouter) error
- func (app *App) ValidateService(service string) error
- type AppCreationError
- type AppLock
- type AppUnitsResponse
- type Applog
- type DeployData
- type DeployKind
- type DeployOptions
- type ErrAppNotLocked
- type Filter
- type LogDispatcher
- type LogListener
- type LogWriter
- type Logger
- type ManyTeamsError
- type NoTeamsError
- type ProcfileError
- type UpdateUnitsResult
Constants ¶
const ( // InternalAppName is a reserved name used for token generation. For // backward compatibility and historical purpose, the value remained // "tsr" when the name of the daemon changed to "tsurud". InternalAppName = "tsr" TsuruServicesEnvVar = "TSURU_SERVICES" )
Variables ¶
var ( ErrAppAlreadyExists = errors.New("there is already an app with this name") ErrAppNotFound = errors.New("App not found.") )
var ( ErrAlreadyHaveAccess = errors.New("team already have access to this app") ErrNoAccess = errors.New("team does not have access to this app") ErrCannotOrphanApp = errors.New("cannot revoke access from this team, as it's the unique team with access to the app") ErrDisabledPlatform = errors.New("Disabled Platform, only admin users can create applications with the platform") )
var AuthScheme auth.Scheme
Functions ¶
func AcquireApplicationLock ¶
AcquireApplicationLock acquires 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 AcquireApplicationLockWait ¶
func AcquireApplicationLockWait(appName string, owner string, reason string, timeout time.Duration) (bool, error)
Same as AcquireApplicationLock but it keeps trying to acquire the lock until timeout is reached.
func Build ¶
func Build(opts DeployOptions) (string, error)
func ChangeQuota ¶
ChangeQuota redefines the limit of the app. The new limit must be bigger than or equal to the current number of units in the app. The new limit may be smaller than 0, which means that the app should have an unlimited number of units.
func CreateApp ¶
CreateApp creates a new app.
Creating a new app is a process composed of the following steps:
- Save the app in the database
- Create the git repository using the repository manager
- Provision the app using the provisioner
func Deploy ¶
func Deploy(opts DeployOptions) (string, 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 GetAppRouterUpdater ¶
func GetAppRouterUpdater() *appRouterUpdater
func MigrateDeploysToEvents ¶
func MigrateDeploysToEvents() error
func PlanService ¶
func PlanService() appTypes.PlanService
func PlatformService ¶
func PlatformService() appTypes.PlatformService
func ReleaseApplicationLock ¶
func ReleaseApplicationLock(appName string)
ReleaseApplicationLock 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.
func ReleaseApplicationLockMany ¶
func ReleaseApplicationLockMany(appNames []string)
func RenameTeam ¶
func RollbackUpdate ¶
func ValidateOrigin ¶
Types ¶
type App ¶
type App struct { Env map[string]bind.EnvVar ServiceEnvs []bind.ServiceEnvVar Platform string `bson:"framework"` Name string CName []string Teams []string TeamOwner string Owner string Plan appTypes.Plan UpdatePlatform bool Lock AppLock Pool string Description string Router string RouterOpts map[string]string Deploys uint Tags []string Error string Routers []appTypes.AppRouter 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 (*App) AddCName ¶
AddCName adds a CName to 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 add the CName on the provisioner.
func (*App) AddInstance ¶
func (app *App) AddInstance(addArgs bind.AddInstanceArgs) 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) CleanImage ¶
func (*App) GetAddresses ¶
func (*App) GetCertificates ¶
func (*App) GetCpuShare ¶
GetCpuShare returns the cpu share for the app.
func (*App) GetDeploys ¶
GetDeploys returns the amount of deploys of an app.
func (*App) GetHealthcheckData ¶
func (app *App) GetHealthcheckData() (router.HealthcheckData, error)
func (*App) GetPlatform ¶
GetPlatform returns the platform of the app.
func (*App) GetRouters ¶
func (*App) GetTeamOwner ¶
GetTeamOwner returns the team owner of the app.
func (*App) GetTeamsName ¶
GetTeamsName returns the names of the app teams.
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) InstanceEnvs ¶
InstanceEnvs returns a map of environment variables that belongs to the given service and service instance.
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) 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.
func (*App) RegisterUnit ¶
func (*App) RemoveCName ¶
func (*App) RemoveCertificate ¶
func (*App) RemoveInstance ¶
func (app *App) RemoveInstance(removeArgs bind.RemoveInstanceArgs) error
func (*App) RemoveRouter ¶
func (*App) RemoveUnits ¶
RemoveUnits removes n units from the app. It's a process composed of multiple steps:
- Remove units from the provisioner
- 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) SetCertificate ¶
func (*App) SetEnvs ¶
func (app *App) SetEnvs(setEnvs bind.SetEnvArgs) error
SetEnvs saves a list of environment variables in the app.
func (*App) SetQuotaInUse ¶
func (*App) SetUnitStatus ¶
SetUnitStatus changes the status of the given unit.
func (*App) SetUpdatePlatform ¶
func (*App) Start ¶
Start starts the app calling the provisioner.Start method and changing the units state to StatusStarted.
func (*App) UnsetEnvs ¶
func (app *App) UnsetEnvs(unsetEnvs bind.UnsetEnvArgs) error
UnsetEnvs removes environment variables from an app, serializing the remaining list of environment variables to all units of the app.
func (*App) ValidateService ¶
type AppCreationError ¶
type AppCreationError struct { Err error // contains filtered or unexported fields }
func (*AppCreationError) Error ¶
func (e *AppCreationError) Error() string
type AppLock ¶
AppLock stores information about a lock hold on the app
func (*AppLock) GetAcquireDate ¶
func (*AppLock) MarshalJSON ¶
type AppUnitsResponse ¶
type Applog ¶
type Applog struct { MongoID bson.ObjectId `bson:"_id,omitempty" json:"-"` Date time.Time Message string Source string AppName string Unit string }
Applog represents a log entry.
type DeployData ¶
type DeployData struct { ID bson.ObjectId `bson:"_id,omitempty"` App string Timestamp time.Time Duration time.Duration Commit string Error string Image string Log string User string Origin string CanRollback bool RemoveDate time.Time `bson:",omitempty"` Diff string Message string }
func GetDeploy ¶
func GetDeploy(id string) (*DeployData, error)
func ListDeploys ¶
func ListDeploys(filter *Filter, skip, limit int) ([]DeployData, error)
ListDeploys returns the list of deploy that match a given filter.
type DeployKind ¶
type DeployKind string
const ( DeployArchiveURL DeployKind = "archive-url" DeployGit DeployKind = "git" DeployImage DeployKind = "image" DeployBuildedImage DeployKind = "imagebuild" DeployRollback DeployKind = "rollback" DeployUpload DeployKind = "upload" DeployUploadBuild DeployKind = "uploadbuild" DeployRebuild DeployKind = "rebuild" )
type DeployOptions ¶
type DeployOptions struct { App *App Commit string BuildTag string ArchiveURL string FileSize int64 File io.ReadCloser `bson:"-"` OutputStream io.Writer `bson:"-"` User string Image string Origin string Rollback bool Build bool Event *event.Event `bson:"-"` Kind DeployKind Message string }
func (*DeployOptions) GetKind ¶
func (o *DeployOptions) GetKind() (kind DeployKind)
func (*DeployOptions) GetOrigin ¶
func (o *DeployOptions) GetOrigin() string
type ErrAppNotLocked ¶
type ErrAppNotLocked struct {
App string
}
func (ErrAppNotLocked) Error ¶
func (e ErrAppNotLocked) Error() string
type Filter ¶
type LogDispatcher ¶
type LogDispatcher struct {
// contains filtered or unexported fields
}
func NewlogDispatcher ¶
func NewlogDispatcher(chanSize int) *LogDispatcher
func (*LogDispatcher) Send ¶
func (d *LogDispatcher) Send(msg *Applog) error
func (*LogDispatcher) String ¶
func (a *LogDispatcher) String() string
type LogListener ¶
type LogListener struct {
// contains filtered or unexported fields
}
func NewLogListener ¶
func NewLogListener(a *App, filterLog Applog) (*LogListener, error)
func (*LogListener) Close ¶
func (l *LogListener) Close()
func (*LogListener) ListenChan ¶
func (l *LogListener) ListenChan() <-chan Applog
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
type ProcfileError ¶
type ProcfileError struct {
// contains filtered or unexported fields
}
func (*ProcfileError) Error ¶
func (e *ProcfileError) Error() string
type UpdateUnitsResult ¶
func UpdateNodeStatus ¶
func UpdateNodeStatus(nodeData provision.NodeStatusData) ([]UpdateUnitsResult, error)
UpdateNodeStatus updates the status of the given node and its units, returning a map which units were found during the update.