Move wisski instance code to separate package
This commit is contained in:
parent
7c3c84e116
commit
063f3f9b7d
67 changed files with 533 additions and 409 deletions
|
|
@ -6,10 +6,10 @@ import (
|
|||
|
||||
_ "embed"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component/instances"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component/static"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/config"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ type indexPageContext struct {
|
|||
|
||||
Config *config.Config
|
||||
|
||||
Instances []instances.WissKIInfo
|
||||
Instances []wisski.WissKIInfo
|
||||
|
||||
TotalCount int
|
||||
RunningCount int
|
||||
|
|
@ -42,7 +42,7 @@ func (info *Info) indexPageAPI(r *http.Request) (idx indexPageContext, err error
|
|||
}
|
||||
|
||||
// get all of their info!
|
||||
idx.Instances = make([]instances.WissKIInfo, len(all))
|
||||
idx.Instances = make([]wisski.WissKIInfo, len(all))
|
||||
for i, instance := range all {
|
||||
{
|
||||
i := i
|
||||
|
|
@ -61,7 +61,7 @@ func (info *Info) indexPageAPI(r *http.Request) (idx indexPageContext, err error
|
|||
|
||||
// get the log entries
|
||||
group.Go(func() (err error) {
|
||||
idx.Backups, err = info.Instances.ExportLogFor("")
|
||||
idx.Backups, err = info.SnapshotsLog.For("")
|
||||
return
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/component"
|
||||
"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"
|
||||
)
|
||||
|
|
@ -16,6 +17,7 @@ type Info struct {
|
|||
|
||||
SnapshotManager *snapshots.Manager
|
||||
Instances *instances.Instances
|
||||
SnapshotsLog *snapshotslog.SnapshotsLog
|
||||
}
|
||||
|
||||
func (Info) Name() string { return "control-info" }
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/component/instances"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component/static"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
|
||||
)
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ type instancePageContext struct {
|
|||
Time time.Time
|
||||
|
||||
Instance models.Instance
|
||||
Info instances.WissKIInfo
|
||||
Info wisski.WissKIInfo
|
||||
}
|
||||
|
||||
func (info *Info) instancePageAPI(r *http.Request) (is instancePageContext, err error) {
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
package info
|
||||
|
||||
import (
|
||||
"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/wisski"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
|
||||
"github.com/tkw1536/goprogram/status"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
||||
type instanceActionFunc = func(info *Info, instance instances.WissKI, str stream.IOStream) error
|
||||
type instanceActionFunc = func(info *Info, instance *wisski.WissKI, str stream.IOStream) error
|
||||
|
||||
var socketInstanceActions = map[string]instanceActionFunc{
|
||||
"snapshot": func(info *Info, instance instances.WissKI, str stream.IOStream) error {
|
||||
"snapshot": func(info *Info, instance *wisski.WissKI, str stream.IOStream) error {
|
||||
return info.SnapshotManager.MakeExport(
|
||||
str,
|
||||
snapshots.ExportTask{
|
||||
Dest: "",
|
||||
Instance: &instance,
|
||||
Instance: instance,
|
||||
|
||||
StagingOnly: false,
|
||||
},
|
||||
)
|
||||
},
|
||||
"rebuild": func(_ *Info, instance instances.WissKI, str stream.IOStream) error {
|
||||
"rebuild": func(_ *Info, instance *wisski.WissKI, str stream.IOStream) error {
|
||||
return instance.Build(str, true)
|
||||
},
|
||||
"update": func(_ *Info, instance instances.WissKI, str stream.IOStream) error {
|
||||
"update": func(_ *Info, instance *wisski.WissKI, str stream.IOStream) error {
|
||||
return instance.BlindUpdate(str)
|
||||
},
|
||||
"cron": func(_ *Info, instance instances.WissKI, str stream.IOStream) error {
|
||||
"cron": func(_ *Info, instance *wisski.WissKI, str stream.IOStream) error {
|
||||
return instance.Cron(str)
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue