Documentation ¶
Index ¶
Constants ¶
const EntryPoint = "main"
EntryPoint defines the name of the method that will be called when running a script (if it exists) in addition to executing top level statements.
Variables ¶
var ( // ErrMalformattedKwarg occurs when a keyword argument passed to a starlark function is malformatted. ErrMalformattedKwarg = errors.New("malformatted keyword argument for method call") // ErrMissingKwarg occurs when a keyword argument is missing from a starlark function call. ErrMissingKwarg = errors.New("missing keyword argument for method call") // ErrMissingArg occurs when an argument is missing from a starlark function call. ErrMissingArg = errors.New("missing argument for method call") // ErrInvalidArgType occurs when an argument provided to a starlark function call has the wrong type. ErrInvalidArgType = errors.New("invalid argument type provided to method") // ErrMissingLibrary occurs when attempting to load a library that doesn't exist. ErrMissingLibrary = errors.New("could not find library to load") // ErrInvalidTypeConversion occurs when converting a golang type to a starlark.Value fails. ErrInvalidTypeConversion = errors.New("could not convert golang value to starlark.Value") // ErrInvalidKwarg occurs when a user incorrectly passes a kwarg to a starlark function ErrInvalidKwarg = errors.New("invalid kwarg was passed to the method") )
Functions ¶
func ConvertToStarlark ¶ added in v0.4.0
ConvertToStarlark provides an exported function for converting starlark values
Types ¶
type ArgParser ¶
type ArgParser interface { RestrictKwargs(kwargs ...string) error GetParam(index int) (starlark.Value, error) GetString(index int) (string, error) GetStringByName(name string) (string, error) GetInt(index int) (int64, error) GetIntByName(name string) (int64, error) GetBool(index int) (bool, error) GetBoolByName(kwarg string) (bool, error) }
An ArgParser enables golang function implementations to retrieve the positional and keyword arguments provided to the starlark method call.
type Environment ¶ added in v0.3.0
type Environment struct {
// contains filtered or unexported fields
}
An Environment enables script libraries to receive dependencies via dependency injection and register hooks for cleanup after execution.
func (*Environment) Close ¶ added in v0.3.0
func (env *Environment) Close() (err error)
Close all handles opened by the environment.
func (*Environment) TrackHandle ¶ added in v0.3.0
func (env *Environment) TrackHandle(handle io.Closer)
TrackHandle ensures that the provided handle is closed after script execution.
type Func ¶
Func provides a simple wrapper that enables a golang function to be exposed to starlark.
type Library ¶
Library is a map of identifiers to underlying golang function implementations.
func (Library) Attr ¶ added in v0.3.0
Attr enables dot expressions and returns the starlark method with the provided name if it exists.
func (Library) AttrNames ¶ added in v0.3.0
AttrNames returns the set of methods provided by the library.
func (Library) Freeze ¶ added in v0.3.0
func (lib Library) Freeze()
Freeze is a no-op since library methods are expected to be safe for concurrent use.
func (Library) Hash ¶ added in v0.3.0
Hash will error since the library type is not intended to be hashable.
func (Library) String ¶ added in v0.3.0
String returns a description of the library, used to implement starlark.value
type Option ¶
type Option func(*Script)
An Option enables additional customization of script configuration and execution.
func WithLibraries ¶
WithLibraries adds one or more libraries to the script's execution environment.
func WithLibrary ¶
WithLibrary is an option to add a library to the script's execution environment.
func WithOutput ¶
WithOutput sets the destination for script execution output.
type Script ¶
type Script struct { io.Reader // Read() instructions to execute io.Writer // Write() execution output ID string Builtins map[string]Func Libraries map[string]Library // contains filtered or unexported fields }
A Script provides metadata and instructions to be executed by the interpreter.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
stdlib
|
|
assets
Package assets provides functionality to load asset files that were packed into the binary during compilation.
|
Package assets provides functionality to load asset files that were packed into the binary during compilation. |
file
Package file provides the standard file library used to perform common file operations.
|
Package file provides the standard file library used to perform common file operations. |
ssh
Package ssh provides functionality to execute commands on remote targets using SSH.
|
Package ssh provides functionality to execute commands on remote targets using SSH. |