service

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Overview

@Author: LinkLeong link@icewhale.com

*@Date: 2022-07-12 09:48:56
*@LastEditors: LinkLeong
*@LastEditTime: 2022-09-02 22:10:05
*@FilePath: /CasaOS/service/service.go
*@Description:
*@Website: https://www.casaos.io
*Copyright (c) 2022 by icewhale, All Rights Reserved.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAppStore             = fmt.Errorf("not an appstore")
	ErrDefaultAppStoreNotFound = fmt.Errorf("default appstore not found")
)
View Source
var (
	ErrComposeAppNotFound                  = fmt.Errorf("compose app not found")
	ErrComposeAppNotMatch                  = fmt.Errorf("compose app not match")
	ErrComposeExtensionNameXCasaOSNotFound = fmt.Errorf("extension `%s` not found", common.ComposeExtensionNameXCasaOS)
	ErrComposeFileNotFound                 = fmt.Errorf("compose file not found")
	ErrInvalidComposeAppStatus             = fmt.Errorf("invalid compose app status")
	ErrMainAppNotFound                     = fmt.Errorf("main app not found")
	ErrNotFoundInAppStore                  = fmt.Errorf("not found in app store")
	ErrSetStoreAppID                       = fmt.Errorf("failed to set store app ID")
	ErrStoreInfoNotFound                   = fmt.Errorf("store info not found")
)
View Source
var (
	NewVersionApp map[string]string // TODO - make use of NewVersionApp map
)

Functions

func ApiService added in v0.4.4

func ApiService() (api.Service, client.APIClient, error)

func BuildCatalog added in v0.4.3

func BuildCatalog(storeRoot string) (map[string]*ComposeApp, error)

func GenerateYAMLFromComposeApp added in v0.4.5

func GenerateYAMLFromComposeApp(compose ComposeApp) ([]byte, error)

func LoadCategoryMap added in v0.4.4

func LoadCategoryMap(storeRoot string) map[string]codegen.CategoryInfo

func LoadRecommend added in v0.4.3

func LoadRecommend(storeRoot string) []string

func PublishEventWrapper added in v0.4.2

func PublishEventWrapper(ctx context.Context, eventType message_bus.EventType, properties map[string]string)

func Standardize added in v0.4.3

func Standardize(text string) string

func StoreRoot added in v0.4.3

func StoreRoot(workdir string) (string, error)

Types

type App added in v0.4.3

type App types.ServiceConfig

func (*App) StoreInfo added in v0.4.3

func (a *App) StoreInfo() (codegen.AppStoreInfo, error)

type AppStore added in v0.4.1

type AppStore interface {
	Catalog() (map[string]*ComposeApp, error)
	CategoryMap() (map[string]codegen.CategoryInfo, error)
	ComposeApp(id string) (*ComposeApp, error)
	Recommend() ([]string, error)
	UpdateCatalog() error
	WorkDir() (string, error)
}

func AppStoreByURL added in v0.4.4

func AppStoreByURL(appstoreURL string) (AppStore, error)

func NewDefaultAppStore added in v0.4.3

func NewDefaultAppStore() (AppStore, error)

type AppStoreManagement added in v0.4.3

type AppStoreManagement struct {
	// contains filtered or unexported fields
}

func NewAppStoreManagement added in v0.4.3

func NewAppStoreManagement() *AppStoreManagement

func (*AppStoreManagement) AppStoreList added in v0.4.3

func (a *AppStoreManagement) AppStoreList() []codegen.AppStoreMetadata

func (*AppStoreManagement) AppStoreMap added in v0.4.3

func (a *AppStoreManagement) AppStoreMap() (map[string]AppStore, error)

func (*AppStoreManagement) Catalog added in v0.4.3

func (a *AppStoreManagement) Catalog() (map[string]*ComposeApp, error)

func (*AppStoreManagement) CategoryMap added in v0.4.4

func (a *AppStoreManagement) CategoryMap() (map[string]codegen.CategoryInfo, error)

AppStore interface

func (*AppStoreManagement) ChangeGlobal added in v0.4.5

func (a *AppStoreManagement) ChangeGlobal(key string, value string) error

func (*AppStoreManagement) ComposeApp added in v0.4.3

func (a *AppStoreManagement) ComposeApp(id string) (*ComposeApp, error)

