Documentation
¶
Overview ¶
Package stack groups apps organizationally; deleting a stack detaches its apps, which keep running.
Index ¶
- Variables
- type Action
- type AppActionResult
- type AppService
- type DeployResult
- type ImportPlacement
- type ImportResult
- type ImportSkip
- type Input
- type NetworkManager
- type PortConflict
- type PortRequester
- type Service
- func (s *Service) AddApp(workspaceID, stackID, appID uint) (*models.Stack, error)
- func (s *Service) AggregateStatus(stackID uint) (StatusCounts, error)
- func (s *Service) AppCount(stackID uint) (int64, error)
- func (s *Service) Create(ctx context.Context, workspaceID uint, in Input) (*models.Stack, error)
- func (s *Service) Delete(ctx context.Context, workspaceID, id uint, withApps bool) error
- func (s *Service) DeleteEnvVar(workspaceID, stackID uint, key string) (int, error)
- func (s *Service) DeployAll(workspaceID, stackID uint) ([]DeployResult, error)
- func (s *Service) DeployOutdated(workspaceID, stackID uint) ([]DeployResult, error)
- func (s *Service) Events(workspaceID, stackID uint, limit int) ([]models.AppEvent, error)
- func (s *Service) Get(workspaceID, id uint) (*models.Stack, error)
- func (s *Service) IDByUID(uid string) (uint, error)
- func (s *Service) ImportCompose(ctx context.Context, workspaceID, userID uint, name, composeYAML string, ...) (*ImportResult, error)
- func (s *Service) ImportEnvVars(workspaceID, stackID uint, content string, isSecret bool) (imported, stale int, err error)
- func (s *Service) Lifecycle(ctx context.Context, workspaceID, stackID uint, action Action, rolling bool) ([]AppActionResult, error)
- func (s *Service) List(workspaceID uint) ([]models.Stack, error)
- func (s *Service) ListEnvVars(workspaceID, stackID uint) ([]models.StackEnvVar, error)
- func (s *Service) Reencrypt(ctx context.Context, workspaceID uint) (int, error)
- func (s *Service) RemoveApp(workspaceID, stackID, appID uint) (*models.Stack, error)
- func (s *Service) RevealEnvVar(workspaceID, stackID uint, key string) (string, error)
- func (s *Service) SetAllocator(a *netalloc.Service)
- func (s *Service) SetEnvVar(workspaceID, stackID uint, key, value string, isSecret bool) (int, error)
- func (s *Service) Update(workspaceID, id uint, in UpdateInput) (*models.Stack, error)
- type StatusCounts
- type UpdateInput
- type VolumeCreator
Constants ¶
This section is empty.
Variables ¶
var ( ErrNameRequired = errors.New("stack name is required") ErrNameTaken = errors.New("a stack with this name already exists") // The name derives DockerName, network and volumes, and GitOps matches on it; use DisplayName for a label. ErrNameImmutable = errors.New("a stack's name cannot be changed; edit its display name instead") ErrNotFound = errors.New("stack not found") ErrAppNotFound = errors.New("application not found in workspace") ErrAppInOtherStack = errors.New("application already belongs to another stack") ErrInvalidAction = errors.New("invalid stack action") ErrKeyRequired = errors.New("environment variable key is required") ErrEnvVarNotFound = errors.New("environment variable not found") )
var ErrComposeInvalid = errors.New("invalid docker-compose content")
Functions ¶
This section is empty.
Types ¶
type AppActionResult ¶
type AppService ¶
type AppService interface {
Start(ctx context.Context, app *models.Application) (*models.Deployment, error)
Stop(ctx context.Context, app *models.Application) error
Restart(ctx context.Context, app *models.Application) (*models.Deployment, error)
WaitRunning(ctx context.Context, app *models.Application) error
Deploy(app *models.Application, registryOverride *uint, tagOverride string, strategy models.DeployStrategy) (*models.Deployment, error)
MarkRedeployRequired(app *models.Application) (bool, error)
Delete(ctx context.Context, app *models.Application) error
Create(workspaceID uint, in application.CreateInput) (*models.Application, error)
SetEnvVar(appID uint, key, value string, isSecret bool) error
AttachVolume(app *models.Application, volumeID uint, path string) error
}
An interface keeps the stack service unit-testable with a fake.
type DeployResult ¶
type DeployResult struct {
AppID uint `json:"app_id"`
AppName string `json:"app_name"`
Status string `json:"status"` // queued | failed
DeploymentID uint `json:"deployment_id,omitempty"`
Error string `json:"error,omitempty"`
}
DeployResult reports the outcome of a deploy for one member app.
type ImportPlacement ¶ added in v1.10.8
ImportPlacement is where an imported stack runs: its location and the single node its apps and volumes share.
type ImportResult ¶
type ImportResult struct {
Stack *models.Stack `json:"stack"`
Created []string `json:"created"`
Volumes []string `json:"volumes"`
PortRequests int `json:"port_requests"`
PortConflicts []PortConflict `json:"port_conflicts"`
Skipped []ImportSkip `json:"skipped"`
}
ImportResult summarizes a compose import.
type ImportSkip ¶
ImportSkip records a service that could not be imported.
type Input ¶
type Input struct {
Name string
DisplayName string
Description string
// Callers may set reserved "miabi.io/" provenance keys; a missing managed-by defaults to "user".
Metadata models.Metadata
Annotations models.Metadata
// ClusterID is the location the stack's members run in; 0 is the default cluster.
ClusterID uint
}
type NetworkManager ¶
type PortConflict ¶
type PortConflict struct {
Service string `json:"service"`
HostPort int `json:"host_port"`
Protocol string `json:"protocol"`
UsedBy string `json:"used_by"`
}
The binding is filed pending so the stack still imports cleanly.
type PortRequester ¶
type PortRequester interface {
Request(workspaceID, userID uint, in portbinding.RequestInput) (*models.PortBinding, error)
RequestImport(workspaceID, userID uint, in portbinding.RequestInput) (*models.PortBinding, string, error)
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo *repositories.StackRepository, apps *repositories.ApplicationRepository, env *repositories.StackEnvVarRepository, events *repositories.AppEventRepository, app AppService, volumes VolumeCreator, docker NetworkManager, ports PortRequester) *Service
func (*Service) AddApp ¶
An app already in a different stack is rejected rather than silently moved.
func (*Service) AggregateStatus ¶
func (s *Service) AggregateStatus(stackID uint) (StatusCounts, error)
AggregateStatus summarizes the statuses of a stack's member apps.
func (*Service) DeleteEnvVar ¶
func (*Service) DeployAll ¶
func (s *Service) DeployAll(workspaceID, stackID uint) ([]DeployResult, error)
func (*Service) DeployOutdated ¶ added in v1.9.5
func (s *Service) DeployOutdated(workspaceID, stackID uint) ([]DeployResult, error)
DeployOutdated leaves current and never-deployed apps alone, rather than restarting the whole stack.
func (*Service) ImportCompose ¶
func (s *Service) ImportCompose(ctx context.Context, workspaceID, userID uint, name, composeYAML string, at ImportPlacement) (*ImportResult, error)
func (*Service) ImportEnvVars ¶
func (*Service) Lifecycle ¶
func (s *Service) Lifecycle(ctx context.Context, workspaceID, stackID uint, action Action, rolling bool) ([]AppActionResult, error)
Lifecycle is best-effort per app; with rolling, each app runs before the next so the stack never fully stops.
func (*Service) ListEnvVars ¶
func (s *Service) ListEnvVars(workspaceID, stackID uint) ([]models.StackEnvVar, error)
func (*Service) RevealEnvVar ¶ added in v1.9.5
Reading plaintext is gated to workspace admins by the route and audited by the handler.
func (*Service) SetAllocator ¶
Nil falls back to Docker's default address pool.
type StatusCounts ¶
type StatusCounts struct {
Total int `json:"total"`
Running int `json:"running"`
Stopped int `json:"stopped"`
Failed int `json:"failed"`
Other int `json:"other"`
}
StatusCounts is an aggregate of member-app statuses for the health badge.