package isolation import "context" type ProjectSpec struct { TenantID uint64 `json:"tenantId"` HostName string `json:"hostName"` RunPath string `json:"runPath"` StorageBytes uint64 `json:"storageBytes"` ProcessLimit uint32 `json:"processLimit"` Databases []string `json:"databases,omitempty"` } type DatabaseAccessSpec struct { Project ProjectSpec `json:"project"` Database string `json:"database"` ReadOnly bool `json:"readOnly"` BlockCleanup bool `json:"blockCleanup,omitempty"` } type TrafficLimitSpec struct { Project ProjectSpec `json:"project"` Domains []string `json:"domains"` Mbps uint32 `json:"mbps"` } type Prepared struct { RootPath string `json:"rootPath"` RunUser string `json:"runUser"` } type FTPIdentitySpec struct { Project ProjectSpec `json:"project"` Username string `json:"username"` } type PHPIdentitySpec struct { Project ProjectSpec `json:"project"` SiteName string `json:"siteName"` Domain string `json:"domain"` Version string `json:"version"` ProcessLimit uint32 `json:"processLimit"` } type WebProtectionSpec struct { Project ProjectSpec `json:"project"` Domain string `json:"domain"` } type ExecutableSpec struct { Project ProjectSpec `json:"project"` RelativePath string `json:"relativePath"` } type PanelRuntimeSpec struct { Project ProjectSpec `json:"project"` Runtime string `json:"runtime"` Version string `json:"version,omitempty"` ProjectName string `json:"projectName,omitempty"` } type PythonRuntimeInstallSpec struct { Version string `json:"version"` } type RuntimeProcessSpec struct { Project ProjectSpec `json:"project"` } type ResourceUsageSpec struct { Project ProjectSpec `json:"project"` Domains []string `json:"domains"` } type ResourceUsage struct { MemoryBytes uint64 `json:"memoryBytes"` CPUTicks uint64 `json:"cpuTicks"` StorageBytes uint64 `json:"storageBytes"` BandwidthBytes uint64 `json:"bandwidthBytes"` ProcessCount uint32 `json:"processCount"` } type NginxNetworkSpec struct { Project ProjectSpec `json:"project"` Domain string `json:"domain"` IPAddress string `json:"ipAddress"` Dedicated bool `json:"dedicated"` HTTPPort int `json:"httpPort"` HTTPSPort int `json:"httpsPort"` } type ProjectBackup struct { TenantID uint64 `json:"tenantId"` HostName string `json:"hostName"` ArchivePath string `json:"archivePath,omitempty"` SizeBytes uint64 `json:"sizeBytes,omitempty"` DatabaseCount int `json:"databaseCount"` } type LegacyImportSpec struct { Project ProjectSpec `json:"project"` SourcePath string `json:"sourcePath"` } type Interface interface { Prepare(context.Context, ProjectSpec) (Prepared, error) Quarantine(context.Context, ProjectSpec) error ApplyWebProtection(context.Context, WebProtectionSpec) error RemoveWebProtection(context.Context, WebProtectionSpec) error PrepareExecutable(context.Context, ExecutableSpec) error PreparePanelRuntime(context.Context, PanelRuntimeSpec) error InstallPythonRuntime(context.Context, string) error TerminateRuntime(context.Context, RuntimeProcessSpec) error ReleaseRunPath(context.Context, ProjectSpec) error PrepareTrash(context.Context, ProjectSpec) error ConfigureFTPIdentity(context.Context, FTPIdentitySpec) error ConfigurePHPIdentity(context.Context, PHPIdentitySpec) error SetPHPIdentityState(context.Context, PHPIdentitySpec, bool) error RemovePHPIdentity(context.Context, PHPIdentitySpec) error ResourceUsage(context.Context, ResourceUsageSpec) (ResourceUsage, error) TerminateProcesses(context.Context, ProjectSpec) error FreezeWrites(context.Context, ProjectSpec) error ConfigureDatabaseAccess(context.Context, DatabaseAccessSpec) error ConfigureTrafficLimits(context.Context, TrafficLimitSpec) error ConfigureFTPTLS(context.Context, string) (string, error) ConfigureNginxNetwork(context.Context, NginxNetworkSpec) error CreateProjectBackup(context.Context, ProjectSpec) (ProjectBackup, error) DeleteProjectBackup(context.Context, ProjectBackup) error VerifyProjectBackup(context.Context, ProjectBackup) error PurgeProject(context.Context, ProjectSpec) error ImportLegacyProject(context.Context, LegacyImportSpec) error } type Mock struct{ Root string } func (m Mock) Prepare(_ context.Context, spec ProjectSpec) (Prepared, error) { return Prepared{RootPath: m.Root + "/" + spec.HostName, RunUser: spec.HostName}, nil } func (Mock) Quarantine(context.Context, ProjectSpec) error { return nil } func (Mock) ApplyWebProtection(context.Context, WebProtectionSpec) error { return nil } func (Mock) RemoveWebProtection(context.Context, WebProtectionSpec) error { return nil } func (Mock) PrepareExecutable(context.Context, ExecutableSpec) error { return nil } func (Mock) PreparePanelRuntime(context.Context, PanelRuntimeSpec) error { return nil } func (Mock) InstallPythonRuntime(context.Context, string) error { return nil } func (Mock) TerminateRuntime(context.Context, RuntimeProcessSpec) error { return nil } func (Mock) ReleaseRunPath(context.Context, ProjectSpec) error { return nil } func (Mock) PrepareTrash(context.Context, ProjectSpec) error { return nil } func (Mock) ConfigureFTPIdentity(context.Context, FTPIdentitySpec) error { return nil } func (Mock) ConfigurePHPIdentity(context.Context, PHPIdentitySpec) error { return nil } func (Mock) SetPHPIdentityState(context.Context, PHPIdentitySpec, bool) error { return nil } func (Mock) RemovePHPIdentity(context.Context, PHPIdentitySpec) error { return nil } func (Mock) ResourceUsage(context.Context, ResourceUsageSpec) (ResourceUsage, error) { return ResourceUsage{}, nil } func (Mock) TerminateProcesses(context.Context, ProjectSpec) error { return nil } func (Mock) FreezeWrites(context.Context, ProjectSpec) error { return nil } func (Mock) ConfigureDatabaseAccess(context.Context, DatabaseAccessSpec) error { return nil } func (Mock) ConfigureTrafficLimits(context.Context, TrafficLimitSpec) error { return nil } func (Mock) ConfigureFTPTLS(context.Context, string) (string, error) { return "plain_allowed_no_certificate", nil } func (Mock) ConfigureNginxNetwork(context.Context, NginxNetworkSpec) error { return nil } func (Mock) CreateProjectBackup(_ context.Context, spec ProjectSpec) (ProjectBackup, error) { return ProjectBackup{TenantID: spec.TenantID, HostName: spec.HostName, ArchivePath: "/tmp/sea-vhost-backup.full.tar.gz", DatabaseCount: len(spec.Databases)}, nil } func (Mock) DeleteProjectBackup(context.Context, ProjectBackup) error { return nil } func (Mock) VerifyProjectBackup(context.Context, ProjectBackup) error { return nil } func (Mock) PurgeProject(context.Context, ProjectSpec) error { return nil } func (Mock) ImportLegacyProject(context.Context, LegacyImportSpec) error { return nil }