Files
vHost/backend/internal/panel/panel.go
T

135 lines
5.5 KiB
Go

package panel
import "context"
type SiteSpec struct {
Name, Domain, Path, RunPath, Runtime, Version, RunUser string
Port, ProcessLimit int
}
type ExistingSite struct {
ID int64 `json:"id"`
Domain string `json:"domain"`
Path string `json:"path"`
PHPVersion string `json:"phpVersion,omitempty"`
Status string `json:"status"`
}
type RuntimeSpec struct {
Runner bool
ProjectName, Runtime, Version, Path, RunPath, EntryFile, Domain string
RunUser string
Port, ProcessLimit int
}
// RuntimeCatalog uses the public runtime names accepted by project creation as
// keys. Values are the exact version identifiers returned by aaPanel.
type RuntimeCatalog map[string][]string
const (
RuntimeAvailable = "available"
RuntimeNotInstalled = "not_installed"
RuntimeProbeFailed = "probe_failed"
PolicyFreeCore = "free_core"
PolicyFreeProject = "free_project"
)
// RuntimeCapability records each language independently. A missing or broken
// optional project route must not prevent Sea vHost itself from being installed.
type RuntimeCapability struct {
Status string `json:"status"`
Versions []string `json:"versions"`
Policy string `json:"policy"`
Detail string `json:"detail,omitempty"`
}
type RuntimeCapabilities map[string]RuntimeCapability
const (
RuntimeComponentReady = "installed"
RuntimeComponentMissing = "not_installed"
RuntimeComponentFailed = "probe_failed"
)
// RuntimeEnvironment is the administrator-facing installation inventory. The
// install endpoints only accept versions present in Available; callers cannot
// pass package names, URLs, shell fragments, or arbitrary panel operations.
type RuntimeEnvironment struct {
Name string `json:"name"`
ComponentTitle string `json:"componentTitle"`
ComponentStatus string `json:"componentStatus"`
ComponentVersion string `json:"componentVersion,omitempty"`
ComponentLatestVersion string `json:"componentLatestVersion,omitempty"`
ComponentUpdateAvailable bool `json:"componentUpdateAvailable"`
ComponentInstallable bool `json:"componentInstallable"`
Installed []string `json:"installed"`
Available []string `json:"available"`
Installing []string `json:"installing"`
Recommended string `json:"recommended,omitempty"`
Detail string `json:"detail,omitempty"`
Patches []RuntimePatch `json:"patches,omitempty"`
}
type RuntimePatch struct {
Branch string `json:"branch"`
Installed string `json:"installed"`
Latest string `json:"latest"`
UpdateAvailable bool `json:"updateAvailable"`
}
// RuntimeMaintenance exposes only fixed PHP updates and existing managed
// runtime records. It is not a generic panel API proxy.
type ManagedCertificateIssuer interface {
IssueManagedCertificate(context.Context, int64, string, []string) (string, error)
ClearManagedCertificateOrder(context.Context, string) error
}
type RuntimeResetter interface {
ResetManagedRuntime(context.Context, int64, string) error
}
type RuntimeMaintenance interface {
UpdatePHPRuntime(context.Context, string, string) error
PHPRuntimeUpdatePending(context.Context, string) (bool, error)
ManagedRuntime(context.Context, int64) (RuntimeSpec, error)
ReplaceManagedRuntime(context.Context, int64, RuntimeSpec) error
}
type Interface interface {
Ping(context.Context) error
RuntimeCapabilities(context.Context) (RuntimeCapabilities, error)
RuntimeCatalog(context.Context) (RuntimeCatalog, error)
RuntimeEnvironments(context.Context) ([]RuntimeEnvironment, error)
InstallRuntimeComponent(context.Context, string) error
InstallRuntimeEnvironment(context.Context, string, string) error
CreateSite(context.Context, SiteSpec) (int64, error)
ListUnmanagedSites(context.Context) ([]ExistingSite, error)
AdoptSite(context.Context, int64, string, SiteSpec) error
RollbackAdoption(context.Context, int64, string, string) error
SetSitePath(context.Context, int64, string) error
DeleteSite(context.Context, int64, string) error
AddDomain(context.Context, int64, string, string) error
DeleteDomain(context.Context, int64, string, string) error
CreateFTP(context.Context, string, string, string, int64) (int64, error)
DeleteFTP(context.Context, int64, string) error
SetFTPState(context.Context, int64, string, bool) error
CreateDatabase(context.Context, string, string, string, int64) (int64, error)
DeleteDatabase(context.Context, int64, string) error
DatabaseSize(context.Context, int64, string) (uint64, error)
ConfigureRuntime(context.Context, RuntimeSpec) error
RemoveRuntime(context.Context, RuntimeSpec) error
SetRuntimeState(context.Context, RuntimeSpec, bool) error
ConfigureProxy(context.Context, int64, string, int) error
RequestCertificate(context.Context, int64, string, []string) error
InstallCertificate(context.Context, int64, string, string, string) error
DisableCertificate(context.Context, int64, string) error
SetSiteState(context.Context, int64, string, bool) error
SetSiteRunPath(context.Context, int64, string) error
MigrateRuntimeIdentity(context.Context, int64, string, bool) error
}
type CredentialManager interface {
SetFTPPassword(context.Context, int64, string, string) error
SetDatabasePassword(context.Context, int64, string, string) error
}