app

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessControl

type AccessControl interface {
	CheckAccess(userID, tenantID, resource, action string) bool
	LogAccess(userID, tenantID, resource, action, details string)
	GetAuditLogs() []AppAuditLogEntry
	GetTenantAuditLogs(tenantID string) []AppAuditLogEntry
	GetAppAuditLogs(appID string) []AppAuditLogEntry
}

AccessControl handles access control for applications

type App

type App struct {
	ID        string
	Name      string
	Image     string
	Command   []string
	Env       map[string]string
	Volumes   []string
	Ports     map[string]string
	Resources ResourceRequirements
	State     AppState
	NodeID    string
	CreatedAt time.Time
	StartedAt *time.Time
	StoppedAt *time.Time
	TenantID  string
	UserID    string
	Metadata  map[string]string
}

App represents an application in the system

type AppAuditLogEntry

type AppAuditLogEntry struct {
	Timestamp int64
	Action    string
	UserID    string
	TenantID  string
	AppID     string
	Details   string
}

AppAuditLogEntry represents an entry in the application audit log

type AppFilter

type AppFilter struct {
	TenantID string
	UserID   string
	State    AppState
	NodeID   string
}

AppFilter represents a filter for listing applications

type AppOptions

type AppOptions struct {
	Name      string
	Image     string
	Command   []string
	Env       map[string]string
	Volumes   []string
	Ports     map[string]string
	Resources ResourceRequirements
	TenantID  string
	UserID    string
	Metadata  map[string]string
}

AppOptions represents options for creating an application

type AppState

type AppState string

AppState represents the state of an application

const (
	// AppStatePending indicates the application is pending
	AppStatePending AppState = "pending"
	// AppStateRunning indicates the application is running
	AppStateRunning AppState = "running"
	// AppStateStopped indicates the application is stopped
	AppStateStopped AppState = "stopped"
	// AppStateFailed indicates the application has failed
	AppStateFailed AppState = "failed"
)

type AppStatus

type AppStatus struct {
	ID           string
	Name         string
	Image        string
	Command      []string
	Env          map[string]string
	Volumes      []string
	Ports        map[string]string
	Resources    ResourceRequirements
	State        AppState
	NodeID       string
	CreatedAt    int64
	StartedAt    int64
	FinishedAt   int64
	RestartCount int
	ExitCode     int
	TenantID     string
	UserID       string
}

AppStatus represents the status of an application

type ContainerManager

type ContainerManager interface {
	CreateContainer(ctx context.Context, name, image string, command []string, env map[string]string, volumes []string, ports map[string]string) (string, error)
	StartContainer(ctx context.Context, id string) error
	StopContainer(ctx context.Context, id string) error
	RemoveContainer(ctx context.Context, id string) error
	GetContainerStatus(ctx context.Context, id string) (string, error)
	GetContainerLogs(ctx context.Context, id string) (string, error)
	ExecInContainer(ctx context.Context, id string, command []string) (string, error)
	ListContainers(ctx context.Context) ([]api.Container, error)
}

ContainerManager handles container operations

type DeploymentStatus

type DeploymentStatus struct {
	ID        string
	Status    string
	Progress  int
	Details   string
	CreatedAt time.Time
	UpdatedAt time.Time
	Completed bool
	Success   bool
}

DeploymentStatus represents the status of a deployment

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles application operations

func NewManager

func NewManager(dataDir string, logger *logrus.Logger) (*Manager, error)

NewManager creates a new application manager

func (*Manager) Close

func (m *Manager) Close() error

Close closes the application manager

func (*Manager) CreateApp

func (m *Manager) CreateApp(ctx context.Context, options AppOptions) (*AppStatus, error)

CreateApp creates a new application

func (*Manager) CreateTenant

func (m *Manager) CreateTenant(ctx context.Context, name, description, owner string) (*Tenant, error)

CreateTenant creates a new tenant

func (*Manager) DeleteApp

func (m *Manager) DeleteApp(id string) error

DeleteApp deletes an application from the database

func (*Manager) DeleteAppWithOptions

func (m *Manager) DeleteAppWithOptions(ctx context.Context, id, userID, tenantID string) error

DeleteAppWithOptions deletes an application with options

func (*Manager) DeleteTenant