func (*AppStoreManagement) DeleteGlobal added in v0.4.5

func (a *AppStoreManagement) DeleteGlobal(key string) error

func (*AppStoreManagement) OnAppStoreRegister added in v0.4.3

func (a *AppStoreManagement) OnAppStoreRegister(fn func(string) error)

func (*AppStoreManagement) OnAppStoreUnregister added in v0.4.3

func (a *AppStoreManagement) OnAppStoreUnregister(fn func(string) error)

func (*AppStoreManagement) Recommend added in v0.4.3

func (a *AppStoreManagement) Recommend() ([]string, error)

func (*AppStoreManagement) RegisterAppStore added in v0.4.3

func (a *AppStoreManagement) RegisterAppStore(ctx context.Context, appstoreURL string, callbacks ...func(*codegen.AppStoreMetadata)) error

func (*AppStoreManagement) UnregisterAppStore added in v0.4.3

func (a *AppStoreManagement) UnregisterAppStore(appStoreID uint) error

func (*AppStoreManagement) UpdateCatalog added in v0.4.3

func (a *AppStoreManagement) UpdateCatalog() error

func (*AppStoreManagement) WorkDir added in v0.4.3

func (a *AppStoreManagement) WorkDir() (string, error)

type ComposeApp added in v0.4.3

type ComposeApp codegen.ComposeApp

func LoadComposeAppFromConfigFile added in v0.4.3

func LoadComposeAppFromConfigFile(appID string, configFile string) (*ComposeApp, error)

func NewComposeAppFromYAML added in v0.4.3

func NewComposeAppFromYAML(yaml []byte, skipInterpolation, skipValidation bool) (*ComposeApp, error)

func (*ComposeApp) App added in v0.4.3

func (a *ComposeApp) App(name string) *App

func (*ComposeApp) Apply added in v0.4.3

func (a *ComposeApp) Apply(ctx context.Context, newComposeYAML []byte) error

func (*ComposeApp) Apps added in v0.4.3

func (a *ComposeApp) Apps() map[string]*App

func (*ComposeApp) AuthorType added in v0.4.4

func (a *ComposeApp) AuthorType() codegen.StoreAppAuthorType

func (*ComposeApp) Containers added in v0.4.3

func (a *ComposeApp) Containers(ctx context.Context) (map[string][]api.ContainerSummary, error)

func (*ComposeApp) Create added in v0.4.4

func (a *ComposeApp) Create(ctx context.Context, options api.CreateOptions, service api.Service) error

func (*ComposeApp) GetPortsInUse added in v0.4.4

func (*ComposeApp) HealthCheck added in v0.4.4

func (a *ComposeApp) HealthCheck() (bool, error)

func (*ComposeApp) IsUpdateAvailable added in v0.4.3

func (a *ComposeApp) IsUpdateAvailable() bool

func (*ComposeApp) IsUpdateAvailableWith added in v0.4.3

func (a *ComposeApp) IsUpdateAvailableWith(storeComposeApp *ComposeApp) bool

func (*ComposeApp) Logs added in v0.4.3

func (a *ComposeApp) Logs(ctx context.Context, lines int) ([]byte, error)

func (*ComposeApp) Pull added in v0.4.4

func (a *ComposeApp) Pull(ctx context.Context) error

func (*ComposeApp) PullAndApply added in v0.4.4

func (a *ComposeApp) PullAndApply(ctx context.Context, newComposeYAML []byte) error

func (*ComposeApp) PullAndInstall added in v0.4.3

func (a *ComposeApp) PullAndInstall(ctx context.Context) error

func (*ComposeApp) SetStatus added in v0.4.3

func (a *ComposeApp) SetStatus(ctx context.Context, status codegen.RequestComposeAppStatus) error

func (*ComposeApp) SetStoreAppID added in v0.4.3

func (a *ComposeApp) SetStoreAppID(storeAppID string) (string, bool)

func (*ComposeApp) SetTitle added in v0.4.4

func (a *ComposeApp) SetTitle(title, lang string)

func (*ComposeApp) StoreInfo added in v0.4.3

func (a *ComposeApp) StoreInfo(includeApps bool) (*codegen.ComposeAppStoreInfo, error)

func (*ComposeApp) Uninstall added in v0.4.3

