addon

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package addon implements "addon" built-in and its life-cycle hooks.

Index

Constants

View Source
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.

func SleepFn

func SleepFn(t *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

SleepFn implements built-in for sleep.

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) Freeze

func (a *Addon) Freeze()

Freeze implements starlark.Value.Freeze.

func (*Addon) GetModule added in v1.3.2

func (a *Addon) GetModule() *loader.Module

GetModule returns the version of loaded module

func (*Addon) Hash

func (a *Addon) Hash() (uint32, error)

Hash implements starlark.Value.Hash.

func (*Addon) Install

func (a *Addon) Install(ctx context.Context) error

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) Load

func (a *Addon) Load(ctx context.Context) (err error)

Load loads addon from its source and executes it.

func (*Addon) LoadedModules

func (a *Addon) LoadedModules() map[string]string

LoadedModules returns a mapping of loaded module paths to their text context.

func (*Addon) Match

func (a *Addon) Match(ctx context.Context) (bool, error)

Match is an optional matching hook. Returns true if addon matched the context and wishes to be installed.

func (*Addon) Remove

func (a *Addon) Remove(ctx context.Context) error

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

func (a *Addon) Status(ctx context.Context) (string, error)

Status returns current addon status. TODO(dmitry.ilyevskiy): Make return value structured.

func (*Addon) String

func (a *Addon) String() string

String implements starlark.Value.String.

func (*Addon) StringPretty

func (a *Addon) StringPretty() string

func (*Addon) Truth

func (a *Addon) Truth() starlark.Bool

Truth implements starlark.Value.Truth.

func (*Addon) Type

func (a *Addon) Type() string

Type implements starlark.Value.Type.

type SkyCtx

type SkyCtx struct {
	Attrs starlark.StringDict
}

SkyCtx implements starlark.HasSetField.

func NewCtx

func NewCtx() *SkyCtx

NewCtx returns new *SkyCtx.

func (*SkyCtx) Attr

func (c *SkyCtx) Attr(name string) (starlark.Value, error)

Attr implements starlark.HasAttrs.Attr.

func (*SkyCtx) AttrNames

func (c *SkyCtx) AttrNames() []string

AttrNames implements starlark.HasAttrs.AttrNames.

func (*SkyCtx) Freeze

func (c *SkyCtx) Freeze()

Freeze implements starlark.Value.Freeze.

func (*SkyCtx) Hash

func (c *SkyCtx) Hash() (uint32, error)

Hash implements starlark.Value.Hash.

func (*SkyCtx) SetField

func (c *SkyCtx) SetField(name string, v starlark.Value) error

SetField implements starlark.HasSetField.SetField.

func (*SkyCtx) String

func (c *SkyCtx) String() string

String implements starlark.Value.String.

func (*SkyCtx) Truth

func (c *SkyCtx) Truth() starlark.Bool

Truth implements starlark.Value.Truth. Returns true if object is non-empty.

func (*SkyCtx) Type

func (c *SkyCtx) Type() string

Type implements starlark.Value.Type.

Jump to

Keyboard shortcuts

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