func (m *Manager) DeleteTenant(ctx context.Context, id string) error

DeleteTenant deletes a tenant

func (*Manager) DeployApp

func (m *Manager) DeployApp(ctx context.Context, image, name, service string, volumes []string, env map[string]string) (string, error)

DeployApp deploys a new application

func (*Manager) ExecInApp

func (m *Manager) ExecInApp(ctx context.Context, id string, command []string, userID, tenantID string) (string, error)

ExecInApp executes a command in an application

func (*Manager) GetAppAuditLogs

func (m *Manager) GetAppAuditLogs(appID string) []AppAuditLogEntry

GetAppAuditLogs returns audit logs for an application

func (*Manager) GetAppLogs

func (m *Manager) GetAppLogs(ctx context.Context, id, userID, tenantID string) (string, error)

GetAppLogs returns the logs of an application

func (*Manager) GetAppStatus

func (m *Manager) GetAppStatus(id string) (*AppStatus, error)

GetAppStatus returns the status of an application

func (*Manager) GetApps

func (m *Manager) GetApps() ([]*AppStatus, error)

GetApps returns all applications

func (*Manager) GetAppsByFilter

func (m *Manager) GetAppsByFilter(filter AppFilter) ([]*AppStatus, error)

GetAppsByFilter returns applications filtered by criteria

func (*Manager) GetContainerByID

func (m *Manager) GetContainerByID(ctx context.Context, containerID string) (api.Container, error)

GetContainerByID returns a container by its ID

func (*Manager) GetContainersByNode

func (m *Manager) GetContainersByNode(ctx context.Context, nodeID string) ([]api.Container, error)

GetContainersByNode returns containers for a specific node

func (*Manager) GetDeploymentStatus

func (m *Manager) GetDeploymentStatus(ctx context.Context, deploymentID string) (*DeploymentStatus, error)

GetDeploymentStatus returns the status of a deployment

func (*Manager) GetService

func (m *Manager) GetService(ctx context.Context, name string) (*Service, error)

GetService returns a service by its name

func (*Manager) GetTenant

func (m *Manager) GetTenant(ctx context.Context, id string) (*Tenant, error)

GetTenant returns a tenant by ID

func (*Manager) GetTenantAppStats

func (m *Manager) GetTenantAppStats(tenantID string) (*TenantAppStats, error)

GetTenantAppStats returns application statistics for a tenant

func (*Manager) ListServices

func (m *Manager) ListServices(ctx context.Context) ([]*Service, error)

ListServices returns a list of services

func (*Manager) ListTenants

func (m *Manager) ListTenants(ctx context.Context) ([]Tenant, error)

ListTenants returns a list of tenants

func (*Manager) MonitorAppHealth

func (m *Manager) MonitorAppHealth(ctx context.Context, id string) error

MonitorAppHealth monitors the health of an application

func (*Manager) RestartApp

func (m *Manager) RestartApp(ctx context.Context, id, userID, tenantID string) error

RestartApp restarts an application

func (*Manager) RestartAppSimple

func (m *Manager) RestartAppSimple(ctx context.Context, id string) error

RestartAppSimple restarts an application without requiring user and tenant IDs

func (*Manager) RollbackDeployment

func (m *Manager) RollbackDeployment(ctx context.Context, deploymentID string) error

RollbackDeployment rolls back a deployment

func (*Manager) SaveApp

func (m *Manager) SaveApp(app *AppStatus) error

SaveApp saves application information to the database

func (*Manager) ScaleApp

func (m *Manager) ScaleApp(ctx context.Context, id string, replicas int, userID ...string) error

ScaleApp scales an application

func (*Manager) ScaleAppWithTenant

func (m *Manager) ScaleAppWithTenant(ctx context.Context, id string, replicas int, userID, tenantID string) error

ScaleAppWithTenant scales an application with tenant information

func (*Manager) StartApp

func (m *Manager) StartApp(ctx context.Context, id, userID, tenantID string) error

StartApp starts an application

func (*Manager) StartAppHealthMonitoring

func (m *Manager) StartAppHealthMonitoring(ctx context.Context, interval time.Duration)

StartAppHealthMonitoring starts monitoring the health of all applications

func (*Manager) StopApp

