sandbox

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package sandbox defines the Lua sandbox used to run user scripts

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidInput indicates a required field is invalid
	ErrInvalidInput = errors.New("invalid input")
	// ErrInvalidWrappedValue indicates the wrapped value did not expand to a table
	ErrInvalidWrappedValue = errors.New("wrapped value must map to a lua table")
	// ErrMissingInput indicates a required field is missing
	ErrMissingInput = errors.New("required input missing")
	// ErrNotImplemented returned when method has not been implemented yet
	ErrNotImplemented = errors.New("not implemented")
	// ErrScriptFailed when the script fails to run
	ErrScriptFailed = errors.New("failure in user script")
)

Functions

This section is empty.

Types

type LuaMod

type LuaMod func(*Sandbox)

LuaMod defines a mod to add to Lua's sandbox

type Opt

type Opt func(*Sandbox)

Opt function to process options on sandbox

func WithContext

func WithContext(ctx context.Context) Opt

WithContext defines the context for a sandbox

func WithDryRun

func WithDryRun() Opt

WithDryRun indicates external changes should only be logged

func WithLog

func WithLog(log *logrus.Logger) Opt

WithLog specifies a logrus logger

func WithRegClient

func WithRegClient(rc *regclient.RegClient) Opt

WithRegClient specifies a regclient interface

func WithThrottle added in v0.5.0

func WithThrottle(t *throttle.Throttle) Opt

WithThrottle is used to limit various actions

type Sandbox

type Sandbox struct {
	// contains filtered or unexported fields
}

Sandbox defines a lua sandbox

func New

func New(name string, opts ...Opt) *Sandbox

New creates a new sandbox

func (*Sandbox) Close

func (s *Sandbox) Close()

Close is use to stop the sandbox

func (*Sandbox) RunScript

func (s *Sandbox) RunScript(script string) (err error)

RunScript is used to execute a script in the sandbox

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL