app

package
v0.0.0-...-47649f3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: BSD-3-Clause Imports: 15 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.",
	}
)
View Source
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")
)

Functions

func IsInvalidVersionError

func IsInvalidVersionError(err error) bool

Types

type AddVersionDataArgs

type AddVersionDataArgs struct {
	Processes    map[string][]string
	CustomData   map[string]interface{}
	ExposedPorts []string
}

type App

type App interface {
	GetName() string
	GetPool() string
	GetTeamOwner() string
	GetTeamsName() []string
	GetPlatform() string
	GetPlatformVersion() string
	GetRegistry() (image.ImageRegistry, error)
	GetDeploys() uint
	GetUpdatePlatform() bool
}

type AppCreationError

type AppCreationError struct {
	App string
	Err error
}

func (*AppCreationError) Error

func (e *AppCreationError) Error() string

type AppLock

type AppLock struct {
	Locked      bool
	Reason      string
	Owner       string
	AcquireDate time.Time
}

AppLock stores information about a lock hold on the app

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 AppLogServiceProvision

type AppLogServiceProvision interface {
	Provision(appName string) error
	CleanUp(appname string) error
}

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)
}

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 bson.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 CPUBurst

type CPUBurst struct {
	Default    float64 `json:"default"`
	MaxAllowed float64 `json:"maxAllowed"`
}

type ErrInvalidVersion

type ErrInvalidVersion struct {
	Version string
}

func (ErrInvalidVersion) Error

func (i ErrInvalidVersion) Error() string

type Filter

type Filter struct {
	Name        string
	NameMatches string
	Platform    string
	TeamOwner   string
	UserOwner   string
	Pool        string
	Pools       []string
	Statuses    []string
	Locked      bool
	Tags        []string
	Extra       map[string][]string
}

type ListLogArgs

type ListLogArgs struct {
	Name         string
	Type         logTypes.LogType
	Source       string
	Units        []string
	Limit        int
	InvertSource bool
}

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

func (Metadata) Annotation

func (m Metadata) Annotation(v string) (string, bool)

func (*Metadata) Empty

func (m *Metadata) Empty() bool

func (Metadata) Label

func (m Metadata) Label(v string) (string, bool)

func (*Metadata) Update

func (m *Metadata) Update(new Metadata)

func (*Metadata) Validate

func (m *Metadata) Validate() error

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 MockApp

type MockApp struct {
	Name, TeamOwner, Platform, PlatformVersion, Pool string
	Deploys                                          uint
	UpdatePlatform                                   bool
	TeamsName                                        []string
	Registry                                         imgTypes.ImageRegistry
}

func (*MockApp) GetDeploys

func (a *MockApp) GetDeploys() uint

func (*MockApp) GetName

func (a *MockApp) GetName() string

func (*MockApp) GetPlatform

func (a *MockApp) GetPlatform() string

func (*MockApp) GetPlatformVersion

func (a *MockApp) GetPlatformVersion() string

func (*MockApp) GetPool

func (a *MockApp) GetPool() string

func (*MockApp) GetRegistry

func (a *MockApp) GetRegistry() (imgTypes.ImageRegistry, error)

func (*MockApp) GetTeamOwner

func (a *MockApp) GetTeamOwner() string

func (*MockApp) GetTeamsName

func (a *MockApp) GetTeamsName() []string

func (*MockApp) GetUpdatePlatform

func (a *MockApp) GetUpdatePlatform() bool

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

type MockAppService

type MockAppService struct {
	Apps   []App
	OnList func(filter *Filter) ([]App, error)
}

func (*MockAppService) GetByName

func (m *MockAppService) GetByName(ctx context.Context, name string) (App, error)

func (*MockAppService) List

func (m *MockAppService) List(ctx context.Context, f *Filter) ([]App, 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

func (m *MockPlanService) FindByName(ctx context.Context, name string) (*Plan, error)

func (*MockPlanService) List

func (m *MockPlanService) List(ctx context.Context) ([]Plan, error)

func (*MockPlanService) Remove

func (m *MockPlanService) Remove(ctx context.Context, name string) error

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 (m *MockPlanStorage) FindByName(ctx context.Context, name string) (*Plan, error)

func (*MockPlanStorage) FindDefault

func (m *MockPlanStorage) FindDefault(ctx context.Context) (*Plan, error)

func (*MockPlanStorage) Insert

func (m *MockPlanStorage) Insert(ctx context.Context, p 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 (*MockPlatformService) FindByName

func (m *MockPlatformService) FindByName(ctx context.Context, name string) (*Platform, error)

func (*MockPlatformService) List

func (m *MockPlatformService) List(ctx context.Context, enabledOnly bool) ([]Platform, error)

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

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 (m *MockPlatformStorage) FindByName(ctx context.Context, name string) (*Platform, error)

func (*MockPlatformStorage) FindEnabled

func (m *MockPlatformStorage) FindEnabled(ctx context.Context) ([]Platform, error)

func (*MockPlatformStorage) Insert

func (m *MockPlatformStorage) Insert(ctx context.Context, p Platform) error

func (*MockPlatformStorage) Update

func (m *MockPlatformStorage) Update(ctx context.Context, p Platform) error

type NewVersionArgs

type NewVersionArgs struct {
	EventID        string
	App            App
	CustomBuildTag string
	Description    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 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 (p Plan) GetCPUBurst() float64

func (Plan) GetMemory

func (p Plan) GetMemory() int64

func (Plan) GetMilliCPU

func (p Plan) GetMilliCPU() int

func (*Plan) MergeOverride

func (p *Plan) MergeOverride(po PlanOverride)

type PlanOverride

type PlanOverride struct {
	Memory   *int64   `json:"memory"`
	CPUMilli *int     `json:"cpumilli"`
	CPUBurst *float64 `json:"cpuBurst"`
}

type PlanService

type PlanService interface {
	Create(ctx context.Context, plan Plan) error
	List(context.Context) ([]Plan, error)
	FindByName(ctx context.Context, name string) (*Plan, error)
	DefaultPlan(context.Context) (*Plan, error)
	Remove(ctx context.Context, planName string) error
}

type PlanStorage

type PlanStorage interface {
	Insert(context.Context, Plan) error
	FindAll(context.Context) ([]Plan, error)
	FindDefault(context.Context) (*Plan, error)
	FindByName(context.Context, string) (*Plan, error)
	Delete(context.Context, Plan) error
}

type PlanValidationError

type PlanValidationError struct {
	Field string
}

func (PlanValidationError) Error

func (p PlanValidationError) Error() string

type Platform

type Platform struct {
	Name     string
	Disabled bool
}

type PlatformOptions

type PlatformOptions struct {
	Name            string
	Version         int
	ExtraTags       []string
	Args            map[string]string
	Output          io.Writer
	Data            []byte
	RollbackVersion int
}

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 Process struct {
	Name     string   `json:"name"` // name of process, it is like a merge key
	Plan     string   `json:"plan,omitempty"`
	Metadata Metadata `json:"metadata"`
}

func (*Process) Empty

func (p *Process) Empty() bool

type RoutableAddresses

type RoutableAddresses struct {
	Prefix    string
	Addresses []*url.URL
	ExtraData map[string]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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