Documentation
¶
Overview ¶
Package templateupgrade plans a guarded upgrade of a deployed catalog template. It is pure: callers parse the stored and catalog compose bodies, the planner returns a JSON-serializable Plan and never touches a runtime, a store or a secret value.
Index ¶
Constants ¶
const ( EnvAdd = "add" EnvRemove = "remove" EnvUpdate = "update" EnvKeepUser = "keep_user" )
Env actions. Values are never reported, only names.
const ( KindPatch = "patch" KindMinor = "minor" KindMajor = "major" KindDowngrade = "downgrade" KindChanged = "changed" KindNew = "new" KindRemoved = "removed" )
Image change kinds.
const ( ServiceUnchanged = "unchanged" ServiceChanged = "changed" ServiceAdded = "added" ServiceRemoved = "removed" )
Service statuses in a Plan.
const ( BlockerVolumeRemoved = "volume_removed" BlockerVolumeRetargeted = "volume_retargeted" BlockerServiceRemoved = "service_removed_with_data" )
Blocker codes: any blocker stops an automatic upgrade.
const ( VolumeAdd = "add" VolumeRemove = "remove" VolumeRetarget = "retarget" PortAdd = "add" PortRemove = "remove" ReasonRemoved = "named volume no longer in the template" ReasonRetargets = "named volume mounted at a different path" )
Volume and port actions.
Variables ¶
var ErrUserServices = errors.New("the app has services that are not part of the template")
ErrUserServices means the installed file has services the template never had; applying the catalog body would delete them.
Functions ¶
Types ¶
type Blocker ¶
type Blocker struct {
Code string `json:"code"`
Service string `json:"service"`
Detail string `json:"detail"`
}
Blocker is one reason an upgrade must not run unattended.
type EnvChange ¶
type EnvChange struct {
Name string `json:"name"`
Action string `json:"action"`
Generated bool `json:"generated,omitempty"`
Required bool `json:"required,omitempty"`
}
EnvChange is one variable's planned fate. Generated marks a value the platform creates (a magic variable), Required one the template leaves empty for the operator.
type HealthcheckChange ¶
type HealthcheckChange struct {
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Preserved bool `json:"preserved,omitempty"`
}
HealthcheckChange summarizes a probe change; Preserved means the user already edited it away from the baseline.
type ImageChange ¶
type ImageChange struct {
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Kind string `json:"kind"`
Preserved bool `json:"preserved,omitempty"`
}
ImageChange is one service's image move. Preserved means the installed tag differs from the baseline, so the user pinned it and the executor leaves it alone.
type Input ¶
type Input struct {
AppID string
TemplateID string
Installed *compose.File
Baseline *compose.File
Template *compose.File
}
Input is everything the planner reads. Baseline is optional: the compose body of the first template revision of the app. With it, a value that differs from the baseline is a user edit; without it every value that differs from the catalog is treated as one.
type Plan ¶
type Plan struct {
AppID string `json:"app_id"`
TemplateID string `json:"template_id"`
FromVersion string `json:"from_version"`
ToVersion string `json:"to_version"`
Risk Risk `json:"risk"`
HasChanges bool `json:"has_changes"`
Automatic bool `json:"automatic"`
Blockers []Blocker `json:"blockers"`
Services []ServicePlan `json:"services"`
}
Plan is the upgrade a later executor may apply: back up first, apply Services in order, roll back on failure. It carries names and tags only, never environment values.
type PortChange ¶
type PortChange struct {
Port int `json:"port"`
Protocol string `json:"protocol,omitempty"`
Action string `json:"action"`
}
PortChange is a published or container port the template adds or drops.
type ServicePlan ¶
type ServicePlan struct {
Name string `json:"name"`
Status string `json:"status"`
Image *ImageChange `json:"image,omitempty"`
Env []EnvChange `json:"env,omitempty"`
Volumes []VolumeChange `json:"volumes,omitempty"`
Ports []PortChange `json:"ports,omitempty"`
Healthcheck *HealthcheckChange `json:"healthcheck,omitempty"`
}
ServicePlan is the change set for one service key.