lua

package
v2.9.18 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigMapKey added in v2.1.0

func GetConfigMapKey(gvk schema.GroupVersionKind) string

func GetWildcardConfigMapKey added in v2.6.0

func GetWildcardConfigMapKey(vm VM, gvk schema.GroupVersionKind) string

func OpenSafeOs

func OpenSafeOs(L *lua.LState) int

func SafeOsLoader

func SafeOsLoader(L *lua.LState) int

Types

type ImpactedResource added in v2.8.0

type ImpactedResource struct {
	UnstructuredObj *unstructured.Unstructured `json:"resource"`
	K8SOperation    K8SOperation               `json:"operation"`
}

func UnmarshalToImpactedResources added in v2.8.0

func UnmarshalToImpactedResources(resources string) ([]ImpactedResource, error)

UnmarshalToImpactedResources unmarshals an ImpactedResource array representation in JSON to ImpactedResource array

type K8SOperation added in v2.8.0

type K8SOperation string

This struct represents a wrapper, that is returned from Lua custom action script, around the unstructured k8s resource + a k8s operation that will need to be performed on this returned resource. Currently only "create" and "patch" operations are supported for custom actions. This replaces the traditional architecture of "Lua action returns the source resource for ArgoCD to patch". This enables ArgoCD to create NEW resources upon custom action. Note that the Lua code in the custom action is coupled to this type, since Lua json output is then unmarshalled to this struct. Avoided using iota, since need the mapping of the string value the end users will write in Lua code ("create" and "patch"). TODO: maybe there is a nicer general way to marshal and unmarshal, instead of explicit iteration over the enum values.

const (
	CreateOperation K8SOperation = "create"
	PatchOperation  K8SOperation = "patch"
)

func (K8SOperation) MarshalJSON added in v2.8.0

func (op K8SOperation) MarshalJSON() ([]byte, error)

func (*K8SOperation) UnmarshalJSON added in v2.8.0

func (op *K8SOperation) UnmarshalJSON(data []byte) error

type ResourceHealthOverrides

type ResourceHealthOverrides map[string]appv1.ResourceOverride

func (ResourceHealthOverrides) GetResourceHealth

func (overrides ResourceHealthOverrides) GetResourceHealth(obj *unstructured.Unstructured) (*health.HealthStatus, error)

type VM

type VM struct {
	ResourceOverrides map[string]appv1.ResourceOverride
	// UseOpenLibs flag to enable open libraries. Libraries are disabled by default while running, but enabled during testing to allow the use of print statements
	UseOpenLibs bool
}

VM Defines a struct that implements the luaVM

func (VM) ExecuteHealthLua

func (vm VM) ExecuteHealthLua(obj *unstructured.Unstructured, script string) (*health.HealthStatus, error)

ExecuteHealthLua runs the lua script to generate the health status of a resource

func (VM) ExecuteResourceAction

func (vm VM) ExecuteResourceAction(obj *unstructured.Unstructured, script string) ([]ImpactedResource, error)

func (VM) ExecuteResourceActionDiscovery

func (vm VM) ExecuteResourceActionDiscovery(obj *unstructured.Unstructured, script string) ([]appv1.ResourceAction, error)

func (VM) GetHealthScript

func (vm VM) GetHealthScript(obj *unstructured.Unstructured) (string, bool, error)

GetHealthScript attempts to read lua script from config and then filesystem for that resource

func (VM) GetResourceAction

func (vm VM) GetResourceAction(obj *unstructured.Unstructured, actionName string) (appv1.ResourceActionDefinition, error)

GetResourceAction attempts to read lua script from config and then filesystem for that resource

func (VM) GetResourceActionDiscovery

func (vm VM) GetResourceActionDiscovery(obj *unstructured.Unstructured) (string, error)

Jump to

Keyboard shortcuts

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