starlark

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package starlark provides starlark builtins to be used in the diagnostics script.

Index

Constants

View Source
const UnknownDefaultErrStr = "unknown value to be set as default"

Variables

This section is empty.

Functions

func CapaProviderFn

func CapaProviderFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

CapaProviderFn is a built-in starlark function that collects compute resources from a k8s cluster Starlark format: capa_provider(kube_config=kube_config(), ssh_config=ssh_config()[workload_cluster=<name>, namespace=<namespace>, nodes=["foo", "bar], labels=["bar", "baz"]])

func CapvProviderFn

func CapvProviderFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

CapvProviderFn is a built-in starlark function that collects compute resources from a k8s cluster Starlark format: capv_provider(kube_config=kube_config(), ssh_config=ssh_config()[workload_cluster=<name>, namespace=<namespace>, nodes=["foo", "bar], labels=["bar", "baz"]])

func GetConstructor

func GetConstructor(val starlark.Value) (string, error)

func GoToStarlarkValue

func GoToStarlarkValue(val interface{}) (starlark.Value, error)

GoToStarlarkValue converts Go value val to its Starlark value/type. It supports basic numeric types, string, bool, and slice/arrays.

func KubeCaptureFn

func KubeCaptureFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

KubeCaptureFn is the Starlark built-in for the fetching kubernetes objects and returns the result as a Starlark value containing the file path and error message, if any Starlark format: kube_capture(what="logs" [, groups="core", namespaces=["default"], kube_config=kube_config()])

func KubeConfigFn

func KubeConfigFn(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

KubeConfigFn is built-in starlark function that wraps the kwargs into a dictionary value. The result is also added to the thread for other built-in to access. Starlark: kube_config(path=kubecf/path)

func KubeGetFn

func KubeGetFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

KubeGetFn is a starlark built-in for the fetching kubernetes objects

func KubeNodesProviderFn

func KubeNodesProviderFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

KubeNodesProviderFn is a built-in starlark function that collects compute resources from a k8s cluster Starlark format: kube_nodes_provider([kube_config=kube_config(), ssh_config=ssh_config(), names=["foo", "bar], labels=["bar", "baz"]])

func SetDefaultsFunc

func SetDefaultsFunc(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, _ []starlark.Tuple) (starlark.Value, error)

SetDefaultsFunc is the built-in fn that saves the arguments to the local Starlark thread. Starlark format: set_defaults([ssh_config()][, kube_config()][, resources()])

func SshConfigFn

func SshConfigFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

SshConfigFn is the backing built-in fn that saves and returns its argument as struct value. Starlark format: ssh_config(username=name[, port][, private_key_path][,max_retries][,conn_timeout][,jump_user][,jump_host])

Types

type Executor

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

func New

func New() *Executor

func (*Executor) AddPredeclared

func (e *Executor) AddPredeclared(name string, value starlark.Value)

AddPredeclared predeclared

func (*Executor) Exec

func (e *Executor) Exec(name string, source io.Reader) error

type GoValue

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

GoValue represents an inherent Go value which can be converted to a Starlark value/type

func NewGoValue

func NewGoValue(val interface{}) *GoValue

NewGoValue creates a value with inherent Go type

func (*GoValue) ToDict

func (v *GoValue) ToDict() (*starlark.Dict, error)

ToDict converts map v to a *starlark.Dict value where the key and value can be of an arbitrary types of string, bool, numeric, or []T.

func (*GoValue) ToList

func (v *GoValue) ToList() (*starlark.List, error)

ToList converts v of type []T to a *starlark.List value where the elements can be of an arbitrary types of string, bool, numeric, or []T.

func (*GoValue) ToStarlarkStruct

func (v *GoValue) ToStarlarkStruct(constructorName string) (*starlarkstruct.Struct, error)

ToStarlarkStruct converts a v of type struct or map to a *starlarkstruct.Struct value

func (*GoValue) ToStarlarkValue

func (v *GoValue) ToStarlarkValue() (starlark.Value, error)

func (*GoValue) ToStringDict

func (v *GoValue) ToStringDict() (starlark.StringDict, error)

ToStringDict converts map v to a starlark.StringDict value where the key is expected to be a string and the value to be a string, bool, numeric, or []T.

func (*GoValue) ToTuple

func (v *GoValue) ToTuple() (starlark.Tuple, error)

ToTuple converts v of type []T to a starlark.Tuple value where the elements can be of an arbitrary types of string, bool, numeric, or []T.

func (*GoValue) Value

func (v *GoValue) Value() interface{}

Value returns the original value as an interface{}

Jump to

Keyboard shortcuts

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