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 ¶
- Variables
- func ApiService() (api.Service, client.APIClient, error)
- func BuildCatalog(storeRoot string) (map[string]*ComposeApp, error)
- func GenerateYAMLFromComposeApp(compose ComposeApp) ([]byte, error)
- func LoadCategoryMap(storeRoot string) map[string]codegen.CategoryInfo
- func LoadRecommend(storeRoot string) []string
- func PublishEventWrapper(ctx context.Context, eventType message_bus.EventType, ...)
- func Standardize(text string) string
- func StoreRoot(workdir string) (string, error)
- type App
- type AppStore
- type AppStoreManagement
- func (a *AppStoreManagement) AppStoreList() []codegen.AppStoreMetadata
- func (a *AppStoreManagement) AppStoreMap() (map[string]AppStore, error)
- func (a *AppStoreManagement) Catalog() (map[string]*ComposeApp, error)
- func (a *AppStoreManagement) CategoryMap() (map[string]codegen.CategoryInfo, error)
- func (a *AppStoreManagement) ChangeGlobal(key string, value string) error
- func (a *AppStoreManagement) ComposeApp(id string) (*ComposeApp, error)
- func (a *AppStoreManagement) DeleteGlobal(key string) error
- func (a *AppStoreManagement) OnAppStoreRegister(fn func(string) error)
- func (a *AppStoreManagement) OnAppStoreUnregister(fn func(string) error)
- func (a *AppStoreManagement) Recommend() ([]string, error)
- func (a *AppStoreManagement) RegisterAppStore(ctx context.Context, appstoreURL string, ...) error
- func (a *AppStoreManagement) UnregisterAppStore(appStoreID uint) error
- func (a *AppStoreManagement) UpdateCatalog() error
- func (a *AppStoreManagement) WorkDir() (string, error)
- type ComposeApp
- func (a *ComposeApp) App(name string) *App
- func (a *ComposeApp) Apply(ctx context.Context, newComposeYAML []byte) error
- func (a *ComposeApp) Apps() map[string]*App
- func (a *ComposeApp) AuthorType() codegen.StoreAppAuthorType
- func (a *ComposeApp) Containers(ctx context.Context) (map[string][]api.ContainerSummary, error)
- func (a *ComposeApp) Create(ctx context.Context, options api.CreateOptions, service api.Service) error
- func (a *ComposeApp) GetPortsInUse() (*codegen.ComposeAppValidationErrorsPortsInUse, error)
- func (a *ComposeApp) HealthCheck() (bool, error)
- func (a *ComposeApp) IsUpdateAvailable() bool
- func (a *ComposeApp) IsUpdateAvailableWith(storeComposeApp *ComposeApp) bool
- func (a *ComposeApp) Logs(ctx context.Context, lines int) ([]byte, error)
- func (a *ComposeApp) Pull(ctx context.Context) error
- func (a *ComposeApp) PullAndApply(ctx context.Context, newComposeYAML []byte) error
- func (a *ComposeApp) PullAndInstall(ctx context.Context) error
- func (a *ComposeApp) SetStatus(ctx context.Context, status codegen.RequestComposeAppStatus) error
- func (a *ComposeApp) SetStoreAppID(storeAppID string) (string, bool)
- func (a *ComposeApp) SetTitle(title, lang string)
- func (a *ComposeApp) StoreInfo(includeApps bool) (*codegen.ComposeAppStoreInfo, error)
- func (a *ComposeApp) Uninstall(ctx context.Context, deleteConfigFolder bool) error
- func (a *ComposeApp) Up(ctx context.Context, service api.Service) error
- func (a *ComposeApp) UpWithCheckRequire(ctx context.Context, service api.Service) error
- func (a *ComposeApp) Update(ctx context.Context) error
- func (a *ComposeApp) UpdateEventPropertiesFromStoreInfo(eventProperties map[string]string) error
- type ComposeService
- func (s *ComposeService) Install(ctx context.Context, composeApp *ComposeApp) error
- func (s *ComposeService) List(ctx context.Context) (map[string]*ComposeApp, error)
- func (s *ComposeService) PrepareWorkingDirectory(name string) (string, error)
- func (s *ComposeService) Status(ctx context.Context, appID string) (string, error)
- func (s *ComposeService) Uninstall(ctx context.Context, composeApp *ComposeApp, deleteConfigFolder bool) error
- type DockerService
- type Services
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 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 PublishEventWrapper ¶ added in v0.4.2
func Standardize ¶ added in v0.4.3
Types ¶
type App ¶ added in v0.4.3
type App types.ServiceConfig
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 NewDefaultAppStore ¶ added in v0.4.3
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 (a *ComposeApp) GetPortsInUse() (*codegen.ComposeAppValidationErrorsPortsInUse, error)
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) 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) UpWithCheckRequire ¶ added in v0.4.4
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) 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 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 ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.