func (m *Manager) StopApp(ctx context.Context, id, userID, tenantID string) error

StopApp stops an application

func (*Manager) UpdateApp

func (m *Manager) UpdateApp(ctx context.Context, id string, options AppOptions, userID, tenantID string) (*AppStatus, error)

UpdateApp updates an application

func (*Manager) UpdateAppExitCode

func (m *Manager) UpdateAppExitCode(id string, exitCode int) error

UpdateAppExitCode updates the exit code of an application

func (*Manager) UpdateAppNodeID

func (m *Manager) UpdateAppNodeID(id, nodeID string) error

UpdateAppNodeID updates the node ID of an application

func (*Manager) UpdateAppRestartCount

func (m *Manager) UpdateAppRestartCount(id string, restartCount int) error

UpdateAppRestartCount updates the restart count of an application

func (*Manager) UpdateAppState

func (m *Manager) UpdateAppState(id string, state AppState) error

UpdateAppState updates the state of an application

func (*Manager) UpdateTenant

func (m *Manager) UpdateTenant(ctx context.Context, id, name, status string) (*Tenant, error)

UpdateTenant updates a tenant

func (*Manager) WithAccessControl

func (m *Manager) WithAccessControl(accessControl AccessControl) *Manager

WithAccessControl sets the access control

func (*Manager) WithContainerManager

func (m *Manager) WithContainerManager(containerManager ContainerManager) *Manager

WithContainerManager sets the container manager

func (*Manager) WithNetworkManager

func (m *Manager) WithNetworkManager(networkManager NetworkManager) *Manager

WithNetworkManager sets the network manager

func (*Manager) WithStorageManager

func (m *Manager) WithStorageManager(storageManager StorageManager) *Manager

WithStorageManager sets the storage manager

func (*Manager) WithTenantManager

func (m *Manager) WithTenantManager(tenantManager interface{}) *Manager

WithTenantManager sets the tenant manager

func (*Manager) ZeroDowntimeDeploy

func (m *Manager) ZeroDowntimeDeploy(ctx context.Context, name, image, service string) (string, error)

ZeroDowntimeDeploy deploys a new version of a service with zero downtime

type NetworkManager

type NetworkManager interface {
	CreateNetwork(ctx context.Context, name string) (string, error)
	DeleteNetwork(ctx context.Context, id string) error
	ConnectContainerToNetwork(ctx context.Context, containerID, networkID string) error
	DisconnectContainerFromNetwork(ctx context.Context, containerID, networkID string) error
}

NetworkManager handles network operations

type ResourceRequirements

type ResourceRequirements struct {
	CPU    float64
	Memory int64
	GPU    int
	Disk   int64
}

ResourceRequirements represents the resource requirements of an application

type Service

type Service struct {
	ID           string
	Name         string
	Image        string
	Command      []string
	Env          map[string]string
	Volumes      []string
	Ports        map[string]string
	Resources    ResourceRequirements
	Replicas     int
	TenantID     string
	UserID       string
	CreatedAt    int64
	UpdatedAt    int64
	State        AppState
	Metadata     map[string]string
	Domain       string
	ContainerIDs []string
}

Service represents a service in the application

type StorageManager

type StorageManager interface {
	CreateVolume(ctx context.Context, options interface{}) (interface{}, error)
	DeleteVolume(ctx context.Context, name string) error
	MountVolume(ctx context.Context, volumeName, containerID, mountPath string) error
	UnmountVolume(ctx context.Context, volumeName, containerID string) error
	ListVolumes(ctx context.Context) ([]interface{}, error)
	CreateVolumeSimple(ctx context.Context, name string, size int64) (interface{}, error)
}

StorageManager handles storage operations

type Tenant

type Tenant struct {
	ID          string
	Name        string
	Description string
	CreatedAt   int64
	UpdatedAt   int64
	Status      string
	Owner       string
	Quota       ResourceRequirements
	UsedQuota   ResourceRequirements
}

Tenant represents a tenant in the system

type TenantAppStats

type TenantAppStats struct {
	TenantID     string
	AppCount     int
	RunningCount int
	FailedCount  int
	TotalCPU     float64
	TotalMemory  int64
	TotalGPU     int
	TotalDisk    int64
}

TenantAppStats represents application statistics for a tenant

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL