package releaseupdate import ( "fmt" "slices" ) type Topology struct { Units []string `json:"units"` ConfigSections []string `json:"config_sections"` // Binaries are the release's host binaries that run beside the units // without a service of their own. They are installed and switched with // the units and are never started, stopped or demanded as a unit. Binaries []string `json:"binaries,omitempty"` } // apps returns the binaries the release installs: its units, and the host // binaries that run beside them without a service. func (t Topology) apps() []string { return append(slices.Clone(t.Units), t.Binaries...) } // MigrationPlan preserves the release's dependency order. Unknown observations // require every step to be checked manually rather than assuming a partial host. func (t Topology) MigrationPlan(units, sections map[string]bool) []string { var steps []string for _, section := range t.ConfigSections { if !sections[section] { steps = append(steps, fmt.Sprintf("configure [%s]", section)) } } for _, unit := range t.Units { if !units[unit] { steps = append(steps, fmt.Sprintf("install and enable %s.service", unit)) } } return steps }