dynamo-browse/internal/dynamo-browse/services/scriptmanager/opts.go
Leon Mika 12909c89ee Removed internal os module
Module "os" is no longer needed since Risor comes with an "os" and "exec" module out of the box now.
2024-03-03 08:54:57 +11:00

27 lines
592 B
Go

package scriptmanager
import (
"context"
"github.com/risor-io/risor/limits"
)
// scriptEnv is the runtime environment for a particular script execution
type scriptEnv struct {
filename string
}
type scriptEnvKeyType struct{}
var scriptEnvKey = scriptEnvKeyType{}
func scriptEnvFromCtx(ctx context.Context) scriptEnv {
perms, _ := ctx.Value(scriptEnvKey).(scriptEnv)
return perms
}
func ctxWithScriptEnv(ctx context.Context, perms scriptEnv) context.Context {
newCtx := context.WithValue(ctx, scriptEnvKey, perms)
newCtx = limits.WithLimits(newCtx, limits.New())
return newCtx
}