plan

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDiff

func FormatDiff(plan *Plan) string

FormatDiff formats the plan as a human-readable diff

Types

type ActionType

type ActionType string

ActionType represents the type of change needed

const (
	ActionCreate ActionType = "create"
	ActionUpdate ActionType = "update"
	ActionDelete ActionType = "delete"
	ActionNone   ActionType = "none"
)

type ConfigAction

type ConfigAction struct {
	Name     string
	Action   ActionType
	ConfigID string
	Labels   map[string]string
	Data     []byte // Only set for create/update
}

ConfigAction represents a planned change to a config

type CurrentState

type CurrentState struct {
	Services map[string]swarm.Service
	Networks map[string]swarm.Network
	Volumes  map[string]struct{} // Just names, volumes don't have full specs in swarm
	Configs  map[string]swarm.Config
	Secrets  map[string]swarm.Secret
}

CurrentState represents the current state of the stack in Swarm

type DesiredState

type DesiredState struct {
	Services map[string]*compose.Service
	Networks map[string]*compose.Network
	Volumes  map[string]*compose.Volume
	Configs  map[string]*compose.Config
	Secrets  map[string]*compose.Secret
}

DesiredState represents the desired state from compose file

func BuildDesiredState

func BuildDesiredState(composeFile *compose.ComposeFile) *DesiredState

BuildDesiredState creates DesiredState from a parsed compose file

type NetworkAction

type NetworkAction struct {
	Name      string
	Action    ActionType
	NetworkID string
	Driver    string
	Labels    map[string]string
}

NetworkAction represents a planned change to a network

type Plan

type Plan struct {
	StackName string

	// Resources (applied first, in order)
	Networks []NetworkAction
	Volumes  []VolumeAction
	Configs  []ConfigAction
	Secrets  []SecretAction

	// Services (applied after resources)
	Services []ServiceAction

	// Cleanup (applied last, only with --prune)
	OrphanedServices []string
	OrphanedNetworks []string
	OrphanedVolumes  []string
	OrphanedConfigs  []string
	OrphanedSecrets  []string
}

Plan represents the full deployment plan

func (*Plan) IsEmpty

func (p *Plan) IsEmpty() bool

IsEmpty returns true if the plan has no changes

type Planner

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

Planner creates deployment plans by comparing current and desired state

func NewPlanner

func NewPlanner(cli *client.Client, stackName string) *Planner

NewPlanner creates a new deployment planner

func (*Planner) CreatePlan

func (p *Planner) CreatePlan(ctx context.Context, current *CurrentState, desired *DesiredState) (*Plan, error)

CreatePlan compares current and desired state and creates a deployment plan

type SecretAction

type SecretAction struct {
	Name     string
	Action   ActionType
	SecretID string
	Labels   map[string]string
	Data     []byte // Only set for create/update
}

SecretAction represents a planned change to a secret

type ServiceAction

type ServiceAction struct {
	Name        string
	Action      ActionType
	CurrentSpec *swarm.ServiceSpec
	DesiredSpec *swarm.ServiceSpec
	CurrentMeta *swarm.Meta
	ServiceID   string
	Changes     []string // Human-readable list of changes
}

ServiceAction represents a planned change to a service

type VolumeAction

type VolumeAction struct {
	Name     string
	Action   ActionType
	VolumeID string
	Driver   string
	Labels   map[string]string
}

VolumeAction represents a planned change to a volume

Jump to

Keyboard shortcuts

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