wisski-cloud-distillery/internal/dis/component/exporter/extras_config.go
Tom Wiesing 890022ae64
internal: Annotate all components with groups
This commit ensures that the compiler has to check every component
against the groups they implement by explicitly annotating the
appropriate interfaces.
2022-11-30 11:08:46 +01:00

46 lines
954 B
Go

package exporter
import (
"context"
"path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
)
// Config implements backing up configuration
type Config struct {
component.Base
}
var (
_ = (component.Backupable)((*Config)(nil))
)
func (*Config) BackupName() string {
return "config"
}
func (control *Config) Backup(scontext component.StagingContext) error {
files := control.backupFiles()
return scontext.AddDirectory("", func(ctx context.Context) error {
for _, src := range files {
name := filepath.Base(src)
if err := scontext.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,
}
}