refactored
This commit is contained in:
62
instancemanager/instance_manager.go
Normal file
62
instancemanager/instance_manager.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package instancemanager
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"git.acooldomain.co/server-manager/backend/models"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
Id string
|
||||
Running bool
|
||||
RunningCommand string
|
||||
RunningImage *models.Image
|
||||
Ports []models.Port
|
||||
Domain string
|
||||
}
|
||||
|
||||
type Port struct {
|
||||
Number uint16
|
||||
Protocol models.PortProtocol
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
Registry string
|
||||
Tag string
|
||||
Command string
|
||||
WorkingDir string
|
||||
Ports []Port
|
||||
}
|
||||
|
||||
type InstanceManager interface {
|
||||
//General
|
||||
// Read Only
|
||||
GetImage(ctx context.Context, imageId string) (*Image, error)
|
||||
ListImages(ctx context.Context) ([]Image, error)
|
||||
GetServer(ctx context.Context, serverId string) (*Server, error)
|
||||
ListServers(ctx context.Context) ([]Server, error)
|
||||
|
||||
// State Changing
|
||||
StartServer(ctx context.Context, serverId string, imageId string, command string, ports []models.Port) error
|
||||
StopServer(ctx context.Context, serverId string) error
|
||||
|
||||
CreateServer(ctx context.Context) (*Server, error)
|
||||
DeleteServer(ctx context.Context, serverId string) error
|
||||
|
||||
// Terminal
|
||||
|
||||
// Status Changing
|
||||
InteractiveTerminal(ctx context.Context, serverId string) (*net.Conn, error)
|
||||
ResizeTerminal(ctx context.Context, serverId string, width uint, height uint) error
|
||||
|
||||
// File Browser
|
||||
|
||||
// Read Only
|
||||
GetFileBrowser(ctx context.Context, serverId string) (*models.FileBrowser, error)
|
||||
ListFileBrowsers(ctx context.Context) ([]models.FileBrowser, error)
|
||||
|
||||
// Status Changing
|
||||
StartFileBrowser(ctx context.Context, serverId string) (*models.FileBrowser, error)
|
||||
StopFileBrowser(ctx context.Context, serverId string) error
|
||||
}
|
||||
Reference in New Issue
Block a user