Documentation ¶
Overview ¶
Package addon implements "addon" built-in and its life-cycle hooks.
Index ¶
- Constants
- func ErrorFn(t *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func NewAddonBuiltin(baseDir string, pkgs starlark.StringDict) *starlark.Builtin
- func SleepFn(t *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- type Addon
- func (a *Addon) Freeze()
- func (a *Addon) GetModule() *loader.Module
- func (a *Addon) Hash() (uint32, error)
- func (a *Addon) Install(ctx context.Context) error
- func (a *Addon) Load(ctx context.Context) (err error)
- func (a *Addon) LoadedModules() map[string]string
- func (a *Addon) Match(ctx context.Context) (bool, error)
- func (a *Addon) Remove(ctx context.Context) error
- func (a *Addon) Status(ctx context.Context) (string, error)
- func (a *Addon) String() string
- func (a *Addon) StringPretty() string
- func (a *Addon) Truth() starlark.Bool
- func (a *Addon) Type() string
- type SkyCtx
- func (c *SkyCtx) Attr(name string) (starlark.Value, error)
- func (c *SkyCtx) AttrNames() []string
- func (c *SkyCtx) Freeze()
- func (c *SkyCtx) Hash() (uint32, error)
- func (c *SkyCtx) SetField(name string, v starlark.Value) error
- func (c *SkyCtx) String() string
- func (c *SkyCtx) Truth() starlark.Bool
- func (c *SkyCtx) Type() string
Constants ¶
const ( // SkyCtxKey is a key of a thread-local value for a *SkyCtx object that // is set for addon execution (accessible by built-ins). SkyCtxKey = "context" // GoCtxKey is same as SkyCtxKey but for context.Context passed from // main runtime. GoCtxKey = "go_context" )
Variables ¶
This section is empty.
Functions ¶
func ErrorFn ¶
func ErrorFn(t *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
ErrorFn implements built-in for interrupting addon execution flow on error and printing its message.
func NewAddonBuiltin ¶
func NewAddonBuiltin(baseDir string, pkgs starlark.StringDict) *starlark.Builtin
NewAddonBuiltin returns new *starlark.Builtin for Addon with pre-declared pkgs.
Types ¶
type Addon ¶
type Addon struct { // TODO(dmitry.ilyevskiy): Place these inside subclassed context. Name string // contains filtered or unexported fields }
Addon implements single addons lifecycle hooks.
func NewAddonForTest ¶
func NewAddonForTest(name, filepath string, ctx, pkgs starlark.StringDict, f loader.ModuleReaderFactory, printW io.Writer) *Addon
NewAddonForTest returns an *Addon for testing.
func (*Addon) Install ¶
Install is called to install an addon. Callback defined by the plugin must perform all necessary work to install the plugin.
Available built-ins:
- TODO(dmitry.ilyevskiy): `kube' - controls Kubernets deployments.
- TODO(dmitry.ilyevskiy): `gcloud' - access to GCP API.
- TODO(dmitry.ilyevskiy): `vault' - access to Vault.
- TODO(dmitry.ilyevskiy): `url' - Generic HTTP client.
func (*Addon) LoadedModules ¶
LoadedModules returns a mapping of loaded module paths to their text context.
func (*Addon) Match ¶
Match is an optional matching hook. Returns true if addon matched the context and wishes to be installed.
func (*Addon) Remove ¶
Remove is called to remove the addon. Executes `remove' addon callback. Returns error if it doesn't exist (or if the callback returns error). TODO(dmitry.ilyevskiy): context must contain opaque info returned by install.
func (*Addon) Status ¶
Status returns current addon status. TODO(dmitry.ilyevskiy): Make return value structured.
func (*Addon) StringPretty ¶
type SkyCtx ¶
type SkyCtx struct {
Attrs starlark.StringDict
}
SkyCtx implements starlark.HasSetField.