instance

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: AGPL-3.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHelmfileService

func NewHelmfileService(logger *slog.Logger, stackService stackService, stackFolder string, classification string) helmfileService

func NewKubernetesService

func NewKubernetesService(config model.Cluster) (*kubernetesService, error)

func NewRepository

func NewRepository(db *gorm.DB, instanceParameterEncryptionKey string) *repository

func Routes

func Routes(r *gin.Engine, authenticator gin.HandlerFunc, handler Handler)

Types

type BackupObject

type BackupObject struct {
	Path         string
	Size         int64
	LastModified time.Time
	Err          error
}

BackupObject represents an object to be backed up

type BackupService

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

BackupService handles the backup operation

func NewBackupService

func NewBackupService(logger *slog.Logger, source BackupSource, s3Client S3BackupClient) *BackupService

NewBackupService creates a new backup service instance

func (*BackupService) PerformBackup

func (s *BackupService) PerformBackup(ctx context.Context, s3Bucket, key string) error

PerformBackup executes the backup operation

type BackupSource

type BackupSource interface {
	// List returns a channel of objects to back up
	List(ctx context.Context) (<-chan BackupObject, error)
	// Get returns a reader for a specific object
	Get(ctx context.Context, path string) (io.ReadCloser, error)
}

BackupSource defines a generic interface for backup sources

type BackupStats

type BackupStats struct {
	ObjectsProcessed int64
	BytesProcessed   int64
	StartTime        time.Time
	// contains filtered or unexported fields
}

BackupStats tracks backup operation statistics

type Category

type Category struct {
	Label     string           `json:"label"`
	Instances []PublicInstance `json:"instances"`
}

type ClusterResources

type ClusterResources struct {
	CPU        string
	Memory     string
	Autoscaled bool
	Nodes      int
}

func FindResources

func FindResources(cluster model.Cluster) (ClusterResources, error)

type GroupWithDeployments

type GroupWithDeployments struct {
	Name        string              `json:"name"`
	Hostname    string              `json:"hostname"`
	Deployments []*model.Deployment `json:"deployments"`
}

type GroupWithPublicInstances

type GroupWithPublicInstances struct {
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Categories  []Category `json:"categories"`
}

type Handler

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

func NewHandler

func NewHandler(stackService stack.Service, groupService groupServiceHandler, instanceService *Service, defaultTTL uint) Handler

func (Handler) DeleteDeployment

func (h Handler) DeleteDeployment(c *gin.Context)

DeleteDeployment deployment by id

func (Handler) DeleteDeploymentInstance

func (h Handler) DeleteDeploymentInstance(c *gin.Context)

DeleteDeploymentInstance delete deployment instance by id

func (Handler) DeployDeployment

func (h Handler) DeployDeployment(c *gin.Context)

func (Handler) FindDeploymentById

func (h Handler) FindDeploymentById(c *gin.Context)

FindDeploymentById deployment

func (Handler) FindDeployments

func (h Handler) FindDeployments(c *gin.Context)

FindDeployments deployments

func (Handler) FindPublicInstances

func (h Handler) FindPublicInstances(c *gin.Context)

FindPublicInstances list public available instances

func (Handler) InstanceWithDetails

func (h Handler) InstanceWithDetails(c *gin.Context)

InstanceWithDetails instance

func (Handler) Logs

func (h Handler) Logs(c *gin.Context)

Logs instance

func (Handler) Pause

func (h Handler) Pause(c *gin.Context)

Pause instance

func (Handler) Reset

func (h Handler) Reset(c *gin.Context)

Reset instance

func (Handler) Restart

func (h Handler) Restart(c *gin.Context)

Restart instance

func (Handler) Resume

func (h Handler) Resume(c *gin.Context)

Resume paused instance

func (Handler) SaveDeployment

func (h Handler) SaveDeployment(c *gin.Context)

func (Handler) SaveInstance

func (h Handler) SaveInstance(c *gin.Context)

func (Handler) Status

func (h Handler) Status(c *gin.Context)

Status returns the status of an instance

func (Handler) UpdateDeployment

func (h Handler) UpdateDeployment(c *gin.Context)

UpdateDeployment updates an existing Deployment's TTL and description

func (Handler) UpdateInstance

func (h Handler) UpdateInstance(c *gin.Context)

UpdateInstance updates an existing deployment instance

type InstanceStatus

type InstanceStatus string
const (
	NotDeployed        InstanceStatus = "NotDeployed"
	Pending            InstanceStatus = "Pending"
	Booting            InstanceStatus = "Booting"
	BootingWithRestart InstanceStatus = "Booting (%d)"
	Running            InstanceStatus = "Running"
	Error              InstanceStatus = "Error"
)

type MinioBackupSource

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

MinioBackupSource implements BackupSource for MinIO

func NewMinioBackupSource

func NewMinioBackupSource(logger *slog.Logger, client MinioClient, bucket string) *MinioBackupSource

func (*MinioBackupSource) Get

func (m *MinioBackupSource) Get(ctx context.Context, path string) (io.ReadCloser, error)

Get implements BackupSource interface

func (*MinioBackupSource) List

func (m *MinioBackupSource) List(ctx context.Context) (<-chan BackupObject, error)

List implements BackupSource interface

type MinioClient

