Documentation ¶
Index ¶
- Constants
- Variables
- func IsInvalidVersionError(err error) bool
- type AddVersionDataArgs
- type App
- type AppCreationError
- type AppInfo
- type AppInternalAddress
- type AppLock
- type AppLogService
- type AppLogServiceInstance
- type AppResume
- type AppRouter
- type AppService
- type AppVersion
- type AppVersionInfo
- type AppVersionService
- type AppVersionStorage
- type AppVersionWriteOptions
- type AppVersions
- type Applog
- type CPUBurst
- type CertIssuers
- type CertificateInfo
- type CertificateSetInfo
- type ErrInvalidVersion
- type Filter
- type ListLogArgs
- type LogWatcher
- type ManyTeamsError
- type Metadata
- type MetadataItem
- type MockAppLogService
- func (m *MockAppLogService) Add(appName, message, source, unit string) error
- func (m *MockAppLogService) Enqueue(entry *Applog) error
- func (m *MockAppLogService) List(ctx context.Context, args ListLogArgs) ([]Applog, error)
- func (m *MockAppLogService) Watch(ctx context.Context, args ListLogArgs) (LogWatcher, error)
- type MockAppService
- func (m *MockAppService) AddInstance(ctx context.Context, app *App, addArgs bind.AddInstanceArgs) error
- func (m *MockAppService) EnsureUUID(ctx context.Context, app *App) (string, error)
- func (m *MockAppService) GetAddresses(ctx context.Context, app *App) ([]string, error)
- func (m *MockAppService) GetByName(ctx context.Context, name string) (*App, error)
- func (m *MockAppService) GetHealthcheckData(ctx context.Context, app *App) (router.HealthcheckData, error)
- func (m *MockAppService) GetInternalBindableAddresses(ctx context.Context, app *App) ([]string, error)
- func (m *MockAppService) GetRegistry(ctx context.Context, app *App) (image.ImageRegistry, error)
- func (m *MockAppService) List(ctx context.Context, f *Filter) ([]*App, error)
- func (m *MockAppService) RemoveInstance(ctx context.Context, app *App, removeArgs bind.RemoveInstanceArgs) error
- type MockLogWatcher
- type MockPlanService
- func (m *MockPlanService) Create(ctx context.Context, plan Plan) error
- func (m *MockPlanService) DefaultPlan(ctx context.Context) (*Plan, error)
- func (m *MockPlanService) FindByName(ctx context.Context, name string) (*Plan, error)
- func (m *MockPlanService) List(ctx context.Context) ([]Plan, error)
- func (m *MockPlanService) Remove(ctx context.Context, name string) error
- type MockPlanStorage
- func (m *MockPlanStorage) Delete(ctx context.Context, p Plan) error
- func (m *MockPlanStorage) FindAll(ctx context.Context) ([]Plan, error)
- func (m *MockPlanStorage) FindByName(ctx context.Context, name string) (*Plan, error)
- func (m *MockPlanStorage) FindDefault(ctx context.Context) (*Plan, error)
- func (m *MockPlanStorage) Insert(ctx context.Context, p Plan) error
- type MockPlatformService
- func (m *MockPlatformService) Create(ctx context.Context, opts PlatformOptions) error
- func (m *MockPlatformService) FindByName(ctx context.Context, name string) (*Platform, error)
- func (m *MockPlatformService) List(ctx context.Context, enabledOnly bool) ([]Platform, error)
- func (m *MockPlatformService) Remove(ctx context.Context, name string) error
- func (m *MockPlatformService) Rollback(ctx context.Context, opts PlatformOptions) error
- func (m *MockPlatformService) Update(ctx context.Context, opts PlatformOptions) error
- type MockPlatformStorage
- func (m *MockPlatformStorage) Delete(ctx context.Context, p Platform) error
- func (m *MockPlatformStorage) FindAll(ctx context.Context) ([]Platform, error)
- func (m *MockPlatformStorage) FindByName(ctx context.Context, name string) (*Platform, error)
- func (m *MockPlatformStorage) FindEnabled(ctx context.Context) ([]Platform, error)
- func (m *MockPlatformStorage) Insert(ctx context.Context, p Platform) error
- func (m *MockPlatformStorage) Update(ctx context.Context, p Platform) error
- type NewVersionArgs
- type NoTeamsError
- type Plan
- type PlanOverride
- type PlanService
- type PlanStorage
- type PlanValidationError
- type Platform
- type PlatformOptions
- type PlatformService
- type PlatformStorage
- type Process
- type RoutableAddresses
- type RouterCertificateInfo
Constants ¶
const (
DefaultAppDir = "/home/application/current"
)
Variables ¶
var ( ErrAppNotFound = errors.New("App not found") ErrPlanNotFound = errors.New("plan not found") ErrPlanAlreadyExists = errors.New("plan already exists") ErrPlanDefaultAmbiguous = errors.New("more than one default plan found") ErrPlanDefaultNotFound = errors.New("default plan not found") ErrLimitOfMemory = errors.New("The minimum allowed memory is 4MB") ErrPlatformNameMissing = errors.New("Platform name is required.") ErrPlatformImageMissing = errors.New("Platform image is required.") ErrPlatformNotFound = errors.New("Platform doesn't exist.") ErrDuplicatePlatform = errors.New("Duplicate platform") ErrInvalidPlatform = errors.New("Invalid platform") ErrMissingFileContent = errors.New("Missing file content.") ErrDeletePlatformWithApps = errors.New("Platform has apps. You must remove them before remove the platform.") ErrInvalidPlatformName = &tsuruErrors.ValidationError{ Message: "Invalid platform name, should have at most 40 " + "characters, containing only lower case letters, numbers or dashes, " + "starting with a letter.", } )
var ( ErrNoVersionsAvailable = errors.New("no versions available for app") ErrTransactionCancelledByChange = errors.New("The update has been cancelled by a previous change") ErrVersionMarkedToRemoval = errors.New("the selected version is marked to removal") )
var CertIssuerDotReplacement = "_dot_"
Functions ¶
func IsInvalidVersionError ¶
Types ¶
type AddVersionDataArgs ¶
type App ¶
type App struct { Env map[string]bind.EnvVar ServiceEnvs []bind.ServiceEnvVar Platform string `bson:"framework"` PlatformVersion string Name string CName []string CertIssuers CertIssuers Teams []string TeamOwner string Owner string Plan Plan UpdatePlatform bool Lock AppLock Pool string Description string Router string // TODO: drop Router field and use just on inputApp RouterOpts map[string]string Deploys uint Tags []string Error string Routers []AppRouter Metadata Metadata Processes []Process // UUID is a v4 UUID lazily generated on the first call to GetUUID() UUID string Quota quota.Quota }
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.
type AppCreationError ¶
func (*AppCreationError) Error ¶
func (e *AppCreationError) Error() string
type AppInfo ¶
type AppInfo struct { Name string `json:"name"` Platform string `json:"platform"` Teams []string `json:"teams"` Plan *Plan `json:"plan"` CName []string `json:"cname"` Owner string `json:"owner"` // we may move this to createdBy Pool string `json:"pool"` Description string `json:"description"` Deploys uint `json:"deploys"` TeamOwner string `json:"teamowner"` Lock AppLock `json:"lock"` Tags []string `json:"tags"` Metadata Metadata `json:"metadata"` Units []provision.Unit `json:"units"` InternalAddresses []AppInternalAddress `json:"internalAddresses,omitempty"` Autoscale []provision.AutoScaleSpec `json:"autoscale,omitempty"` UnitsMetrics []provision.UnitMetric `json:"unitsMetrics,omitempty"` AutoscaleRecommendation []provision.RecommendedResources `json:"autoscaleRecommendation,omitempty"` Provisioner string `json:"provisioner,omitempty"` Cluster string `json:"cluster,omitempty"` Processes []Process `json:"processes,omitempty"` Routers []AppRouter `json:"routers"` VolumeBinds []volume.VolumeBind `json:"volumeBinds,omitempty"` ServiceInstanceBinds []bind.ServiceInstanceBind `json:"serviceInstanceBinds"` IP string `json:"ip,omitempty"` Router string `json:"router,omitempty"` RouterOpts map[string]string `json:"routeropts"` Quota *quota.Quota `json:"quota,omitempty"` Error string `json:"error,omitempty"` DashboardURL string `json:"dashboardURL,omitempty"` }
type AppInternalAddress ¶
type AppLogService ¶
type AppLogService interface { Enqueue(entry *Applog) error Add(appName, message, source, unit string) error List(ctx context.Context, args ListLogArgs) ([]Applog, error) Watch(ctx context.Context, args ListLogArgs) (LogWatcher, error) }
type AppLogServiceInstance ¶
type AppLogServiceInstance interface {
Instance() AppLogService
}
type AppResume ¶
type AppResume struct { Name string `json:"name"` Pool string `json:"pool"` TeamOwner string `json:"teamowner"` Plan Plan `json:"plan"` Units []provision.Unit `json:"units"` CName []string `json:"cname"` IP string `json:"ip"` Routers []AppRouter `json:"routers"` Lock AppLock `json:"lock"` Tags []string `json:"tags"` Error string `json:"error,omitempty"` Platform string `json:"platform,omitempty"` Description string `json:"description,omitempty"` Metadata Metadata `json:"metadata,omitempty"` }
AppResume is a minimal representation of the app, created to make appList faster and transmit less data.
type AppRouter ¶
type AppRouter struct { Name string `json:"name"` Opts map[string]string `json:"opts"` Address string `json:"address" bson:"-"` Addresses []string `json:"addresses" bson:"-"` Type string `json:"type" bson:"-"` Status string `json:"status,omitempty" bson:"-"` StatusDetail string `json:"status-detail,omitempty" bson:"-"` }
type AppService ¶
type AppService interface { GetByName(ctx context.Context, name string) (*App, error) List(ctx context.Context, filter *Filter) ([]*App, error) GetHealthcheckData(ctx context.Context, app *App) (router.HealthcheckData, error) GetAddresses(ctx context.Context, app *App) ([]string, error) GetInternalBindableAddresses(ctx context.Context, app *App) ([]string, error) EnsureUUID(ctx context.Context, app *App) (string, error) GetRegistry(ctx context.Context, app *App) (image.ImageRegistry, error) AddInstance(ctx context.Context, app *App, addArgs bind.AddInstanceArgs) error RemoveInstance(ctx context.Context, app *App, removeArgs bind.RemoveInstanceArgs) error }
type AppVersion ¶
type AppVersion interface { Version() int BuildImageName() (string, error) CommitBuildImage() error BaseImageName() (string, error) CommitBaseImage() error CommitSuccessful() error MarkToRemoval() error VersionInfo() AppVersionInfo Processes() (map[string][]string, error) TsuruYamlData() (provTypes.TsuruYamlData, error) WebProcess() (string, error) AddData(AddVersionDataArgs) error String() string ToggleEnabled(enabled bool, reason string) error UpdatePastUnits(process string, replicas int) error }
type AppVersionInfo ¶
type AppVersionInfo struct { Version int `json:"version"` Description string `json:"description"` BuildImage string `json:"buildImage"` DeployImage string `json:"deployImage"` CustomBuildTag string `json:"customBuildTag"` CustomData map[string]interface{} `json:"customData"` Processes map[string][]string `json:"processes"` ExposedPorts []string `json:"exposedPorts"` EventID string `json:"eventID"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DisabledReason string `json:"disabledReason"` Disabled bool `json:"disabled"` DeploySuccessful bool `json:"deploySuccessful"` MarkedToRemoval bool `json:"markedToRemoval"` PastUnits map[string]int `json:"pastUnits"` }
type AppVersionService ¶
type AppVersionService interface { VersionByPendingImage(ctx context.Context, app *App, imageID string) (AppVersion, error) VersionByImageOrVersion(ctx context.Context, app *App, image string) (AppVersion, error) LatestSuccessfulVersion(ctx context.Context, app *App) (AppVersion, error) NewAppVersion(ctx context.Context, args NewVersionArgs) (AppVersion, error) AppVersionFromInfo(context.Context, *App, AppVersionInfo) (AppVersion, error) // contains filtered or unexported methods }
type AppVersionStorage ¶
type AppVersionStorage interface { UpdateVersion(ctx context.Context, appName string, vi *AppVersionInfo, opts ...*AppVersionWriteOptions) error UpdateVersionSuccess(ctx context.Context, appName string, vi *AppVersionInfo, opts ...*AppVersionWriteOptions) error NewAppVersion(ctx context.Context, args NewVersionArgs) (*AppVersionInfo, error) // contains filtered or unexported methods }
type AppVersionWriteOptions ¶
type AppVersionWriteOptions struct { // PreviousUpdatedHash is used to avoid a race of updates and loss data by concurrent updates. PreviousUpdatedHash string }
type AppVersions ¶
type AppVersions struct { AppName string `json:"appName"` Count int `json:"count"` LastSuccessfulVersion int `json:"lastSuccessfulVersion"` Versions map[int]AppVersionInfo `json:"versions"` UpdatedAt time.Time `json:"updatedAt"` UpdatedHash string `json:"updatedHash"` MarkedToRemoval bool `json:"markedToRemoval"` }
type Applog ¶
type Applog struct { MongoID primitive.ObjectID `bson:"_id,omitempty" json:"-"` Date time.Time Message string Source string Name string Type logTypes.LogType Unit string }
Applog represents a log entry.
type CertIssuers ¶
type CertificateInfo ¶
type CertificateSetInfo ¶
type CertificateSetInfo struct {
Routers map[string]RouterCertificateInfo `json:"routers"`
}
func (*CertificateSetInfo) IsEmpty ¶
func (csi *CertificateSetInfo) IsEmpty() bool
type ErrInvalidVersion ¶
type ErrInvalidVersion struct {
Version string
}
func (ErrInvalidVersion) Error ¶
func (i ErrInvalidVersion) Error() string
type ListLogArgs ¶
type LogWatcher ¶
type LogWatcher interface { Chan() <-chan Applog Close() }
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 Metadata ¶
type Metadata struct { Labels []MetadataItem `json:"labels"` Annotations []MetadataItem `json:"annotations"` }
Metadata represents the user defined labels and annotations
type MetadataItem ¶
type MetadataItem struct { Name string `json:"name"` Value string `json:"value,omitempty"` Delete bool `json:"delete,omitempty" bson:"-"` }
MetadataItem is a Name-Value structure
type MockAppLogService ¶
type MockAppLogService struct{}
func (*MockAppLogService) Add ¶
func (m *MockAppLogService) Add(appName, message, source, unit string) error
func (*MockAppLogService) Enqueue ¶
func (m *MockAppLogService) Enqueue(entry *Applog) error
func (*MockAppLogService) List ¶
func (m *MockAppLogService) List(ctx context.Context, args ListLogArgs) ([]Applog, error)
func (*MockAppLogService) Watch ¶
func (m *MockAppLogService) Watch(ctx context.Context, args ListLogArgs) (LogWatcher, error)
type MockAppService ¶
type MockAppService struct { Apps []*App OnList func(filter *Filter) ([]*App, error) OnRegistry func(app *App) (image.ImageRegistry, error) OnGetAddresses func(app *App) ([]string, error) OnAddInstance func(app *App, addArgs bind.AddInstanceArgs) error OnRemoveInstance func(app *App, removeArgs bind.RemoveInstanceArgs) error OnGetInternalBindableAddresses func(app *App) ([]string, error) OnGetHealthcheckData func(app *App) (router.HealthcheckData, error) }
func (*MockAppService) AddInstance ¶
func (m *MockAppService) AddInstance(ctx context.Context, app *App, addArgs bind.AddInstanceArgs) error
func (*MockAppService) EnsureUUID ¶
func (*MockAppService) GetAddresses ¶
func (*MockAppService) GetHealthcheckData ¶
func (m *MockAppService) GetHealthcheckData(ctx context.Context, app *App) (router.HealthcheckData, error)
func (*MockAppService) GetInternalBindableAddresses ¶
func (*MockAppService) GetRegistry ¶
func (m *MockAppService) GetRegistry(ctx context.Context, app *App) (image.ImageRegistry, error)
func (*MockAppService) RemoveInstance ¶
func (m *MockAppService) RemoveInstance(ctx context.Context, app *App, removeArgs bind.RemoveInstanceArgs) error
type MockLogWatcher ¶
type MockLogWatcher struct {
// contains filtered or unexported fields
}
func NewMockLogWatcher ¶
func NewMockLogWatcher() *MockLogWatcher
func (*MockLogWatcher) Chan ¶
func (m *MockLogWatcher) Chan() <-chan Applog
func (*MockLogWatcher) Close ¶
func (m *MockLogWatcher) Close()
func (*MockLogWatcher) Enqueue ¶
func (m *MockLogWatcher) Enqueue(log Applog)
type MockPlanService ¶
type MockPlanService struct { Plans []Plan OnCreate func(Plan) error OnList func() ([]Plan, error) OnFindByName func(string) (*Plan, error) OnDefaultPlan func() (*Plan, error) OnRemove func(string) error }
MockPlanService implements PlanService interface
func (*MockPlanService) Create ¶
func (m *MockPlanService) Create(ctx context.Context, plan Plan) error
func (*MockPlanService) DefaultPlan ¶
func (m *MockPlanService) DefaultPlan(ctx context.Context) (*Plan, error)
func (*MockPlanService) FindByName ¶
type MockPlanStorage ¶
type MockPlanStorage struct { OnInsert func(Plan) error OnFindAll func() ([]Plan, error) OnFindDefault func() (*Plan, error) OnFindByName func(string) (*Plan, error) OnDelete func(Plan) error }
MockPlanStorage implements PlanStorage interface
func (*MockPlanStorage) Delete ¶
func (m *MockPlanStorage) Delete(ctx context.Context, p Plan) error
func (*MockPlanStorage) FindAll ¶
func (m *MockPlanStorage) FindAll(ctx context.Context) ([]Plan, error)
func (*MockPlanStorage) FindByName ¶
func (*MockPlanStorage) FindDefault ¶
func (m *MockPlanStorage) FindDefault(ctx context.Context) (*Plan, error)
type MockPlatformService ¶
type MockPlatformService struct { OnCreate func(PlatformOptions) error OnList func(bool) ([]Platform, error) OnFindByName func(string) (*Platform, error) OnUpdate func(PlatformOptions) error OnRemove func(string) error OnRollback func(PlatformOptions) error }
MockPlatformService implements PlatformService interface
func (*MockPlatformService) Create ¶
func (m *MockPlatformService) Create(ctx context.Context, opts PlatformOptions) error
func (*MockPlatformService) FindByName ¶
func (*MockPlatformService) Remove ¶
func (m *MockPlatformService) Remove(ctx context.Context, name string) error
func (*MockPlatformService) Rollback ¶
func (m *MockPlatformService) Rollback(ctx context.Context, opts PlatformOptions) error
func (*MockPlatformService) Update ¶
func (m *MockPlatformService) Update(ctx context.Context, opts PlatformOptions) error
type MockPlatformStorage ¶
type MockPlatformStorage struct { OnInsert func(Platform) error OnFindByName func(string) (*Platform, error) OnFindAll func() ([]Platform, error) OnFindEnabled func() ([]Platform, error) OnUpdate func(Platform) error OnDelete func(Platform) error }
MockPlatformStorage implements PlatformStorage interface
func (*MockPlatformStorage) Delete ¶
func (m *MockPlatformStorage) Delete(ctx context.Context, p Platform) error
func (*MockPlatformStorage) FindAll ¶
func (m *MockPlatformStorage) FindAll(ctx context.Context) ([]Platform, error)
func (*MockPlatformStorage) FindByName ¶
func (*MockPlatformStorage) FindEnabled ¶
func (m *MockPlatformStorage) FindEnabled(ctx context.Context) ([]Platform, error)
type NewVersionArgs ¶
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 Plan ¶
type Plan struct { Name string `json:"name"` Memory int64 `json:"memory"` CPUMilli int `json:"cpumilli"` CPUBurst *CPUBurst `json:"cpuBurst,omitempty"` Default bool `json:"default,omitempty"` Override *PlanOverride `json:"override,omitempty"` }
func (Plan) GetCPUBurst ¶
func (Plan) GetMilliCPU ¶
func (*Plan) MergeOverride ¶
func (p *Plan) MergeOverride(po PlanOverride)
type PlanOverride ¶
type PlanService ¶
type PlanStorage ¶
type PlanValidationError ¶
type PlanValidationError struct {
Field string
}
func (PlanValidationError) Error ¶
func (p PlanValidationError) Error() string
type PlatformOptions ¶
type PlatformService ¶
type PlatformService interface { Create(context.Context, PlatformOptions) error List(context.Context, bool) ([]Platform, error) FindByName(context.Context, string) (*Platform, error) Update(context.Context, PlatformOptions) error Remove(context.Context, string) error Rollback(context.Context, PlatformOptions) error }
type PlatformStorage ¶
type PlatformStorage interface { Insert(context.Context, Platform) error FindByName(context.Context, string) (*Platform, error) FindAll(context.Context) ([]Platform, error) FindEnabled(context.Context) ([]Platform, error) Update(context.Context, Platform) error Delete(context.Context, Platform) error }
type Process ¶
type RoutableAddresses ¶
type RouterCertificateInfo ¶
type RouterCertificateInfo struct {
CNames map[string]CertificateInfo `json:"cnames"`
}
func (*RouterCertificateInfo) IsEmpty ¶
func (rci *RouterCertificateInfo) IsEmpty() bool