Refactor component/extras into snapshotting

This commit is contained in:
Tom Wiesing 2022-10-04 10:25:51 +02:00
parent 6d9c83c842
commit 6f409be8b2
No known key found for this signature in database
9 changed files with 81 additions and 79 deletions

View file

@ -1,43 +0,0 @@
package extras
import (
"path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/component"
)
// Config implements backing up configuration
type Config struct {
component.ComponentBase
}
func (Config) Name() string { return "config" }
func (*Config) BackupName() string {
return "config"
}
func (control *Config) Backup(context component.StagingContext) error {
files := control.backupFiles()
return context.AddDirectory("", func() error {
for _, src := range files {
name := filepath.Base(src)
if err := context.CopyFile(name, src); err != nil {
return err
}
}
return nil
})
}
// backupfiles lists the files to be backed up.
func (control *Config) backupFiles() []string {
return []string{
control.Config.ConfigPath,
control.Config.ExecutablePath(),
control.Config.SelfOverridesFile,
control.Config.SelfResolverBlockFile,
control.Config.GlobalAuthorizedKeysFile,
}
}