Documentation ¶
Overview ¶
@Author: LinkLeong link@icewhale.com
*@Date: 2022-07-12 09:48:56 *@LastEditors: LinkLeong *@LastEditTime: 2022-09-02 22:10:05 *@FilePath: /DappsterOS/service/service.go *@Description: *@Website: https://www.dappsteros.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) FinishUpgrade(appID string)
- func (a *AppStoreManagement) IsUpdateAvailable(composeApp *ComposeApp) bool
- func (a *AppStoreManagement) IsUpdateAvailableWith(composeApp *ComposeApp, storeComposeApp *ComposeApp) (bool, error)
- func (a *AppStoreManagement) IsUpdating(appID string) bool
- 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) RegisterAppStoreSync(ctx context.Context, appstoreURL string, ...) error
- func (a *AppStoreManagement) StartUpgrade(appID string)
- 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) Logs(ctx context.Context, lines int) ([]byte, error)
- func (a *ComposeApp) MainService() (*App, error)
- func (a *ComposeApp) MainTag() (string, 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) SetUncontrolled(uncontrolled bool) error
- 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) IsInstalling(appName string) bool
- 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 ProgressDetail
- type PullOut
- type Services
- type StatusType
- type Throttler
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") ErrComposeExtensionNameXDappsterOSNotFound = fmt.Errorf("extension `%s` not found", common.ComposeExtensionNameXDappsterOS) 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") ErrMainServiceNotSpecified = fmt.Errorf("main service not been specified") )
View Source
var ErrAppStoreSourceExists = fmt.Errorf("appstore source already exists")
View Source
var (
NewVersionApp map[string]string // TODO - make use of NewVersionApp map
)
View Source
var NoUpdateBlacklist = []string{
"johnguan/stable-diffusion-webui:latest",
}
the patch is have no choice the digest compare is not work for these images I don't know why, but I have to do this I will remove the patch after I rewrite the digest compare
Functions ¶
func BuildCatalog ¶
func BuildCatalog(storeRoot string) (map[string]*ComposeApp, error)
func GenerateYAMLFromComposeApp ¶
func GenerateYAMLFromComposeApp(compose ComposeApp) ([]byte, error)
func LoadCategoryMap ¶
func LoadCategoryMap(storeRoot string) map[string]codegen.CategoryInfo
func LoadRecommend ¶
func PublishEventWrapper ¶
func Standardize ¶
Types ¶
type App ¶
type App types.ServiceConfig
type AppStore ¶
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 ¶
func NewDefaultAppStore ¶
type AppStoreManagement ¶
type AppStoreManagement struct {
// contains filtered or unexported fields
}
func NewAppStoreManagement ¶
func NewAppStoreManagement() *AppStoreManagement
func (*AppStoreManagement) AppStoreList ¶
func (a *AppStoreManagement) AppStoreList() []codegen.AppStoreMetadata
func (*AppStoreManagement) AppStoreMap ¶
func (a *AppStoreManagement) AppStoreMap() (map[string]AppStore, error)
func (*AppStoreManagement) Catalog ¶
func (a *AppStoreManagement) Catalog() (map[string]*ComposeApp, error)
func (*AppStoreManagement) CategoryMap ¶
func (a *AppStoreManagement) CategoryMap() (map[string]codegen.CategoryInfo, error)
AppStore interface
func (*AppStoreManagement) ChangeGlobal ¶
func (a *AppStoreManagement) ChangeGlobal(key string, value string) error
func (*AppStoreManagement) ComposeApp ¶
func (a *AppStoreManagement) ComposeApp(id string) (*ComposeApp, error)
func (*AppStoreManagement) DeleteGlobal ¶
func (a *AppStoreManagement) DeleteGlobal(key string) error
func (*AppStoreManagement) FinishUpgrade ¶
func (a *AppStoreManagement) FinishUpgrade(appID string)
func (*AppStoreManagement) IsUpdateAvailable ¶
func (a *AppStoreManagement) IsUpdateAvailable(composeApp *ComposeApp) bool
func (*AppStoreManagement) IsUpdateAvailableWith ¶
func (a *AppStoreManagement) IsUpdateAvailableWith(composeApp *ComposeApp, storeComposeApp *ComposeApp) (bool, error)
func (*AppStoreManagement) IsUpdating ¶
func (a *AppStoreManagement) IsUpdating(appID string) bool
func (*AppStoreManagement) OnAppStoreRegister ¶
func (a *AppStoreManagement) OnAppStoreRegister(fn func(string) error)
func (*AppStoreManagement) OnAppStoreUnregister ¶
func (a *AppStoreManagement) OnAppStoreUnregister(fn func(string) error)
func (*AppStoreManagement) Recommend ¶
func (a *AppStoreManagement) Recommend() ([]string, error)
func (*AppStoreManagement) RegisterAppStore ¶
func (a *AppStoreManagement) RegisterAppStore(ctx context.Context, appstoreURL string, callbacks ...func(*codegen.AppStoreMetadata)) error
func (*AppStoreManagement) RegisterAppStoreSync ¶
func (a *AppStoreManagement) RegisterAppStoreSync(ctx context.Context, appstoreURL string, callbacks ...func(*codegen.AppStoreMetadata)) error
TODO: refactor the function and above function
func (*AppStoreManagement) StartUpgrade ¶
func (a *AppStoreManagement) StartUpgrade(appID string)
func (*AppStoreManagement) UnregisterAppStore ¶
func (a *AppStoreManagement) UnregisterAppStore(appStoreID uint) error
func (*AppStoreManagement) UpdateCatalog ¶
func (a *AppStoreManagement) UpdateCatalog() error
func (*AppStoreManagement) WorkDir ¶
func (a *AppStoreManagement) WorkDir() (string, error)
type ComposeApp ¶
type ComposeApp codegen.ComposeApp
func LoadComposeAppFromConfigFile ¶
func LoadComposeAppFromConfigFile(appID string, configFile string) (*ComposeApp, error)
func NewComposeAppFromYAML ¶
func NewComposeAppFromYAML(yaml []byte, skipInterpolation, skipValidation bool) (*ComposeApp, error)
func (*ComposeApp) App ¶
func (a *ComposeApp) App(name string) *App
TODO rename the function to service and add error return value
func (*ComposeApp) Apply ¶
func (a *ComposeApp) Apply(ctx context.Context, newComposeYAML []byte) error
func (*ComposeApp) Apps ¶
func (a *ComposeApp) Apps() map[string]*App
func (*ComposeApp) AuthorType ¶
func (a *ComposeApp) AuthorType() codegen.StoreAppAuthorType
func (*ComposeApp) Containers ¶
func (a *ComposeApp) Containers(ctx context.Context) (map[string][]api.ContainerSummary, error)
func (*ComposeApp) Create ¶
func (a *ComposeApp) Create(ctx context.Context, options api.CreateOptions, service api.Service) error
func (*ComposeApp) GetPortsInUse ¶
func (a *ComposeApp) GetPortsInUse() (*codegen.ComposeAppValidationErrorsPortsInUse, error)
func (*ComposeApp) HealthCheck ¶
func (a *ComposeApp) HealthCheck() (bool, error)
func (*ComposeApp) MainService ¶
func (a *ComposeApp) MainService() (*App, error)
func (*ComposeApp) MainTag ¶
func (a *ComposeApp) MainTag() (string, error)
func (*ComposeApp) PullAndApply ¶
func (a *ComposeApp) PullAndApply(ctx context.Context, newComposeYAML []byte) error
func (*ComposeApp) PullAndInstall ¶
func (a *ComposeApp) PullAndInstall(ctx context.Context) error
func (*ComposeApp) SetStatus ¶
func (a *ComposeApp) SetStatus(ctx context.Context, status codegen.RequestComposeAppStatus) error
func (*ComposeApp) SetStoreAppID ¶
func (a *ComposeApp) SetStoreAppID(storeAppID string) (string, bool)
func (*ComposeApp) SetTitle ¶
func (a *ComposeApp) SetTitle(title, lang string)
func (*ComposeApp) SetUncontrolled ¶
func (a *ComposeApp) SetUncontrolled(uncontrolled bool) error
func (*ComposeApp) StoreInfo ¶
func (a *ComposeApp) StoreInfo(includeApps bool) (*codegen.ComposeAppStoreInfo, error)
func (*ComposeApp) Uninstall ¶
func (a *ComposeApp) Uninstall(ctx context.Context, deleteConfigFolder bool) error
func (*ComposeApp) UpWithCheckRequire ¶
func (*ComposeApp) UpdateEventPropertiesFromStoreInfo ¶
func (a *ComposeApp) UpdateEventPropertiesFromStoreInfo(eventProperties map[string]string) error
Try to update AppIcon and AppTitle in given event properties from store info
type ComposeService ¶
type ComposeService struct {
// contains filtered or unexported fields
}
func NewComposeService ¶
func NewComposeService() *ComposeService
func (*ComposeService) Install ¶
func (s *ComposeService) Install(ctx context.Context, composeApp *ComposeApp) error
func (*ComposeService) IsInstalling ¶
func (s *ComposeService) IsInstalling(appName string) bool
func (*ComposeService) List ¶
func (s *ComposeService) List(ctx context.Context) (map[string]*ComposeApp, error)
func (*ComposeService) PrepareWorkingDirectory ¶
func (s *ComposeService) PrepareWorkingDirectory(name string) (string, error)
func (*ComposeService) Uninstall ¶
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 ¶
type PullOut ¶
type PullOut struct { Status StatusType `json:"status"` ProgressDetail ProgressDetail `json:"progressDetail"` Id string `json:"id"` }
type Services ¶
type Services interface { AppStoreManagement() *AppStoreManagement // Git() *GitService Compose() *ComposeService Docker() DockerService Gateway() external.ManagementService Notify() external.NotifyService MessageBus() *message_bus.ClientWithResponses }
var (
MyService Services
)
func NewService ¶
type StatusType ¶
type StatusType string
const ( Pull StatusType = "Pulling fs layer" PullComplete StatusType = "Pull complete" )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.