Rename snapshots.Manager => exporter.Exporter

This commit is contained in:
Tom Wiesing 2022-10-17 15:41:33 +02:00
parent 063f3f9b7d
commit 8d2855fdcb
No known key found for this signature in database
23 changed files with 105 additions and 100 deletions

View file

@ -2,7 +2,7 @@ package cmd
import ( import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery" wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshots" "github.com/FAU-CDI/wisski-distillery/internal/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/core" "github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/pkg/logging" "github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/tkw1536/goprogram/exit" "github.com/tkw1536/goprogram/exit"
@ -41,18 +41,18 @@ func (bk backup) Run(context wisski_distillery.Context) error {
// prune old backups // prune old backups
if !bk.NoPrune { if !bk.NoPrune {
defer logging.LogOperation(func() error { defer logging.LogOperation(func() error {
return dis.ExportManager().PruneExports(context.IOStream) return dis.Exporter().PruneExports(context.IOStream)
}, context.IOStream, "Pruning old backups") }, context.IOStream, "Pruning old backups")
} }
// do the handling // do the handling
err := dis.ExportManager().MakeExport(context.IOStream, snapshots.ExportTask{ err := dis.Exporter().MakeExport(context.IOStream, exporter.ExportTask{
Dest: bk.Positionals.Dest, Dest: bk.Positionals.Dest,
StagingOnly: bk.StagingOnly, StagingOnly: bk.StagingOnly,
Instance: nil, Instance: nil,
BackupDescription: snapshots.BackupDescription{ BackupDescription: exporter.BackupDescription{
ConcurrentSnapshots: bk.ConcurrentSnapshots, ConcurrentSnapshots: bk.ConcurrentSnapshots,
}, },
}) })

View file

@ -2,7 +2,7 @@ package cmd
import ( import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery" wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshots" "github.com/FAU-CDI/wisski-distillery/internal/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/core" "github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/tkw1536/goprogram/exit" "github.com/tkw1536/goprogram/exit"
) )
@ -45,7 +45,7 @@ func (sn snapshot) Run(context wisski_distillery.Context) error {
} }
// do a snapshot of it! // do a snapshot of it!
err = dis.ExportManager().MakeExport(context.IOStream, snapshots.ExportTask{ err = dis.Exporter().MakeExport(context.IOStream, exporter.ExportTask{
Dest: sn.Positionals.Dest, Dest: sn.Positionals.Dest,
StagingOnly: sn.StagingOnly, StagingOnly: sn.StagingOnly,

View file

@ -70,8 +70,8 @@ func (si systemupdate) Run(context wisski_distillery.Context) error {
for _, d := range []string{ for _, d := range []string{
dis.Config.DeployRoot, dis.Config.DeployRoot,
dis.Instances().Path(), dis.Instances().Path(),
dis.ExportManager().StagingPath(), dis.Exporter().StagingPath(),
dis.ExportManager().ArchivePath(), dis.Exporter().ArchivePath(),
} { } {
context.Println(d) context.Println(d)
if err := dis.Core.Environment.MkdirAll(d, environment.DefaultDirPerm); err != nil { if err := dis.Core.Environment.MkdirAll(d, environment.DefaultDirPerm); err != nil {

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"fmt" "fmt"
@ -49,7 +49,7 @@ type BackupDescription struct {
} }
// New create a new Backup // New create a new Backup
func (manager *Manager) NewBackup(io stream.IOStream, description BackupDescription) (backup Backup) { func (exporter *Exporter) NewBackup(io stream.IOStream, description BackupDescription) (backup Backup) {
backup.Description = description backup.Description = description
// catch anything critical that happened during the snapshot // catch anything critical that happened during the snapshot
@ -60,7 +60,7 @@ func (manager *Manager) NewBackup(io stream.IOStream, description BackupDescript
// do the create keeping track of time! // do the create keeping track of time!
logging.LogOperation(func() error { logging.LogOperation(func() error {
backup.StartTime = time.Now().UTC() backup.StartTime = time.Now().UTC()
backup.run(io, manager) backup.run(io, exporter)
backup.EndTime = time.Now().UTC() backup.EndTime = time.Now().UTC()
return nil return nil
@ -69,13 +69,13 @@ func (manager *Manager) NewBackup(io stream.IOStream, description BackupDescript
return return
} }
func (backup *Backup) run(ios stream.IOStream, manager *Manager) { func (backup *Backup) run(ios stream.IOStream, exporter *Exporter) {
// create a manifest // create a manifest
manifest, done := backup.handleManifest(backup.Description.Dest) manifest, done := backup.handleManifest(backup.Description.Dest)
defer done() defer done()
// create a new status display // create a new status display
backups := manager.Backupable backups := exporter.Backupable
backup.ComponentErrors = make(map[string]error, len(backups)) backup.ComponentErrors = make(map[string]error, len(backups))
// Component backup tasks // Component backup tasks
@ -93,7 +93,7 @@ func (backup *Backup) run(ios stream.IOStream, manager *Manager) {
Handler: func(bc component.Backupable, index int, writer io.Writer) error { Handler: func(bc component.Backupable, index int, writer io.Writer) error {
return bc.Backup( return bc.Backup(
component.NewStagingContext( component.NewStagingContext(
manager.Environment, exporter.Environment,
stream.NewIOStream(writer, writer, nil, 0), stream.NewIOStream(writer, writer, nil, 0),
filepath.Join(backup.Description.Dest, bc.BackupName()), filepath.Join(backup.Description.Dest, bc.BackupName()),
manifest, manifest,
@ -118,13 +118,13 @@ func (backup *Backup) run(ios stream.IOStream, manager *Manager) {
defer st.Stop() defer st.Stop()
instancesBackupDir := filepath.Join(backup.Description.Dest, "instances") instancesBackupDir := filepath.Join(backup.Description.Dest, "instances")
if err := manager.Environment.Mkdir(instancesBackupDir, environment.DefaultDirPerm); err != nil { if err := exporter.Environment.Mkdir(instancesBackupDir, environment.DefaultDirPerm); err != nil {
backup.InstanceListErr = err backup.InstanceListErr = err
return nil return nil
} }
// list all instances // list all instances
wissKIs, err := manager.Instances.All() wissKIs, err := exporter.Instances.All()
if err != nil { if err != nil {
backup.InstanceListErr = err backup.InstanceListErr = err
return nil return nil
@ -139,7 +139,7 @@ func (backup *Backup) run(ios stream.IOStream, manager *Manager) {
Handler: func(instance *wisski.WissKI, index int, writer io.Writer) Snapshot { Handler: func(instance *wisski.WissKI, index int, writer io.Writer) Snapshot {
dir := filepath.Join(instancesBackupDir, instance.Slug) dir := filepath.Join(instancesBackupDir, instance.Slug)
if err := manager.Environment.Mkdir(dir, environment.DefaultDirPerm); err != nil { if err := exporter.Environment.Mkdir(dir, environment.DefaultDirPerm); err != nil {
return Snapshot{ return Snapshot{
ErrPanic: err, ErrPanic: err,
} }
@ -147,7 +147,7 @@ func (backup *Backup) run(ios stream.IOStream, manager *Manager) {
manifest <- dir manifest <- dir
return manager.NewSnapshot(instance, stream.NewIOStream(writer, writer, nil, 0), SnapshotDescription{ return exporter.NewSnapshot(instance, stream.NewIOStream(writer, writer, nil, 0), SnapshotDescription{
Dest: dir, Dest: dir,
}) })
}, },

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"fmt" "fmt"
@ -6,48 +6,49 @@ import (
"time" "time"
"github.com/FAU-CDI/wisski-distillery/internal/component" "github.com/FAU-CDI/wisski-distillery/internal/component"
"github.com/FAU-CDI/wisski-distillery/internal/component/exporter/logger"
"github.com/FAU-CDI/wisski-distillery/internal/component/instances" "github.com/FAU-CDI/wisski-distillery/internal/component/instances"
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshotslog"
"github.com/FAU-CDI/wisski-distillery/internal/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/component/sql"
"github.com/FAU-CDI/wisski-distillery/pkg/environment" "github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/password" "github.com/FAU-CDI/wisski-distillery/pkg/password"
) )
// Manager manages snapshots and backups // Exporter manages snapshots and backups
type Manager struct { type Exporter struct {
component.ComponentBase component.ComponentBase
SQL *sql.SQL SQL *sql.SQL
Instances *instances.Instances Instances *instances.Instances
SnapshotsLog *snapshotslog.SnapshotsLog ExporterLogger *logger.Logger
Snapshotable []component.Snapshotable Snapshotable []component.Snapshotable
Backupable []component.Backupable Backupable []component.Backupable
} }
func (Manager) Name() string { return "snapshots" } func (Exporter) Name() string { return "snapshots" }
// Path returns the path that contains all snapshot related data. // Path returns the path that contains all snapshot related data.
func (dis *Manager) Path() string { func (dis *Exporter) Path() string {
return filepath.Join(dis.Config.DeployRoot, "snapshots") return filepath.Join(dis.Config.DeployRoot, "snapshots")
} }
// StagingPath returns the path to the directory containing a temporary staging area for snapshots. // StagingPath returns the path to the directory containing a temporary staging area for snapshots.
// Use NewSnapshotStagingDir to generate a new staging area. // Use NewSnapshotStagingDir to generate a new staging area.
func (dis *Manager) StagingPath() string { func (dis *Exporter) StagingPath() string {
return filepath.Join(dis.Path(), "staging") return filepath.Join(dis.Path(), "staging")
} }
// ArchivePath returns the path to the directory containing all exported archives. // ArchivePath returns the path to the directory containing all exported archives.
// Use NewSnapshotArchivePath to generate a path to a new archive in this directory. // Use NewSnapshotArchivePath to generate a path to a new archive in this directory.
func (dis *Manager) ArchivePath() string { func (dis *Exporter) ArchivePath() string {
return filepath.Join(dis.Path(), "archives") return filepath.Join(dis.Path(), "archives")
} }
// NewArchivePath returns the path to a new archive with the provided prefix. // NewArchivePath returns the path to a new archive with the provided prefix.
// The path is guaranteed to not exist. // The path is guaranteed to not exist.
func (dis *Manager) NewArchivePath(prefix string) (path string) { func (dis *Exporter) NewArchivePath(prefix string) (path string) {
// TODO: Consider moving these into a subdirectory with the provided prefix. // TODO: Consider moving these into a subdirectory with the provided prefix.
for path == "" || fsx.Exists(dis.Environment, path) { for path == "" || fsx.Exists(dis.Environment, path) {
name := dis.newSnapshotName(prefix) + ".tar.gz" name := dis.newSnapshotName(prefix) + ".tar.gz"
@ -58,7 +59,7 @@ func (dis *Manager) NewArchivePath(prefix string) (path string) {
// newSnapshot name returns a new basename for a snapshot with the provided prefix. // newSnapshot name returns a new basename for a snapshot with the provided prefix.
// The name is guaranteed to be unique within this process. // The name is guaranteed to be unique within this process.
func (*Manager) newSnapshotName(prefix string) string { func (*Exporter) newSnapshotName(prefix string) string {
suffix, _ := password.Password(10) // silently ignore any errors! suffix, _ := password.Password(10) // silently ignore any errors!
if prefix == "" { if prefix == "" {
prefix = "backup" prefix = "backup"
@ -70,7 +71,7 @@ func (*Manager) newSnapshotName(prefix string) string {
// NewStagingDir returns the path to a new snapshot directory. // NewStagingDir returns the path to a new snapshot directory.
// The directory is guaranteed to have been freshly created. // The directory is guaranteed to have been freshly created.
func (dis *Manager) NewStagingDir(prefix string) (path string, err error) { func (dis *Exporter) NewStagingDir(prefix string) (path string, err error) {
for path == "" || environment.IsExist(err) { for path == "" || environment.IsExist(err) {
path = filepath.Join(dis.StagingPath(), dis.newSnapshotName(prefix)) path = filepath.Join(dis.StagingPath(), dis.newSnapshotName(prefix))
err = dis.Core.Environment.Mkdir(path, environment.DefaultFilePerm) err = dis.Core.Environment.Mkdir(path, environment.DefaultFilePerm)

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"fmt" "fmt"

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"path/filepath" "path/filepath"

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"github.com/FAU-CDI/wisski-distillery/internal/component" "github.com/FAU-CDI/wisski-distillery/internal/component"

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"io" "io"

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"io" "io"
@ -14,7 +14,7 @@ import (
) )
// ExportTask describes a task that makes either a [Backup] or a [Snapshot]. // ExportTask describes a task that makes either a [Backup] or a [Snapshot].
// See [Manager.MakeExport] // See [Exporter.MakeExport]
type ExportTask struct { type ExportTask struct {
// Dest is the destination path to write the backup to. // Dest is the destination path to write the backup to.
// When empty, this is created automatically in the staging or archive directory. // When empty, this is created automatically in the staging or archive directory.
@ -42,7 +42,7 @@ type export interface {
// MakeExport performs an export task as described by flags. // MakeExport performs an export task as described by flags.
// Output is directed to the provided io. // Output is directed to the provided io.
func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err error) { func (exporter *Exporter) MakeExport(io stream.IOStream, task ExportTask) (err error) {
// extract parameters // extract parameters
Title := "Backup" Title := "Backup"
Slug := "" Slug := ""
@ -60,20 +60,20 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
archivePath = task.Dest archivePath = task.Dest
} }
if stagingDir == "" { if stagingDir == "" {
stagingDir, err = manager.NewStagingDir(Slug) stagingDir, err = exporter.NewStagingDir(Slug)
if err != nil { if err != nil {
return err return err
} }
} }
if !task.StagingOnly && archivePath == "" { if !task.StagingOnly && archivePath == "" {
archivePath = manager.NewArchivePath(Slug) archivePath = exporter.NewArchivePath(Slug)
} }
io.Printf("Staging Directory: %s\n", stagingDir) io.Printf("Staging Directory: %s\n", stagingDir)
io.Printf("Archive Path: %s\n", archivePath) io.Printf("Archive Path: %s\n", archivePath)
// create the staging directory // create the staging directory
logging.LogMessage(io, "Creating staging directory") logging.LogMessage(io, "Creating staging directory")
err = manager.Environment.Mkdir(stagingDir, environment.DefaultDirPerm) err = exporter.Environment.Mkdir(stagingDir, environment.DefaultDirPerm)
if !environment.IsExist(err) && err != nil { if !environment.IsExist(err) && err != nil {
return err return err
} }
@ -83,7 +83,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
if !task.StagingOnly { if !task.StagingOnly {
defer func() { defer func() {
logging.LogMessage(io, "Removing staging directory") logging.LogMessage(io, "Removing staging directory")
manager.Environment.RemoveAll(stagingDir) exporter.Environment.RemoveAll(stagingDir)
}() }()
} }
@ -95,11 +95,11 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
var sl export var sl export
if task.Instance == nil { if task.Instance == nil {
task.BackupDescription.Dest = stagingDir task.BackupDescription.Dest = stagingDir
backup := manager.NewBackup(io, task.BackupDescription) backup := exporter.NewBackup(io, task.BackupDescription)
sl = &backup sl = &backup
} else { } else {
task.SnapshotDescription.Dest = stagingDir task.SnapshotDescription.Dest = stagingDir
snapshot := manager.NewSnapshot(task.Instance, io, task.SnapshotDescription) snapshot := exporter.NewSnapshot(task.Instance, io, task.SnapshotDescription)
sl = &snapshot sl = &snapshot
} }
@ -111,7 +111,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
io.Println(reportPath) io.Println(reportPath)
// create the path // create the path
report, err := manager.Environment.Create(reportPath, environment.DefaultFilePerm) report, err := exporter.Environment.Create(reportPath, environment.DefaultFilePerm)
if err != nil { if err != nil {
return err return err
} }
@ -131,7 +131,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
// write out the log entry // write out the log entry
entry.Path = stagingDir entry.Path = stagingDir
entry.Packed = false entry.Packed = false
manager.SnapshotsLog.Add(entry) exporter.ExporterLogger.Add(entry)
io.Printf("Wrote %s\n", stagingDir) io.Printf("Wrote %s\n", stagingDir)
return nil return nil
@ -146,7 +146,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
st.Start() st.Start()
defer st.Stop() defer st.Stop()
count, err = targz.Package(manager.Environment, archivePath, stagingDir, func(dst, src string) { count, err = targz.Package(exporter.Environment, archivePath, stagingDir, func(dst, src string) {
st.Set(0, dst) st.Set(0, dst)
}) })
@ -159,7 +159,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
logging.LogMessage(io, "Writing Log Entry") logging.LogMessage(io, "Writing Log Entry")
entry.Path = archivePath entry.Path = archivePath
entry.Packed = true entry.Packed = true
manager.SnapshotsLog.Add(entry) exporter.ExporterLogger.Add(entry)
// and we're done! // and we're done!
return nil return nil

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import "github.com/FAU-CDI/wisski-distillery/internal/models" import "github.com/FAU-CDI/wisski-distillery/internal/models"

View file

@ -1,4 +1,4 @@
package snapshotslog package logger
import ( import (
"github.com/FAU-CDI/wisski-distillery/internal/component" "github.com/FAU-CDI/wisski-distillery/internal/component"
@ -8,19 +8,19 @@ import (
"github.com/tkw1536/goprogram/lib/collection" "github.com/tkw1536/goprogram/lib/collection"
) )
// SnapshotsLog is responsible for logging snapshots // Logger is responsible for logging backups and snapshots
type SnapshotsLog struct { type Logger struct {
component.ComponentBase component.ComponentBase
SQL *sql.SQL SQL *sql.SQL
} }
func (*SnapshotsLog) Name() string { return "snapshots-log" } func (*Logger) Name() string { return "snapshots-log" }
// For retrieves (and prunes) the ExportLog. // For retrieves (and prunes) the ExportLog.
// Slug determines if entries for Backups (empty slug) // Slug determines if entries for Backups (empty slug)
// or a specific Instance (non-empty slug) are returned. // or a specific Instance (non-empty slug) are returned.
func (log *SnapshotsLog) For(slug string) (exports []models.Export, err error) { func (log *Logger) For(slug string) (exports []models.Export, err error) {
exports, err = log.Log() exports, err = log.Log()
if err != nil { if err != nil {
return nil, err return nil, err
@ -32,7 +32,7 @@ func (log *SnapshotsLog) For(slug string) (exports []models.Export, err error) {
} }
// Log retrieves (and prunes) all entries in the snapshot log. // Log retrieves (and prunes) all entries in the snapshot log.
func (log *SnapshotsLog) Log() ([]models.Export, error) { func (log *Logger) Log() ([]models.Export, error) {
// query the table! // query the table!
table, err := log.SQL.QueryTable(false, models.ExportTable) table, err := log.SQL.QueryTable(false, models.ExportTable)
if err != nil { if err != nil {
@ -64,7 +64,7 @@ func (log *SnapshotsLog) Log() ([]models.Export, error) {
} }
// AddToExportLog adds the provided export to the log. // AddToExportLog adds the provided export to the log.
func (log *SnapshotsLog) Add(export models.Export) error { func (log *Logger) Add(export models.Export) error {
// find the table // find the table
table, err := log.SQL.QueryTable(false, models.ExportTable) table, err := log.SQL.QueryTable(false, models.ExportTable)
if err != nil { if err != nil {

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"path/filepath" "path/filepath"

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"path/filepath" "path/filepath"
@ -9,16 +9,16 @@ import (
// ShouldPrune determines if a file with the provided modification time should be // ShouldPrune determines if a file with the provided modification time should be
// removed from the export log. // removed from the export log.
func (manager *Manager) ShouldPrune(modtime time.Time) bool { func (exporter *Exporter) ShouldPrune(modtime time.Time) bool {
return time.Since(modtime) > time.Duration(manager.Config.MaxBackupAge)*24*time.Hour return time.Since(modtime) > time.Duration(exporter.Config.MaxBackupAge)*24*time.Hour
} }
// Prune prunes all old exports // Prune prunes all old exports
func (manager *Manager) PruneExports(io stream.IOStream) error { func (exporter *Exporter) PruneExports(io stream.IOStream) error {
sPath := manager.ArchivePath() sPath := exporter.ArchivePath()
// list all the files // list all the files
entries, err := manager.Core.Environment.ReadDir(sPath) entries, err := exporter.Core.Environment.ReadDir(sPath)
if err != nil { if err != nil {
return err return err
} }
@ -36,20 +36,20 @@ func (manager *Manager) PruneExports(io stream.IOStream) error {
} }
// check if it should be pruned! // check if it should be pruned!
if !manager.ShouldPrune(info.ModTime()) { if !exporter.ShouldPrune(info.ModTime()) {
continue continue
} }
// assemble path, and then remove the file! // assemble path, and then remove the file!
path := filepath.Join(sPath, entry.Name()) path := filepath.Join(sPath, entry.Name())
io.Printf("Removing %s cause it is older than %d days", path, manager.Config.MaxBackupAge) io.Printf("Removing %s cause it is older than %d days", path, exporter.Config.MaxBackupAge)
if err := manager.Core.Environment.Remove(path); err != nil { if err := exporter.Core.Environment.Remove(path); err != nil {
return err return err
} }
} }
// prune the snapshot log! // prune the snapshot log!
_, err = manager.SnapshotsLog.Log() _, err = exporter.ExporterLogger.Log()
return err return err
} }

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"encoding/json" "encoding/json"

View file

@ -1,4 +1,4 @@
package snapshots package exporter
import ( import (
"fmt" "fmt"
@ -43,7 +43,7 @@ type Snapshot struct {
} }
// Snapshot creates a new snapshot of this instance into dest // Snapshot creates a new snapshot of this instance into dest
func (snapshots *Manager) NewSnapshot(instance *wisski.WissKI, io stream.IOStream, desc SnapshotDescription) (snapshot Snapshot) { func (snapshots *Exporter) NewSnapshot(instance *wisski.WissKI, io stream.IOStream, desc SnapshotDescription) (snapshot Snapshot) {
logging.LogMessage(io, "Locking instance") logging.LogMessage(io, "Locking instance")
if err := instance.TryLock(); err != nil { if err := instance.TryLock(); err != nil {
@ -83,7 +83,7 @@ func (snapshots *Manager) NewSnapshot(instance *wisski.WissKI, io stream.IOStrea
return return
} }
func (snapshot *Snapshot) makeParts(ios stream.IOStream, snapshots *Manager, instance *wisski.WissKI, needsRunning bool) map[string]error { func (snapshot *Snapshot) makeParts(ios stream.IOStream, snapshots *Exporter, instance *wisski.WissKI, needsRunning bool) map[string]error {
if !needsRunning && !snapshot.Description.Keepalive { if !needsRunning && !snapshot.Description.Keepalive {
stack := instance.Barrel() stack := instance.Barrel()

View file

@ -5,9 +5,10 @@ import (
"net/http" "net/http"
"github.com/FAU-CDI/wisski-distillery/internal/component" "github.com/FAU-CDI/wisski-distillery/internal/component"
"github.com/FAU-CDI/wisski-distillery/internal/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/component/exporter/logger"
"github.com/FAU-CDI/wisski-distillery/internal/component/instances" "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/snapshotslog"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx" "github.com/FAU-CDI/wisski-distillery/pkg/httpx"
"github.com/tkw1536/goprogram/stream" "github.com/tkw1536/goprogram/stream"
) )
@ -15,9 +16,9 @@ import (
type Info struct { type Info struct {
component.ComponentBase component.ComponentBase
SnapshotManager *snapshots.Manager Exporter *exporter.Exporter
Instances *instances.Instances Instances *instances.Instances
SnapshotsLog *snapshotslog.SnapshotsLog SnapshotsLog *logger.Logger
} }
func (Info) Name() string { return "control-info" } func (Info) Name() string { return "control-info" }

View file

@ -1,7 +1,7 @@
package info package info
import ( import (
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshots" "github.com/FAU-CDI/wisski-distillery/internal/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/wisski" "github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx" "github.com/FAU-CDI/wisski-distillery/pkg/httpx"
"github.com/tkw1536/goprogram/status" "github.com/tkw1536/goprogram/status"
@ -12,9 +12,9 @@ type instanceActionFunc = func(info *Info, instance *wisski.WissKI, str stream.I
var socketInstanceActions = map[string]instanceActionFunc{ var socketInstanceActions = map[string]instanceActionFunc{
"snapshot": func(info *Info, instance *wisski.WissKI, str stream.IOStream) error { "snapshot": func(info *Info, instance *wisski.WissKI, str stream.IOStream) error {
return info.SnapshotManager.MakeExport( return info.Exporter.MakeExport(
str, str,
snapshots.ExportTask{ exporter.ExportTask{
Dest: "", Dest: "",
Instance: instance, Instance: instance,

View file

@ -5,8 +5,9 @@ import (
"path/filepath" "path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/component" "github.com/FAU-CDI/wisski-distillery/internal/component"
"github.com/FAU-CDI/wisski-distillery/internal/component/exporter/logger"
"github.com/FAU-CDI/wisski-distillery/internal/component/meta" "github.com/FAU-CDI/wisski-distillery/internal/component/meta"
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshotslog"
"github.com/FAU-CDI/wisski-distillery/internal/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/component/sql"
"github.com/FAU-CDI/wisski-distillery/internal/component/triplestore" "github.com/FAU-CDI/wisski-distillery/internal/component/triplestore"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
@ -20,10 +21,10 @@ import (
type Instances struct { type Instances struct {
component.ComponentBase component.ComponentBase
TS *triplestore.Triplestore TS *triplestore.Triplestore
SQL *sql.SQL SQL *sql.SQL
Meta *meta.Meta Meta *meta.Meta
SnapshotsLog *snapshotslog.SnapshotsLog ExporterLog *logger.Logger
} }
func (Instances) Name() string { func (Instances) Name() string {
@ -48,7 +49,7 @@ func (instances *Instances) use(wisski *wisski.WissKI) {
wisski.SQL = instances.SQL wisski.SQL = instances.SQL
wisski.TS = instances.TS wisski.TS = instances.TS
wisski.Meta = instances.Meta wisski.Meta = instances.Meta
wisski.SnapshotsLog = instances.SnapshotsLog wisski.ExporterLog = instances.ExporterLog
} }
// WissKI returns the WissKI with the provided slug, if it exists. // WissKI returns the WissKI with the provided slug, if it exists.

View file

@ -5,13 +5,14 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/component" "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/control"
"github.com/FAU-CDI/wisski-distillery/internal/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/component/exporter/logger"
"github.com/FAU-CDI/wisski-distillery/internal/component/home" "github.com/FAU-CDI/wisski-distillery/internal/component/home"
"github.com/FAU-CDI/wisski-distillery/internal/component/info" "github.com/FAU-CDI/wisski-distillery/internal/component/info"
"github.com/FAU-CDI/wisski-distillery/internal/component/instances" "github.com/FAU-CDI/wisski-distillery/internal/component/instances"
"github.com/FAU-CDI/wisski-distillery/internal/component/meta" "github.com/FAU-CDI/wisski-distillery/internal/component/meta"
"github.com/FAU-CDI/wisski-distillery/internal/component/resolver" "github.com/FAU-CDI/wisski-distillery/internal/component/resolver"
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshots"
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshotslog"
"github.com/FAU-CDI/wisski-distillery/internal/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/component/sql"
"github.com/FAU-CDI/wisski-distillery/internal/component/ssh" "github.com/FAU-CDI/wisski-distillery/internal/component/ssh"
"github.com/FAU-CDI/wisski-distillery/internal/component/static" "github.com/FAU-CDI/wisski-distillery/internal/component/static"
@ -42,12 +43,12 @@ func (dis *Distillery) register(context component.ComponentPoolContext) []compon
auto[*meta.Meta], auto[*meta.Meta],
// Snapshots // Snapshots
auto[*snapshots.Manager], auto[*exporter.Exporter],
auto[*snapshotslog.SnapshotsLog], auto[*logger.Logger],
auto[*snapshots.Config], auto[*exporter.Config],
auto[*snapshots.Bookkeeping], auto[*exporter.Bookkeeping],
auto[*snapshots.Filesystem], auto[*exporter.Filesystem],
auto[*snapshots.Pathbuilders], auto[*exporter.Pathbuilders],
// Control server // Control server
auto[*control.Control], auto[*control.Control],

View file

@ -6,9 +6,9 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/component" "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/control"
"github.com/FAU-CDI/wisski-distillery/internal/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/component/instances" "github.com/FAU-CDI/wisski-distillery/internal/component/instances"
"github.com/FAU-CDI/wisski-distillery/internal/component/resolver" "github.com/FAU-CDI/wisski-distillery/internal/component/resolver"
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshots"
"github.com/FAU-CDI/wisski-distillery/internal/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/component/sql"
"github.com/FAU-CDI/wisski-distillery/internal/component/ssh" "github.com/FAU-CDI/wisski-distillery/internal/component/ssh"
"github.com/FAU-CDI/wisski-distillery/internal/component/triplestore" "github.com/FAU-CDI/wisski-distillery/internal/component/triplestore"
@ -85,8 +85,8 @@ func (dis *Distillery) Triplestore() *triplestore.Triplestore {
func (dis *Distillery) Instances() *instances.Instances { func (dis *Distillery) Instances() *instances.Instances {
return e[*instances.Instances](dis) return e[*instances.Instances](dis)
} }
func (dis *Distillery) ExportManager() *snapshots.Manager { func (dis *Distillery) Exporter() *exporter.Exporter {
return e[*snapshots.Manager](dis) return e[*exporter.Exporter](dis)
} }
func (dis *Distillery) Installable() []component.Installable { func (dis *Distillery) Installable() []component.Installable {

View file

@ -4,5 +4,5 @@ import "github.com/FAU-CDI/wisski-distillery/internal/models"
// Snapshots returns the list of snapshots of this WissKI // Snapshots returns the list of snapshots of this WissKI
func (wisski *WissKI) Snapshots() (snapshots []models.Export, err error) { func (wisski *WissKI) Snapshots() (snapshots []models.Export, err error) {
return wisski.SnapshotsLog.For(wisski.Slug) return wisski.ExporterLog.For(wisski.Slug)
} }

View file

@ -3,8 +3,9 @@ package wisski
import ( import (
"github.com/FAU-CDI/wisski-distillery/internal/component" "github.com/FAU-CDI/wisski-distillery/internal/component"
"github.com/FAU-CDI/wisski-distillery/internal/component/exporter/logger"
"github.com/FAU-CDI/wisski-distillery/internal/component/meta" "github.com/FAU-CDI/wisski-distillery/internal/component/meta"
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshotslog"
"github.com/FAU-CDI/wisski-distillery/internal/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/component/sql"
"github.com/FAU-CDI/wisski-distillery/internal/component/triplestore" "github.com/FAU-CDI/wisski-distillery/internal/component/triplestore"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
@ -24,7 +25,7 @@ type WissKI struct {
TS *triplestore.Triplestore TS *triplestore.Triplestore
SQL *sql.SQL SQL *sql.SQL
SnapshotsLog *snapshotslog.SnapshotsLog ExporterLog *logger.Logger
} }
// Save saves this instance in the bookkeeping table // Save saves this instance in the bookkeeping table