wisski-cloud-distillery/internal/dis/component/server/admin/socket/actions/rebuild.go
Tom Wiesing 24ff81f7cd
Add local.settings.php to every instance
This commit adds a new file 'local.settings.php' to each distillery
instance. This file can be used to automatically edit global distillery
settings.
2024-04-01 16:43:11 +02:00

40 lines
925 B
Go

package actions
import (
"context"
"encoding/json"
"io"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth/scopes"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
)
type Rebuild struct {
component.Base
}
var (
_ WebsocketInstanceAction = (*Rebuild)(nil)
)
func (*Rebuild) Action() InstanceAction {
return InstanceAction{
Action: Action{
Name: "rebuild",
Scope: scopes.ScopeUserAdmin,
NumParams: 1,
},
}
}
func (r *Rebuild) Act(ctx context.Context, instance *wisski.WissKI, in io.Reader, out io.Writer, params ...string) error {
// read the flags of the instance to be rebuilt
var system models.System
if err := json.Unmarshal([]byte(params[0]), &system); err != nil {
return err
}
return instance.SystemManager().Apply(ctx, out, system)
}