Documentation
¶
Overview ¶
Package migrationplan turns a read of another platform into a reviewable plan: a per-item verdict, what would be created, and typed fixes.
Index ¶
- Constants
- Variables
- func StatCommand(dir string) string
- func VerifyData(dbs []DatabaseResult, wantVolumes []string, stats []VolumeStat) (evidence, problems []string)
- func VolumeStatCommand(volume string) string
- type Checklist
- type DatabaseResult
- type Fix
- type Item
- type Options
- type Override
- type Preview
- type Report
- type StepState
- type Verdict
- type VolumeCheck
- type VolumeInfo
- type VolumeStat
Constants ¶
const ( StepImported = "imported" StepDataVerified = "data_verified" StepShadowRunning = "shadow_running" StepDNSSwitched = "dns_switched" StepOldStopped = "old_stopped" )
Cutover checklist steps, in the only order they can be completed.
const ( StatusPending = "pending" StatusDone = "done" )
Step statuses.
const ( FixAuto = "auto" FixGuided = "guided" FixValidate = "validate" )
Fix kinds: auto is applied by the control plane through an override, guided sends the operator to the page that does it, validate re-checks.
const ( FixRename = "rename" FixSetPort = "set_port" FixHoldDomains = "hold_domains" FixCheckDNS = "check_dns" FixCopyData = "copy_data" FixCopyVolumes = "copy_volumes" FixUseTemplate = "use_template" FixConnectRepo = "connect_repo" FixDeployFile = "deploy_compose" )
Fix codes the dashboard maps to a button and copy.
Variables ¶
var ( ErrUnknownStep = errors.New("unknown checklist step") ErrStepBlocked = errors.New("an earlier step is not done") ErrStepNotDone = errors.New("step is not done") ErrAlreadyDone = errors.New("step is already done") ErrBadChecklist = errors.New("stored checklist is not valid") )
Transition errors.
var Steps = []string{StepImported, StepDataVerified, StepShadowRunning, StepDNSSwitched, StepOldStopped}
Steps is the checklist order.
Functions ¶
func StatCommand ¶
StatCommand prints "files bytes" for a directory, for the operator to run on the source and on the target and paste back.
func VerifyData ¶
func VerifyData(dbs []DatabaseResult, wantVolumes []string, stats []VolumeStat) (evidence, problems []string)
VerifyData decides the data_verified step. wantVolumes lists the app's volume names that need a stat; it returns the evidence lines and the reasons it cannot pass.
func VolumeStatCommand ¶
VolumeStatCommand is StatCommand for a named Docker volume on this host.
Types ¶
type Checklist ¶
Checklist is the per-app state machine. Zero value has every step pending.
func (Checklist) Current ¶
Current is the first step not done, or "" when the migration is finished.
type DatabaseResult ¶
type DatabaseResult struct {
Name string `json:"name"`
Status string `json:"status"`
Checked int `json:"checked"`
Mismatched int `json:"mismatched"`
Found bool `json:"found"`
}
DatabaseResult is a database copy's recorded verification.
type Fix ¶
type Fix struct {
Code string `json:"code"`
Kind string `json:"kind"`
// Detail carries a value the button needs, such as a suggested name or search term.
Detail string `json:"detail,omitempty"`
}
Fix is one way to clear a blocker.
type Item ¶
type Item struct {
Kind string `json:"kind"`
SourceID string `json:"source_id"`
Name string `json:"name"`
Target string `json:"target,omitempty"`
Project string `json:"project,omitempty"`
Environment string `json:"environment,omitempty"`
Server string `json:"server,omitempty"`
Source string `json:"source,omitempty"`
Verdict Verdict `json:"verdict"`
Reasons []string `json:"reasons,omitempty"`
Manual []string `json:"manual,omitempty"`
Domains []string `json:"domains,omitempty"`
Port int `json:"port,omitempty"`
EnvCount int `json:"env_count"`
Volumes []VolumeInfo `json:"volumes,omitempty"`
Crons []string `json:"crons,omitempty"`
Fixes []Fix `json:"fixes,omitempty"`
Preview *Preview `json:"preview,omitempty"`
}
Item is one row of the plan report.
type Options ¶
type Options struct {
Plan platformimport.PlanOptions
// TakenDomains maps a domain already routed on this control plane to its app.
TakenDomains map[string]string
Overrides map[string]Override
}
Options steer Analyze.
type Override ¶
type Override struct {
Name string `json:"name,omitempty"`
Port int `json:"port,omitempty"`
DropDomains bool `json:"drop_domains,omitempty"`
}
Override is a per-item change the operator chose, usually from a Fix.
type Preview ¶
type Preview struct {
Name string `json:"name"`
Image string `json:"image,omitempty"`
Engine string `json:"engine,omitempty"`
Version string `json:"version,omitempty"`
Port int `json:"port,omitempty"`
Domains []string `json:"domains,omitempty"`
Env int `json:"env"`
Secrets int `json:"secrets"`
Volumes int `json:"volumes"`
Replicas int `json:"replicas,omitempty"`
DroppedKeys []string `json:"dropped_keys,omitempty"`
}
Preview is what an import would create, the dry-run diff against the source.
type Report ¶
type Report struct {
Platform platformimport.Platform `json:"platform"`
Items []Item `json:"items"`
Counts map[Verdict]int `json:"counts"`
Notes []string `json:"notes,omitempty"`
}
Report is the read-only plan.
func Analyze ¶
func Analyze(d *platformimport.Discovery, o Options) (*platformimport.Plan, Report)
Analyze plans the import and builds the report. The returned plan has the overrides applied, so applying it creates exactly what the report previews.
func MergeApplied ¶
func MergeApplied(rep Report, applied platformimport.Report) Report
MergeApplied folds an apply outcome into the report: created items read as already imported, failures as needs_manual with the failure reason.
type StepState ¶
type StepState struct {
Status string `json:"status"`
At string `json:"at,omitempty"`
Actor string `json:"actor,omitempty"`
Note string `json:"note,omitempty"`
Evidence []string `json:"evidence,omitempty"`
}
StepState is one step's stored state.
type Verdict ¶
type Verdict string
Verdict says what an import of one item will do.
const ( WillImport Verdict = "will_import" ImportsWithChanges Verdict = "imports_with_changes" NeedsManual Verdict = "needs_manual" Unsupported Verdict = "unsupported" AlreadyImported Verdict = "already_imported" )
Verdicts shown per item.
func Classify ¶
func Classify(it platformimport.Item) Verdict
Classify maps an importer item status onto a verdict. An item whose caveats carry a manual step is needs_manual, one that only changed on the way in (a renamed target) is imports_with_changes.
type VolumeCheck ¶
type VolumeCheck struct {
VolumeStat
OK bool `json:"ok"`
}
VolumeCheck is the comparison of one volume.
func CompareVolumes ¶
func CompareVolumes(stats []VolumeStat) []VolumeCheck
CompareVolumes requires identical file counts and sizes on both sides.
type VolumeInfo ¶
type VolumeInfo struct {
Name string `json:"name,omitempty"`
HostPath string `json:"host_path,omitempty"`
ContainerPath string `json:"container_path"`
SizeBytes int64 `json:"size_bytes,omitempty"`
}
VolumeInfo is one persistent mount found on the source.
type VolumeStat ¶
type VolumeStat struct {
Name string `json:"name"`
SourceFiles int64 `json:"source_files"`
SourceBytes int64 `json:"source_bytes"`
TargetFiles int64 `json:"target_files"`
TargetBytes int64 `json:"target_bytes"`
}
VolumeStat is the file count and total size of one volume, measured on both hosts by the operator (the control plane never reaches the source).