Update to new goprogram version

This commit is contained in:
Tom Wiesing 2023-11-01 22:01:24 +01:00
parent 7bd9570bc0
commit 873fdcd5c2
No known key found for this signature in database
106 changed files with 478 additions and 825 deletions

View file

@ -17,7 +17,7 @@ func (sockets *Sockets) Actions() ActionMap {
return map[string]Action{
// generic actions
"backup": sockets.Generic(scopes.ScopeUserAdmin, "", 0, func(ctx context.Context, sockets *Sockets, in io.Reader, out io.Writer, params ...string) error {
return sockets.Dependencies.Exporter.MakeExport(
return sockets.dependencies.Exporter.MakeExport(
ctx,
out,
exporter.ExportTask{
@ -35,7 +35,7 @@ func (sockets *Sockets) Actions() ActionMap {
return err
}
instance, err := sockets.Dependencies.Provision.Provision(
instance, err := sockets.dependencies.Provision.Provision(
out,
ctx,
flags,
@ -54,7 +54,7 @@ func (sockets *Sockets) Actions() ActionMap {
// instance-specific actions!
"snapshot": sockets.Instance(scopes.ScopeUserAdmin, "", 0, func(ctx context.Context, socket *Sockets, instance *wisski.WissKI, in io.Reader, out io.Writer, params ...string) error {
return socket.Dependencies.Exporter.MakeExport(
return socket.dependencies.Exporter.MakeExport(
ctx,
out,
exporter.ExportTask{
@ -86,7 +86,7 @@ func (sockets *Sockets) Actions() ActionMap {
return instance.Barrel().Stack().Down(ctx, out)
}),
"purge": sockets.Instance(scopes.ScopeUserAdmin, "", 0, func(ctx context.Context, sockets *Sockets, instance *wisski.WissKI, in io.Reader, out io.Writer, params ...string) error {
return sockets.Dependencies.Purger.Purge(ctx, out, instance.Slug)
return sockets.dependencies.Purger.Purge(ctx, out, instance.Slug)
}),
"never": sockets.Generic(scopes.ScopeNever, "", 0, func(ctx context.Context, sockets *Sockets, in io.Reader, out io.Writer, params ...string) error {
panic("never called")

View file

@ -23,7 +23,7 @@ type Sockets struct {
actions lazy.Lazy[ActionMap]
Dependencies struct {
dependencies struct {
Provision *provision.Provision
Instances *instances.Instances
Exporter *exporter.Exporter
@ -40,7 +40,7 @@ func (socket *Sockets) Routes() component.Routes {
return component.Routes{
Prefix: "/api/v1/ws",
Exact: true,
Decorator: socket.Dependencies.Auth.Require(true, scopes.ScopeUserValid, nil),
Decorator: socket.dependencies.Auth.Require(true, scopes.ScopeUserValid, nil),
}
}
@ -54,7 +54,7 @@ func (sockets *Sockets) HandleRoute(ctx context.Context, path string) (http.Hand
// Serve handles a connection to the websocket api
func (socket *Sockets) Serve(conn httpx.WebSocketConnection) {
// handle the websocket connection!
name, err := socket.actions.Get(socket.Actions).Handle(socket.Dependencies.Auth, conn)
name, err := socket.actions.Get(socket.Actions).Handle(socket.dependencies.Auth, conn)
if err != nil {
zerolog.Ctx(conn.Context()).Err(err).Str("name", name).Msg("Error handling websocket")
}
@ -80,7 +80,7 @@ func (sockets *Sockets) Instance(scope component.Scope, scopeParam string, numPa
NumParams: numParams + 1,
Handle: func(ctx context.Context, in io.Reader, out io.Writer, params ...string) error {
instance, err := sockets.Dependencies.Instances.WissKI(ctx, params[0])
instance, err := sockets.dependencies.Instances.WissKI(ctx, params[0])
if err != nil {
return err
}