Rename snapshots.Manager => exporter.Exporter
This commit is contained in:
parent
063f3f9b7d
commit
8d2855fdcb
23 changed files with 105 additions and 100 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -49,7 +49,7 @@ type BackupDescription struct {
|
|||
}
|
||||
|
||||
// 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
|
||||
|
||||
// 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!
|
||||
logging.LogOperation(func() error {
|
||||
backup.StartTime = time.Now().UTC()
|
||||
backup.run(io, manager)
|
||||
backup.run(io, exporter)
|
||||
backup.EndTime = time.Now().UTC()
|
||||
|
||||
return nil
|
||||
|
|
@ -69,13 +69,13 @@ func (manager *Manager) NewBackup(io stream.IOStream, description BackupDescript
|
|||
return
|
||||
}
|
||||
|
||||
func (backup *Backup) run(ios stream.IOStream, manager *Manager) {
|
||||
func (backup *Backup) run(ios stream.IOStream, exporter *Exporter) {
|
||||
// create a manifest
|
||||
manifest, done := backup.handleManifest(backup.Description.Dest)
|
||||
defer done()
|
||||
|
||||
// create a new status display
|
||||
backups := manager.Backupable
|
||||
backups := exporter.Backupable
|
||||
backup.ComponentErrors = make(map[string]error, len(backups))
|
||||
|
||||
// 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 {
|
||||
return bc.Backup(
|
||||
component.NewStagingContext(
|
||||
manager.Environment,
|
||||
exporter.Environment,
|
||||
stream.NewIOStream(writer, writer, nil, 0),
|
||||
filepath.Join(backup.Description.Dest, bc.BackupName()),
|
||||
manifest,
|
||||
|
|
@ -118,13 +118,13 @@ func (backup *Backup) run(ios stream.IOStream, manager *Manager) {
|
|||
defer st.Stop()
|
||||
|
||||
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
|
||||
return nil
|
||||
}
|
||||
|
||||
// list all instances
|
||||
wissKIs, err := manager.Instances.All()
|
||||
wissKIs, err := exporter.Instances.All()
|
||||
if err != nil {
|
||||
backup.InstanceListErr = err
|
||||
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 {
|
||||
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{
|
||||
ErrPanic: err,
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ func (backup *Backup) run(ios stream.IOStream, manager *Manager) {
|
|||
|
||||
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,
|
||||
})
|
||||
},
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -6,48 +6,49 @@ import (
|
|||
"time"
|
||||
|
||||
"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/snapshotslog"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component/sql"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/password"
|
||||
)
|
||||
|
||||
// Manager manages snapshots and backups
|
||||
type Manager struct {
|
||||
// Exporter manages snapshots and backups
|
||||
type Exporter struct {
|
||||
component.ComponentBase
|
||||
|
||||
SQL *sql.SQL
|
||||
Instances *instances.Instances
|
||||
SnapshotsLog *snapshotslog.SnapshotsLog
|
||||
SQL *sql.SQL
|
||||
Instances *instances.Instances
|
||||
ExporterLogger *logger.Logger
|
||||
|
||||
Snapshotable []component.Snapshotable
|
||||
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.
|
||||
func (dis *Manager) Path() string {
|
||||
func (dis *Exporter) Path() string {
|
||||
return filepath.Join(dis.Config.DeployRoot, "snapshots")
|
||||
}
|
||||
|
||||
// StagingPath returns the path to the directory containing a temporary staging area for snapshots.
|
||||
// Use NewSnapshotStagingDir to generate a new staging area.
|
||||
func (dis *Manager) StagingPath() string {
|
||||
func (dis *Exporter) StagingPath() string {
|
||||
return filepath.Join(dis.Path(), "staging")
|
||||
}
|
||||
|
||||
// ArchivePath returns the path to the directory containing all exported archives.
|
||||
// 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")
|
||||
}
|
||||
|
||||
// NewArchivePath returns the path to a new archive with the provided prefix.
|
||||
// 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.
|
||||
for path == "" || fsx.Exists(dis.Environment, path) {
|
||||
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.
|
||||
// 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!
|
||||
if prefix == "" {
|
||||
prefix = "backup"
|
||||
|
|
@ -70,7 +71,7 @@ func (*Manager) newSnapshotName(prefix string) string {
|
|||
|
||||
// NewStagingDir returns the path to a new snapshot directory.
|
||||
// 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) {
|
||||
path = filepath.Join(dis.StagingPath(), dis.newSnapshotName(prefix))
|
||||
err = dis.Core.Environment.Mkdir(path, environment.DefaultFilePerm)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
// ExportTask describes a task that makes either a [Backup] or a [Snapshot].
|
||||
// See [Manager.MakeExport]
|
||||
// See [Exporter.MakeExport]
|
||||
type ExportTask struct {
|
||||
// Dest is the destination path to write the backup to.
|
||||
// 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.
|
||||
// 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
|
||||
Title := "Backup"
|
||||
Slug := ""
|
||||
|
|
@ -60,20 +60,20 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
|
|||
archivePath = task.Dest
|
||||
}
|
||||
if stagingDir == "" {
|
||||
stagingDir, err = manager.NewStagingDir(Slug)
|
||||
stagingDir, err = exporter.NewStagingDir(Slug)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !task.StagingOnly && archivePath == "" {
|
||||
archivePath = manager.NewArchivePath(Slug)
|
||||
archivePath = exporter.NewArchivePath(Slug)
|
||||
}
|
||||
io.Printf("Staging Directory: %s\n", stagingDir)
|
||||
io.Printf("Archive Path: %s\n", archivePath)
|
||||
|
||||
// create the 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 {
|
||||
return err
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
|
|||
if !task.StagingOnly {
|
||||
defer func() {
|
||||
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
|
||||
if task.Instance == nil {
|
||||
task.BackupDescription.Dest = stagingDir
|
||||
backup := manager.NewBackup(io, task.BackupDescription)
|
||||
backup := exporter.NewBackup(io, task.BackupDescription)
|
||||
sl = &backup
|
||||
} else {
|
||||
task.SnapshotDescription.Dest = stagingDir
|
||||
snapshot := manager.NewSnapshot(task.Instance, io, task.SnapshotDescription)
|
||||
snapshot := exporter.NewSnapshot(task.Instance, io, task.SnapshotDescription)
|
||||
sl = &snapshot
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
|
|||
io.Println(reportPath)
|
||||
|
||||
// create the path
|
||||
report, err := manager.Environment.Create(reportPath, environment.DefaultFilePerm)
|
||||
report, err := exporter.Environment.Create(reportPath, environment.DefaultFilePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
|
|||
// write out the log entry
|
||||
entry.Path = stagingDir
|
||||
entry.Packed = false
|
||||
manager.SnapshotsLog.Add(entry)
|
||||
exporter.ExporterLogger.Add(entry)
|
||||
|
||||
io.Printf("Wrote %s\n", stagingDir)
|
||||
return nil
|
||||
|
|
@ -146,7 +146,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
|
|||
st.Start()
|
||||
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)
|
||||
})
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ func (manager *Manager) MakeExport(io stream.IOStream, task ExportTask) (err err
|
|||
logging.LogMessage(io, "Writing Log Entry")
|
||||
entry.Path = archivePath
|
||||
entry.Packed = true
|
||||
manager.SnapshotsLog.Add(entry)
|
||||
exporter.ExporterLogger.Add(entry)
|
||||
|
||||
// and we're done!
|
||||
return nil
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import "github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshotslog
|
||||
package logger
|
||||
|
||||
import (
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component"
|
||||
|
|
@ -8,19 +8,19 @@ import (
|
|||
"github.com/tkw1536/goprogram/lib/collection"
|
||||
)
|
||||
|
||||
// SnapshotsLog is responsible for logging snapshots
|
||||
type SnapshotsLog struct {
|
||||
// Logger is responsible for logging backups and snapshots
|
||||
type Logger struct {
|
||||
component.ComponentBase
|
||||
|
||||
SQL *sql.SQL
|
||||
}
|
||||
|
||||
func (*SnapshotsLog) Name() string { return "snapshots-log" }
|
||||
func (*Logger) Name() string { return "snapshots-log" }
|
||||
|
||||
// For retrieves (and prunes) the ExportLog.
|
||||
// Slug determines if entries for Backups (empty slug)
|
||||
// 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()
|
||||
if err != nil {
|
||||
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.
|
||||
func (log *SnapshotsLog) Log() ([]models.Export, error) {
|
||||
func (log *Logger) Log() ([]models.Export, error) {
|
||||
// query the table!
|
||||
table, err := log.SQL.QueryTable(false, models.ExportTable)
|
||||
if err != nil {
|
||||
|
|
@ -64,7 +64,7 @@ func (log *SnapshotsLog) Log() ([]models.Export, error) {
|
|||
}
|
||||
|
||||
// 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
|
||||
table, err := log.SQL.QueryTable(false, models.ExportTable)
|
||||
if err != nil {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
|
@ -9,16 +9,16 @@ import (
|
|||
|
||||
// ShouldPrune determines if a file with the provided modification time should be
|
||||
// removed from the export log.
|
||||
func (manager *Manager) ShouldPrune(modtime time.Time) bool {
|
||||
return time.Since(modtime) > time.Duration(manager.Config.MaxBackupAge)*24*time.Hour
|
||||
func (exporter *Exporter) ShouldPrune(modtime time.Time) bool {
|
||||
return time.Since(modtime) > time.Duration(exporter.Config.MaxBackupAge)*24*time.Hour
|
||||
}
|
||||
|
||||
// Prune prunes all old exports
|
||||
func (manager *Manager) PruneExports(io stream.IOStream) error {
|
||||
sPath := manager.ArchivePath()
|
||||
func (exporter *Exporter) PruneExports(io stream.IOStream) error {
|
||||
sPath := exporter.ArchivePath()
|
||||
|
||||
// list all the files
|
||||
entries, err := manager.Core.Environment.ReadDir(sPath)
|
||||
entries, err := exporter.Core.Environment.ReadDir(sPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -36,20 +36,20 @@ func (manager *Manager) PruneExports(io stream.IOStream) error {
|
|||
}
|
||||
|
||||
// check if it should be pruned!
|
||||
if !manager.ShouldPrune(info.ModTime()) {
|
||||
if !exporter.ShouldPrune(info.ModTime()) {
|
||||
continue
|
||||
}
|
||||
|
||||
// assemble path, and then remove the file!
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// prune the snapshot log!
|
||||
_, err = manager.SnapshotsLog.Log()
|
||||
_, err = exporter.ExporterLogger.Log()
|
||||
return err
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package snapshots
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -43,7 +43,7 @@ type Snapshot struct {
|
|||
}
|
||||
|
||||
// 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")
|
||||
if err := instance.TryLock(); err != nil {
|
||||
|
|
@ -83,7 +83,7 @@ func (snapshots *Manager) NewSnapshot(instance *wisski.WissKI, io stream.IOStrea
|
|||
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 {
|
||||
stack := instance.Barrel()
|
||||
|
||||
|
|
@ -5,9 +5,10 @@ import (
|
|||
"net/http"
|
||||
|
||||
"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/snapshots"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component/snapshotslog"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
|
@ -15,9 +16,9 @@ import (
|
|||
type Info struct {
|
||||
component.ComponentBase
|
||||
|
||||
SnapshotManager *snapshots.Manager
|
||||
Instances *instances.Instances
|
||||
SnapshotsLog *snapshotslog.SnapshotsLog
|
||||
Exporter *exporter.Exporter
|
||||
Instances *instances.Instances
|
||||
SnapshotsLog *logger.Logger
|
||||
}
|
||||
|
||||
func (Info) Name() string { return "control-info" }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package info
|
||||
|
||||
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/pkg/httpx"
|
||||
"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{
|
||||
"snapshot": func(info *Info, instance *wisski.WissKI, str stream.IOStream) error {
|
||||
return info.SnapshotManager.MakeExport(
|
||||
return info.Exporter.MakeExport(
|
||||
str,
|
||||
snapshots.ExportTask{
|
||||
exporter.ExportTask{
|
||||
Dest: "",
|
||||
Instance: instance,
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"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/snapshotslog"
|
||||
"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/models"
|
||||
|
|
@ -20,10 +21,10 @@ import (
|
|||
type Instances struct {
|
||||
component.ComponentBase
|
||||
|
||||
TS *triplestore.Triplestore
|
||||
SQL *sql.SQL
|
||||
Meta *meta.Meta
|
||||
SnapshotsLog *snapshotslog.SnapshotsLog
|
||||
TS *triplestore.Triplestore
|
||||
SQL *sql.SQL
|
||||
Meta *meta.Meta
|
||||
ExporterLog *logger.Logger
|
||||
}
|
||||
|
||||
func (Instances) Name() string {
|
||||
|
|
@ -48,7 +49,7 @@ func (instances *Instances) use(wisski *wisski.WissKI) {
|
|||
wisski.SQL = instances.SQL
|
||||
wisski.TS = instances.TS
|
||||
wisski.Meta = instances.Meta
|
||||
wisski.SnapshotsLog = instances.SnapshotsLog
|
||||
wisski.ExporterLog = instances.ExporterLog
|
||||
}
|
||||
|
||||
// WissKI returns the WissKI with the provided slug, if it exists.
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ 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/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/info"
|
||||
"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/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/ssh"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component/static"
|
||||
|
|
@ -42,12 +43,12 @@ func (dis *Distillery) register(context component.ComponentPoolContext) []compon
|
|||
auto[*meta.Meta],
|
||||
|
||||
// Snapshots
|
||||
auto[*snapshots.Manager],
|
||||
auto[*snapshotslog.SnapshotsLog],
|
||||
auto[*snapshots.Config],
|
||||
auto[*snapshots.Bookkeeping],
|
||||
auto[*snapshots.Filesystem],
|
||||
auto[*snapshots.Pathbuilders],
|
||||
auto[*exporter.Exporter],
|
||||
auto[*logger.Logger],
|
||||
auto[*exporter.Config],
|
||||
auto[*exporter.Bookkeeping],
|
||||
auto[*exporter.Filesystem],
|
||||
auto[*exporter.Pathbuilders],
|
||||
|
||||
// Control server
|
||||
auto[*control.Control],
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ 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/exporter"
|
||||
"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/snapshots"
|
||||
"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/triplestore"
|
||||
|
|
@ -85,8 +85,8 @@ func (dis *Distillery) Triplestore() *triplestore.Triplestore {
|
|||
func (dis *Distillery) Instances() *instances.Instances {
|
||||
return e[*instances.Instances](dis)
|
||||
}
|
||||
func (dis *Distillery) ExportManager() *snapshots.Manager {
|
||||
return e[*snapshots.Manager](dis)
|
||||
func (dis *Distillery) Exporter() *exporter.Exporter {
|
||||
return e[*exporter.Exporter](dis)
|
||||
}
|
||||
|
||||
func (dis *Distillery) Installable() []component.Installable {
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ import "github.com/FAU-CDI/wisski-distillery/internal/models"
|
|||
|
||||
// Snapshots returns the list of snapshots of this WissKI
|
||||
func (wisski *WissKI) Snapshots() (snapshots []models.Export, err error) {
|
||||
return wisski.SnapshotsLog.For(wisski.Slug)
|
||||
return wisski.ExporterLog.For(wisski.Slug)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ package wisski
|
|||
|
||||
import (
|
||||
"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/snapshotslog"
|
||||
"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/models"
|
||||
|
|
@ -24,7 +25,7 @@ type WissKI struct {
|
|||
TS *triplestore.Triplestore
|
||||
SQL *sql.SQL
|
||||
|
||||
SnapshotsLog *snapshotslog.SnapshotsLog
|
||||
ExporterLog *logger.Logger
|
||||
}
|
||||
|
||||
// Save saves this instance in the bookkeeping table
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue