From 698f04e13e272dceb0302eb4b4919a280c8f55bd Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Sat, 1 Oct 2022 20:18:58 +0200 Subject: [PATCH] Create new 'extras' components for management --- .../{control/backup.go => extras/config.go} | 16 +++++++++++----- internal/component/extras/extras.go | 2 ++ internal/dis/component.go | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) rename internal/component/{control/backup.go => extras/config.go} (65%) create mode 100644 internal/component/extras/extras.go diff --git a/internal/component/control/backup.go b/internal/component/extras/config.go similarity index 65% rename from internal/component/control/backup.go rename to internal/component/extras/config.go index 3bad507..71844a6 100644 --- a/internal/component/control/backup.go +++ b/internal/component/extras/config.go @@ -1,4 +1,4 @@ -package control +package extras import ( "path/filepath" @@ -6,12 +6,18 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/component" ) -func (*Control) BackupName() string { +// Config implements backing up configuration +type Config struct { + component.ComponentBase +} + +func (Config) Name() string { return "extra-config" } + +func (*Config) BackupName() string { return "config" } -// Backup backups all control plane configuration files into dest -func (control *Control) Backup(context component.StagingContext) error { +func (control *Config) Backup(context component.StagingContext) error { files := control.backupFiles() return context.AddDirectory("", func() error { @@ -26,7 +32,7 @@ func (control *Control) Backup(context component.StagingContext) error { } // backupfiles lists the files to be backed up. -func (control *Control) backupFiles() []string { +func (control *Config) backupFiles() []string { return []string{ control.Config.ConfigPath, control.Config.ExecutablePath(), diff --git a/internal/component/extras/extras.go b/internal/component/extras/extras.go new file mode 100644 index 0000000..f6c0570 --- /dev/null +++ b/internal/component/extras/extras.go @@ -0,0 +1,2 @@ +// Package extras implements additional components to be used for backups and snapshots +package extras diff --git a/internal/dis/component.go b/internal/dis/component.go index c4eab01..8dcb043 100644 --- a/internal/dis/component.go +++ b/internal/dis/component.go @@ -5,6 +5,7 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/component" "github.com/FAU-CDI/wisski-distillery/internal/component/control" + "github.com/FAU-CDI/wisski-distillery/internal/component/extras" "github.com/FAU-CDI/wisski-distillery/internal/component/instances" "github.com/FAU-CDI/wisski-distillery/internal/component/snapshots" "github.com/FAU-CDI/wisski-distillery/internal/component/sql" @@ -31,6 +32,9 @@ type components struct { // other components instances lazy.Lazy[*instances.Instances] snapshots lazy.Lazy[*snapshots.Manager] + + // extras components + extrasConfig lazy.Lazy[*extras.Config] } // @@ -82,6 +86,14 @@ func (dis *Distillery) SnapshotManager() *snapshots.Manager { }) } +// +// EXTRAS COMPONENTS +// + +func (dis *Distillery) ExtrasConfig() *extras.Config { + return component.Initialize(dis.Core, &dis.components.extrasConfig, nil) +} + // // ALL COMPONENTS // @@ -94,6 +106,10 @@ func (dis *Distillery) Components() []component.Component { dis.Triplestore(), dis.SQL(), dis.Instances(), + dis.SnapshotManager(), + + // extras components + dis.ExtrasConfig(), } }