type MinioClient interface {
	ListObjects(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo
	GetObject(ctx context.Context, bucketName, objectName string, opts minio.GetObjectOptions) (*minio.Object, error)
}

MinioClient defines the methods we need from MinIO client

type MinioRestoreClient

type MinioRestoreClient interface {
	PutObject(ctx context.Context, bucket string, name string, reader io.Reader, size int64, options minio.PutObjectOptions) (minio.UploadInfo, error)
	ListObjects(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo
	RemoveObjects(ctx context.Context, bucketName string, objectsCh <-chan minio.ObjectInfo, opts minio.RemoveObjectsOptions) <-chan minio.RemoveObjectError
}

type PublicInstance

type PublicInstance struct {
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Hostname    string    `json:"hostname"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

type RestoreService

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

func NewRestoreService

func NewRestoreService(logger *slog.Logger, minioClient MinioRestoreClient, s3Client S3RestoreClient) *RestoreService

func (*RestoreService) PerformPurge

func (s *RestoreService) PerformPurge(ctx context.Context, minioBucket string) error

func (*RestoreService) PerformRestore

func (s *RestoreService) PerformRestore(ctx context.Context, s3Bucket, s3Key, minioBucket string) error

type RestoreStats

type RestoreStats struct {
	ObjectsRestored int64
	BytesRestored   int64
	StartTime       time.Time
	// contains filtered or unexported fields
}

type S3BackupClient

type S3BackupClient interface {
	CreateMultipartUpload(ctx context.Context, params *s3.CreateMultipartUploadInput, optFns ...func(*s3.Options)) (*s3.CreateMultipartUploadOutput, error)
	UploadPart(ctx context.Context, params *s3.UploadPartInput, optFns ...func(*s3.Options)) (*s3.UploadPartOutput, error)
	CompleteMultipartUpload(ctx context.Context, params *s3.CompleteMultipartUploadInput, optFns ...func(*s3.Options)) (*s3.CompleteMultipartUploadOutput, error)
	AbortMultipartUpload(ctx context.Context, params *s3.AbortMultipartUploadInput, optFns ...func(*s3.Options)) (*s3.AbortMultipartUploadOutput, error)
}

S3BackupClient defines the methods we need from AWS S3 client

type S3RestoreClient

type S3RestoreClient interface {
	GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
}

type SaveDeploymentRequest

type SaveDeploymentRequest struct {
	Name        string `json:"name" binding:"required,dns_rfc1035_label"`
	Description string `json:"description"`
	Group       string `json:"group" binding:"required"`
	TTL         uint   `json:"ttl"`
}

type SaveInstanceRequest

type SaveInstanceRequest struct {
	StackName  string     `json:"stackName"`
	Parameters parameters `json:"parameters"`
	Public     bool       `json:"public"`
}

type Service

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

func NewService

func NewService(logger *slog.Logger, instanceRepository *repository, groupService groupService, stackService stack.Service, helmfileService helmfile, s3Client *s3.Client, s3Bucket string, tokenService *token.TokenService) *Service

func (Service) Delete

func (s Service) Delete(ctx context.Context, deploymentInstanceId uint) error

func (Service) DeleteDeployment

func (s Service) DeleteDeployment(ctx context.Context, deployment *model.Deployment) error

func (Service) DeleteInstance

func (s Service) DeleteInstance(ctx context.Context, deploymentId, instanceId uint) error

func (Service) DeployDeployment

func (s Service) DeployDeployment(ctx context.Context, token string, deployment *model.Deployment) error

func (Service) FilestoreBackup

func (s Service) FilestoreBackup(ctx context.Context, instance *model.DeploymentInstance, name string, database *model.Database) error

func (Service) FindAllDeployments

func (s Service) FindAllDeployments(ctx context.Context) ([]model.Deployment, error)

func (Service) FindDecryptedDeploymentById

func (s Service) FindDecryptedDeploymentById(ctx context.Context, id uint) (*model.Deployment, error)

func (Service) FindDecryptedDeploymentInstanceById

func (s Service) FindDecryptedDeploymentInstanceById(ctx context.Context, id uint) (*model.DeploymentInstance, error)

func (Service) FindDeploymentById

func (s Service) FindDeploymentById(ctx context.Context, id uint) (*model.Deployment, error)

func (Service) FindDeploymentInstanceById

func (s Service) FindDeploymentInstanceById(ctx context.Context, id uint) (*model.DeploymentInstance, error)

func (Service) FindDeployments

func (s Service) FindDeployments(ctx context.Context, user *model.User) ([]GroupWithDeployments, error)

func (Service) FindPublicInstances

func (s Service) FindPublicInstances(ctx context.Context) ([]GroupWithPublicInstances, error)

func (Service) GetStatus

func (s Service) GetStatus(instance *model.DeploymentInstance) (InstanceStatus, error)

func (Service) Logs

func (s Service) Logs(instance *model.DeploymentInstance, group *model.Group, typeSelector string) (io.ReadCloser, error)

func (Service) Pause

func (s Service) Pause(ctx context.Context, instance *model.DeploymentInstance) error

func (Service) Reset

func (s Service) Reset(ctx context.Context, token string, instance *model.DeploymentInstance, ttl uint) error

func (Service) Restart

func (s Service) Restart(ctx context.Context, instance *model.DeploymentInstance, typeSelector string) error

func (Service) Resume

func (s Service) Resume(ctx context.Context, instance *model.DeploymentInstance) error

func (Service) SaveDeployment

func (s Service) SaveDeployment(ctx context.Context, deployment *model.Deployment) error

func (Service) SaveInstance

func (s Service) SaveInstance(ctx context.Context, instance *model.DeploymentInstance) error

func (Service) UpdateDeployment

func (s Service) UpdateDeployment(ctx context.Context, token string, deploymentId uint, ttl uint, description string) (*model.Deployment, error)

func (Service) UpdateInstance

func (s Service) UpdateInstance(ctx context.Context, token string, deploymentId, instanceId uint, parameters parameters, public bool) (*model.DeploymentInstance, error)

type UpdateDeploymentRequest

type UpdateDeploymentRequest struct {
	TTL         uint   `json:"ttl"`
	Description string `json:"description"`
}

Jump to

Keyboard shortcuts

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