'wdcli backup': Rework backup process
This commit reworks the backup process to dynamically find the list of components.
This commit is contained in:
parent
55bee7422d
commit
5cd5ae9be2
32 changed files with 361 additions and 279 deletions
|
|
@ -3,6 +3,7 @@ package component
|
|||
|
||||
import (
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/config"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
||||
// Component represents a logical subsystem of the distillery.
|
||||
|
|
@ -31,20 +32,34 @@ type Component interface {
|
|||
Base() *ComponentBase
|
||||
}
|
||||
|
||||
// InstallableComponent implements an installable component
|
||||
type InstallableComponent interface {
|
||||
// Installable implements an installable component.
|
||||
type Installable interface {
|
||||
Component
|
||||
|
||||
// Stack can be used to gain access to the "docker compose" stack.
|
||||
//
|
||||
// This should internally call
|
||||
Stack() Installable
|
||||
// This should internally call [ComponentBase.MakeStack]
|
||||
Stack() StackWithResources
|
||||
|
||||
// Context returns a new InstallationContext to be used during installation from the command line.
|
||||
// Typically this should just pass through the parent, but might perform other tasks.
|
||||
Context(parent InstallationContext) InstallationContext
|
||||
}
|
||||
|
||||
// Backupable represents a component with a Backup method
|
||||
type Backupable interface {
|
||||
Component
|
||||
|
||||
// BackupName returns a new name to be used as an argument for path.
|
||||
BackupName() string
|
||||
|
||||
// Backup backs up this component into the destination path path.
|
||||
//
|
||||
// The destination path may be a folder or directory, depending on the component.
|
||||
// The destination path does not need to exist.
|
||||
Backup(io stream.IOStream, path string) error
|
||||
}
|
||||
|
||||
// ComponentBase implements base functionality for a component
|
||||
type ComponentBase struct {
|
||||
Dir string // Dir is the directory this component lives in
|
||||
|
|
@ -67,7 +82,7 @@ func (ComponentBase) Context(parent InstallationContext) InstallationContext {
|
|||
}
|
||||
|
||||
// MakeStack registers the Installable as a stack
|
||||
func (cb ComponentBase) MakeStack(stack Installable) Installable {
|
||||
func (cb ComponentBase) MakeStack(stack StackWithResources) StackWithResources {
|
||||
stack.Dir = cb.Dir
|
||||
return stack
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue