scriptlet

package
v6.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(programName string, src string, preDeclared []string) (*starlark.Program, error)

Compile compiles a scriptlet.

func Optional

func Optional(name string) scriptletFunction

Optional is a convenience wrapper declaring an optional function.

func Required

func Required(name string) scriptletFunction

Required is a convenience wrapper declaring a required function.

func StarlarkMarshal

func StarlarkMarshal(input any) (starlark.Value, error)

StarlarkMarshal converts input to a starlark Value. It only includes exported struct fields, and uses the "json" tag for field names.

func StarlarkUnmarshal

func StarlarkUnmarshal(input starlark.Value) (any, error)

StarlarkUnmarshal converts a Starlark value into a Go value. Only NoneType, Bool, Int, Float, String, List and Dict are supported.

func Validate

func Validate(compiler func(string, string) (*starlark.Program, error), programName string, src string, scriptletFunctions Declaration) error

Validate validates a scriptlet by compiling it and checking the presence of required and optional functions.

Types

type Declaration

type Declaration = map[scriptletFunction][]string

Declaration is a type alias to make scriptlet declaration easier.

type Loader

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

Loader holds the programs for the scriptlet.

func NewLoader

func NewLoader() *Loader

NewLoader creates a new Loader.

func (*Loader) Program

func (l *Loader) Program(name string, programName string) (*starlark.Program, *starlark.Thread, error)

Program returns a precompiled scriptlet program.

func (*Loader) Set

func (l *Loader) Set(compiler func(string, string) (*starlark.Program, error), programName string, src string) error

Set compiles a scriptlet into memory. If empty src is provided the current program is deleted.

Jump to

Keyboard shortcuts

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