Documentation ¶
Overview ¶
Package starlark runs Pachyderm-specific starlark programs. It's recommended to import this as "ourstar" when also using go.starlark.net/starlark in the same package.
Index ¶
- Variables
- func Error(name string, err error) []zap.Field
- func FromStarlark(v starlark.Value) any
- func GetContext(t *starlark.Thread) context.Context
- func ReflectList[T any](xs []T) *starlark.List
- func RegisterPersonality(name string, opts Options)
- func Run(rctx context.Context, in string, opts Options, f RunFunc) (starlark.StringDict, error)
- func RunProgram(ctx context.Context, path string, opts Options) (starlark.StringDict, error)
- func RunScript(ctx context.Context, name string, script string, opts Options) (starlark.StringDict, error)
- func RunShell(ctx context.Context, path string, opts Options) error
- func Stack(name string, stack starlark.CallStack) zap.Field
- func Union(dicts ...starlark.StringDict) starlark.StringDict
- func UsePersonalityFlag(flagset *pflag.FlagSet)
- func Value(in any) starlark.Value
- type Any
- type Options
- type Reflect
- func (r *Reflect) Attr(name string) (starlark.Value, error)
- func (r *Reflect) AttrNames() []string
- func (r *Reflect) Cmp(y starlark.Value, _ int) (int, error)
- func (r *Reflect) Freeze()
- func (r *Reflect) Get(v starlark.Value) (starlark.Value, bool, error)
- func (r *Reflect) Hash() (uint32, error)
- func (r *Reflect) String() string
- func (r *Reflect) Truth() starlark.Bool
- func (r *Reflect) Type() string
- type RunFunc
- type ToGoer
Constants ¶
This section is empty.
Variables ¶
var Personality = personality{ Name: "", Options: Options{}, }
Personality is the personality selected from the command line.
Functions ¶
func FromStarlark ¶
FromStarlark returns a Go value for a Starlark value.
func GetContext ¶
GetContext returns a context.Context that applies to in the provided Starlark thread.
func ReflectList ¶
ReflectList returns a starlark.List from any Go slice.
func RegisterPersonality ¶
RegisterPersonality registers a personality; intended to be called from the init() section of modules that provide starlark bindings.
func Run ¶
Run runs the provided RunFunc. The input "in" is not run here, and only serves as a base path for resolving module loads.
func RunProgram ¶
RunProgram runs an on-disk Starlark script located at path.
func RunScript ¶
func RunScript(ctx context.Context, name string, script string, opts Options) (starlark.StringDict, error)
RunScript runs a script named "name" from the program text in "script".
func Union ¶
func Union(dicts ...starlark.StringDict) starlark.StringDict
func UsePersonalityFlag ¶
UsePersonalityFlag registers DefaultPersonality with the provided flagset.
Types ¶
type Options ¶
type Options struct { // Modules are built-in modules that are available for programs to load with "load". // "*.star" is always resolve to a disk path; everything else can be a key in this map. The // StringDict map value should be a map from function names to starlark.Builtin objects. Modules map[string]starlark.StringDict // Predefined is a dictionary of predefined values that don't need to be loaded. Predefined starlark.StringDict // REPLPredefined are values that are only predefined in an interactive shell. REPLPredefined starlark.StringDict // ThreadLocalVars are additional thread-local variables to set. Go code can get at these // environment variables with thread.Local(key). See GetContext() for an example. ThreadLocalVars map[string]any }
Options controls the Starlark execution environment.
type Reflect ¶
type Reflect struct {
Any any
}
Reflect is a starlark.Value that exposes the fields of struct types. For example, `package foo; struct Test { Foo string }` would be of type "foo.Test" and have one attribute, "Foo", in starlark, used like value.Foo.
type RunFunc ¶
type RunFunc func(fileOpts *syntax.FileOptions, thread *starlark.Thread, in string, module string, globals starlark.StringDict) (starlark.StringDict, error)
RunFunc is a function that can run a Starlark program in a thread. in is the string passed to Run, module is the canonical module name for that code, if applicable.