func (a *ComposeApp) Uninstall(ctx context.Context, deleteConfigFolder bool) error

func (*ComposeApp) Up added in v0.4.4

func (a *ComposeApp) Up(ctx context.Context, service api.Service) error

func (*ComposeApp) UpWithCheckRequire added in v0.4.4

func (a *ComposeApp) UpWithCheckRequire(ctx context.Context, service api.Service) error

func (*ComposeApp) Update added in v0.4.3

func (a *ComposeApp) Update(ctx context.Context) error

func (*ComposeApp) UpdateEventPropertiesFromStoreInfo added in v0.4.4

func (a *ComposeApp) UpdateEventPropertiesFromStoreInfo(eventProperties map[string]string) error

Try to update AppIcon and AppTitle in given event properties from store info

type ComposeService added in v0.4.3

type ComposeService struct{}

func NewComposeService added in v0.4.3

func NewComposeService() *ComposeService

func (*ComposeService) Install added in v0.4.3

func (s *ComposeService) Install(ctx context.Context, composeApp *ComposeApp) error

func (*ComposeService) List added in v0.4.3

func (s *ComposeService) List(ctx context.Context) (map[string]*ComposeApp, error)

func (*ComposeService) PrepareWorkingDirectory added in v0.4.3

func (s *ComposeService) PrepareWorkingDirectory(name string) (string, error)

func (*ComposeService) Status added in v0.4.3

func (s *ComposeService) Status(ctx context.Context, appID string) (string, error)

func (*ComposeService) Uninstall added in v0.4.3

func (s *ComposeService) Uninstall(ctx context.Context, composeApp *ComposeApp, deleteConfigFolder bool) error

type DockerService

type DockerService interface {
	// image
	IsExistImage(imageName string) bool
	PullImage(ctx context.Context, imageName string) error
	PullLatestImage(ctx context.Context, imageName string) (bool, error)
	RemoveImage(name string) error

	// container
	CheckContainerHealth(id string) (bool, error)
	CreateContainer(m model.CustomizationPostData, id string) (containerID string, err error)
	CreateContainerShellSession(container, row, col string) (hr types.HijackedResponse, err error)
	DescribeContainer(ctx context.Context, name string) (*types.ContainerJSON, error)
	GetContainer(id string) (types.Container, error)
	GetContainerAppList(name, image, state *string) (*[]model.MyAppList, *[]model.MyAppList)
	GetContainerByName(name string) (*types.Container, error)
	GetContainerLog(name string) ([]byte, error)
	GetContainerStats() []model.DockerStatsModel
	RecreateContainer(ctx context.Context, id string, pull bool, force bool) error
	RemoveContainer(name string, update bool) error
	RenameContainer(name, id string) (err error)
	StartContainer(name string) error
	StopContainer(id string) error

	// network
	GetNetworkList() []types.NetworkResource

	// docker server
	GetServerInfo() (types.Info, error)
}

func NewDockerService

func NewDockerService() DockerService

type ProgressDetail added in v0.4.5

type ProgressDetail struct {
	Current int64 `json:"current"`
	Total   int64 `json:"total"`
}

type PullOut added in v0.4.5

type PullOut struct {
	Status         StatusType     `json:"status"`
	ProgressDetail ProgressDetail `json:"progressDetail"`
	Id             string         `json:"id"`
}

type Services

type Services interface {
	AppStoreManagement() *AppStoreManagement

	V2AppStore() AppStore

	// Git() *GitService
	Compose() *ComposeService
	Docker() DockerService
	Gateway() external.ManagementService
	Notify() external.NotifyService
	MessageBus() *message_bus.ClientWithResponses
}
var (
	MyService Services
)

func NewService

func NewService(RuntimePath string) Services

type StatusType added in v0.4.5

type StatusType string
const (
	Pull         StatusType = "Pulling fs layer"
	PullComplete StatusType = "Pull complete"
)

type Throttler added in v0.4.5

type Throttler struct {
	InvokeInterval time.Duration
	LastInvokeTime time.Time
}

func NewThrottler added in v0.4.5

func NewThrottler(interval time.Duration) *Throttler

func (*Throttler) ThrottleFunc added in v0.4.5

func (t *Throttler) ThrottleFunc(f func())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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