Documentation ¶
Index ¶
- func GetConfigMapKey(gvk schema.GroupVersionKind) string
- func GetWildcardConfigMapKey(vm VM, gvk schema.GroupVersionKind) string
- func Match(pattern, text string, separators ...rune) bool
- func OpenSafeOs(L *lua.LState) int
- func SafeOsLoader(L *lua.LState) int
- func UnmarshalToUnstructured(resource string) (*unstructured.Unstructured, error)
- type ImpactedResource
- type K8SOperation
- type KnownTypeField
- type OverrideIgnoreDiff
- type ResourceAction
- type ResourceActionDefinition
- type ResourceActionParam
- type ResourceActions
- type ResourceHealthOverrides
- type ResourceOverride
- type VM
- func (vm VM) ExecuteHealthLua(obj *unstructured.Unstructured, script string) (*health.HealthStatus, error)
- func (vm VM) ExecuteResourceAction(obj *unstructured.Unstructured, script string) ([]ImpactedResource, error)
- func (vm VM) ExecuteResourceActionDiscovery(obj *unstructured.Unstructured, script string) ([]ResourceAction, error)
- func (vm VM) GetHealthScript(obj *unstructured.Unstructured) (string, bool, error)
- func (vm VM) GetResourceAction(obj *unstructured.Unstructured, actionName string) (ResourceActionDefinition, error)
- func (vm VM) GetResourceActionDiscovery(obj *unstructured.Unstructured) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfigMapKey ¶
func GetConfigMapKey(gvk schema.GroupVersionKind) string
func GetWildcardConfigMapKey ¶
func GetWildcardConfigMapKey(vm VM, gvk schema.GroupVersionKind) string
func OpenSafeOs ¶
func SafeOsLoader ¶
func UnmarshalToUnstructured ¶
func UnmarshalToUnstructured(resource string) (*unstructured.Unstructured, error)
UnmarshalToUnstructured unmarshals a resource representation in JSON to unstructured data
Types ¶
type ImpactedResource ¶
type ImpactedResource struct { UnstructuredObj *unstructured.Unstructured `json:"resource"` K8SOperation K8SOperation `json:"operation"` }
func UnmarshalToImpactedResources ¶
func UnmarshalToImpactedResources(resources string) ([]ImpactedResource, error)
UnmarshalToImpactedResources unmarshals an ImpactedResource array representation in JSON to ImpactedResource array
type K8SOperation ¶
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 ¶
func (op K8SOperation) MarshalJSON() ([]byte, error)
func (*K8SOperation) UnmarshalJSON ¶
func (op *K8SOperation) UnmarshalJSON(data []byte) error
type KnownTypeField ¶
type OverrideIgnoreDiff ¶
type OverrideIgnoreDiff struct { // JSONPointers is a JSON path list following the format defined in RFC4627 (https://datatracker.ietf.org/doc/html/rfc6902#section-3) JSONPointers []string `json:"jsonPointers" protobuf:"bytes,1,rep,name=jSONPointers"` // JQPathExpressions is a JQ path list that will be evaludated during the diff process JQPathExpressions []string `json:"jqPathExpressions" protobuf:"bytes,2,opt,name=jqPathExpressions"` // ManagedFieldsManagers is a list of trusted managers. Fields mutated by those managers will take precedence over the // desired state defined in the SCM and won't be displayed in diffs ManagedFieldsManagers []string `json:"managedFieldsManagers" protobuf:"bytes,3,opt,name=managedFieldsManagers"` }
OverrideIgnoreDiff contains configurations about how fields should be ignored during diffs between the desired state and live state
type ResourceAction ¶
type ResourceAction struct { Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` Params []ResourceActionParam `json:"params,omitempty" protobuf:"bytes,2,rep,name=params"` Disabled bool `json:"disabled,omitempty" protobuf:"varint,3,opt,name=disabled"` }
TODO: describe this type TODO: describe members of this type
type ResourceActionDefinition ¶
type ResourceActionDefinition struct { Name string `json:"name" protobuf:"bytes,1,opt,name=name"` ActionLua string `json:"action.lua" yaml:"action.lua" protobuf:"bytes,2,opt,name=actionLua"` }
TODO: describe this type TODO: describe members of this type
type ResourceActionParam ¶
type ResourceActionParam struct { Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` Value string `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"` Type string `json:"type,omitempty" protobuf:"bytes,3,opt,name=type"` Default string `json:"default,omitempty" protobuf:"bytes,4,opt,name=default"` }
TODO: describe this type TODO: describe members of this type
type ResourceActions ¶
type ResourceActions struct { ActionDiscoveryLua string `json:"discovery.lua,omitempty" yaml:"discovery.lua,omitempty" protobuf:"bytes,1,opt,name=actionDiscoveryLua"` Definitions []ResourceActionDefinition `json:"definitions,omitempty" protobuf:"bytes,2,rep,name=definitions"` }
TODO: describe this type TODO: describe members of this type
type ResourceHealthOverrides ¶
type ResourceHealthOverrides map[string]ResourceOverride
func (ResourceHealthOverrides) GetResourceHealth ¶
func (overrides ResourceHealthOverrides) GetResourceHealth(obj *unstructured.Unstructured) (*health.HealthStatus, error)
type ResourceOverride ¶
type ResourceOverride struct { HealthLua string `protobuf:"bytes,1,opt,name=healthLua"` UseOpenLibs bool `protobuf:"bytes,5,opt,name=useOpenLibs"` Actions string `protobuf:"bytes,3,opt,name=actions"` IgnoreDifferences OverrideIgnoreDiff `protobuf:"bytes,2,opt,name=ignoreDifferences"` IgnoreResourceUpdates OverrideIgnoreDiff `protobuf:"bytes,6,opt,name=ignoreResourceUpdates"` KnownTypeFields []KnownTypeField `protobuf:"bytes,4,opt,name=knownTypeFields"` }
ResourceOverride holds configuration to customize resource diffing and health assessment TODO: describe the members of this type
func (*ResourceOverride) GetActions ¶
func (o *ResourceOverride) GetActions() (ResourceActions, error)
TODO: describe this method
func (ResourceOverride) MarshalJSON ¶
func (s ResourceOverride) MarshalJSON() ([]byte, error)
TODO: describe this method
func (*ResourceOverride) UnmarshalJSON ¶
func (s *ResourceOverride) UnmarshalJSON(data []byte) error
TODO: describe this method
type VM ¶
type VM struct { ResourceOverrides map[string]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) ([]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) (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)