Rename snapshots.Manager => exporter.Exporter
This commit is contained in:
parent
063f3f9b7d
commit
8d2855fdcb
23 changed files with 105 additions and 100 deletions
39
internal/component/exporter/extras_pathbuilders.go
Normal file
39
internal/component/exporter/extras_pathbuilders.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package exporter
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component/instances"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
)
|
||||
|
||||
type Pathbuilders struct {
|
||||
component.ComponentBase
|
||||
Instances *instances.Instances
|
||||
}
|
||||
|
||||
func (Pathbuilders) Name() string { return "pathbuilders" }
|
||||
|
||||
func (Pathbuilders) SnapshotNeedsRunning() bool { return true }
|
||||
|
||||
func (Pathbuilders) SnapshotName() string { return "pathbuilders" }
|
||||
|
||||
func (pbs *Pathbuilders) Snapshot(wisski models.Instance, context component.StagingContext) error {
|
||||
return context.AddDirectory(".", func() error {
|
||||
builders, err := pbs.Instances.Instance(wisski).AllPathbuilders(nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for name, bytes := range builders {
|
||||
if err := context.AddFile(name+".xml", func(file io.Writer) error {
|
||||
_, err := file.Write([]byte(bytes))
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue