language

package
v0.0.0-...-473deaa Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Copyright 2020 Devtron Labs Pvt Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 Devtron Labs Pvt Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 Devtron Labs Pvt Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	APPLY  string = "APPLY"
	PATCH  string = "PATCH"
	DELETE string = "DELETE"
)
View Source
const StepCompleted = "Completed"
View Source
const StepInProgress = "InProgress"

Variables

This section is empty.

Functions

func Generate

func Generate(size int) string

func HttpRequest

func HttpRequest(url string) (map[string]interface{}, error)

func JsonDelete

func JsonDelete(json, pattern string) valHolder

func JsonEdit

func JsonEdit(json, pattern string, value interface{}) valHolder

func JsonSelect

func JsonSelect(json, pattern string) valHolder

func NewKubectl

func NewKubectl() *kubectl

func SortManifestsByKind

func SortManifestsByKind(manifests []unstructured.Unstructured, ordering KindSortOrder) []unstructured.Unstructured

sort manifests by kind.

Results are sorted by 'ordering', keeping order of items with equal kind/priority

func SplitResourceArgument

func SplitResourceArgument(arg string) []string

SplitResourceArgument splits the argument with commas and returns unique strings in the original order.

func StripQuotes

func StripQuotes(text string) string

func YamlDelete

func YamlDelete(yml, pattern string) valHolder

func YamlEdit

func YamlEdit(yml, pattern string, value interface{}) valHolder

func YamlSelect

func YamlSelect(yml, pattern string) valHolder

Types

type ApplyRequest

type ApplyRequest struct {
	Manifest  string `protobuf:"bytes,1,req,name=manifest" json:"manifest,omitempty"`
	Namespace string `protobuf:"bytes,2,req,name=namespace" json:"namespace,omitempty"`
	Force     *bool  `protobuf:"bytes,3,req,name=force" json:"force,omitempty"`
	Validate  *bool  `protobuf:"bytes,4,req,name=validate" json:"validate,omitempty"`
}

type ApplyResponse

type ApplyResponse struct {
	Message          string                  `protobuf:"bytes,1,req,name=message" json:"message,omitempty"`
	Err              string                  `protobuf:"bytes,2,req,name=err" json:"err,omitempty"`
	Name             string                  `protobuf:"bytes,3,req,name=name" json:"name,omitempty"`
	Namespace        string                  `protobuf:"bytes,4,req,name=namespace" json:"namespace,omitempty"`
	GroupVersionKind schema.GroupVersionKind `protobuf:"bytes,5,req,name=groupVersionKind" json:"groupVersionKind,omitempty"`
}

type ArgsProcessor

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

func NewFactory

func NewFactory(mapper *Mapper) *ArgsProcessor

func (*ArgsProcessor) AddError

func (a *ArgsProcessor) AddError(err error)

func (*ArgsProcessor) ReplaceAliases

func (a *ArgsProcessor) ReplaceAliases(input string) string

ReplaceAliases accepts an argument and tries to expand any existing aliases found in it

func (*ArgsProcessor) ResourceTuples

func (a *ArgsProcessor) ResourceTuples() []resourceTuple

func (*ArgsProcessor) ResourceTypeOrNameArgs

func (a *ArgsProcessor) ResourceTypeOrNameArgs(args ...string)

ResourceTypeOrNameArgs indicates that the builder should accept arguments of the form `(<type1>[,<type2>,...]|<type> <name1>[,<name2>,...])`. When one argument is received, the types provided will be retrieved from the server (and be comma delimited). When two or more arguments are received, they must be a single type and resource name(s). The allowEmptySelector permits to select all the resources (via Everything func).

func (*ArgsProcessor) ResourceTypes

func (a *ArgsProcessor) ResourceTypes(types ...string)

ResourceTypes is a list of types of resources to operate on, when listing objects on the server or retrieving objects that match a selector.

type Arguments

type Arguments struct {
	// Parameters is the list of parameters to pass to the template or workflow
	// +patchStrategy=merge
	// +patchMergeKey=name
	Parameters []Parameter `json:"parameters,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,1,rep,name=parameters"`
}

Arguments to a template

type Command

type Command struct {
	Type string
}

type DAGTask

type DAGTask struct {
	// Name is the name of the target
	Name string `json:"name" protobuf:"bytes,1,opt,name=name"`

	// Name of template to execute
	Template string `json:"template" protobuf:"bytes,2,opt,name=template"`

	// Arguments are the parameter and artifact arguments to the template
	Arguments Arguments `json:"arguments,omitempty" protobuf:"bytes,3,opt,name=arguments"`

	// Dependencies are name of other targets which this depends on
	Dependencies []string `json:"dependencies,omitempty" protobuf:"bytes,5,rep,name=dependencies"`

	// OnExit is a template reference which is invoked at the end of the
	// template, irrespective of the success, failure, or error of the
	// primary template.
	OnExit string `json:"onExit,omitempty" protobuf:"bytes,11,opt,name=onExit"`
}

DAGTask represents a node in the graph during DAG execution

type DAGTemplate

type DAGTemplate struct {
	// Target are one or more names of targets to execute in a DAG
	Target string `json:"target,omitempty" protobuf:"bytes,1,opt,name=target"`

	// Tasks are a list of DAG tasks
	// +patchStrategy=merge
	// +patchMergeKey=name
	Tasks []DAGTask `json:"tasks" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,2,rep,name=tasks"`

	// This flag is for DAG logic. The DAG logic has a built-in "fail fast" feature to stop scheduling new steps,
	// as soon as it detects that one of the DAG nodes is failed. Then it waits until all DAG nodes are completed
	// before failing the DAG itself.
	// The FailFast flag default is true,  if set to false, it will allow a DAG to run all branches of the DAG to
	// completion (either success or failure), regardless of the failed outcomes of branches in the DAG.
	// More info and example about this feature at https://github.com/argoproj/argo/issues/1442
	FailFast *bool `json:"failFast,omitempty" protobuf:"varint,3,opt,name=failFast"`
}

DAGTemplate is a template subtype for directed acyclic graph templates

type DataType

type DataType string
const (
	STRING  DataType = "STRING"
	BOOLEAN DataType = "BOOLEAN"
	INT     DataType = "INT"
	FLOAT   DataType = "FLOAT"
	NIL     DataType = "NIL"
	ID      DataType = "ID"
	ERR     DataType = "ERROR"
)

type DeleteRequest

type DeleteRequest struct {
	Name             string                  `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
	Namespace        string                  `protobuf:"bytes,2,req,name=namespace" json:"namespace,omitempty"`
	GroupVersionKind schema.GroupVersionKind `protobuf:"bytes,3,req,name=groupVersionKind" json:"groupVersionKind,omitempty"`
	Force            *bool                   `protobuf:"bytes,4,req,name=force" json:"force,omitempty"`
}

type GetRequest

type GetRequest struct {
	Name             string                  `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
	Namespace        string                  `protobuf:"bytes,2,req,name=namespace" json:"namespace,omitempty"`
	GroupVersionKind schema.GroupVersionKind `protobuf:"bytes,3,req,name=groupVersionKind" json:"groupVersionKind,omitempty"`
}

type HealthStatus

type HealthStatus struct {
	Status  health.HealthStatusCode `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"`
	Message string                  `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}

type Inputs

type Inputs Arguments

type KindSortOrder

type KindSortOrder []string

KindSortOrder is an ordering of Kinds.

var InstallOrder KindSortOrder = []string{
	"Namespace",
	"NetworkPolicy",
	"ResourceQuota",
	"LimitRange",
	"PodSecurityPolicy",
	"PodDisruptionBudget",
	"ServiceAccount",
	"Secret",
	"SecretList",
	"ConfigMap",
	"StorageClass",
	"PersistentVolume",
	"PersistentVolumeClaim",
	"CustomResourceDefinition",
	"ClusterRole",
	"ClusterRoleList",
	"ClusterRoleBinding",
	"ClusterRoleBindingList",
	"Role",
	"RoleList",
	"RoleBinding",
	"RoleBindingList",
	"Service",
	"DaemonSet",
	"Pod",
	"ReplicationController",
	"ReplicaSet",
	"Deployment",
	"HorizontalPodAutoscaler",
	"StatefulSet",
	"Job",
	"CronJob",
	"Ingress",
	"APIService",
}

InstallOrder is the order in which manifests should be installed (by Kind).

Those occurring earlier in the list get installed before those occurring later in the list.

var UninstallOrder KindSortOrder = []string{
	"APIService",
	"Ingress",
	"Service",
	"CronJob",
	"Job",
	"StatefulSet",
	"HorizontalPodAutoscaler",
	"Deployment",
	"ReplicaSet",
	"ReplicationController",
	"Pod",
	"DaemonSet",
	"RoleBindingList",
	"RoleBinding",
	"RoleList",
	"Role",
	"ClusterRoleBindingList",
	"ClusterRoleBinding",
	"ClusterRoleList",
	"ClusterRole",
	"CustomResourceDefinition",
	"PersistentVolumeClaim",
	"PersistentVolume",
	"StorageClass",
	"ConfigMap",
	"SecretList",
	"Secret",
	"ServiceAccount",
	"PodDisruptionBudget",
	"PodSecurityPolicy",
	"LimitRange",
	"ResourceQuota",
	"NetworkPolicy",
	"Namespace",
}

UninstallOrder is the order in which manifests should be uninstalled (by Kind).

Those occurring earlier in the list get uninstalled before those occurring later in the list.

type KlangListener

type KlangListener struct {
	*parser.BaseKlangListener
	// contains filtered or unexported fields
}

func NewKlangListener

func NewKlangListener(mapper *Mapper) *KlangListener

func (*KlangListener) EnterIf_stat

func (l *KlangListener) EnterIf_stat(ctx *parser.If_statContext)

EnterIf_stat is called when production if_stat is entered.

func (*KlangListener) EnterWhile_stat

func (l *KlangListener) EnterWhile_stat(ctx *parser.While_statContext)

EnterWhile_stat is called when production while_stat is entered.

func (*KlangListener) ExitAssignment

func (l *KlangListener) ExitAssignment(ctx *parser.AssignmentContext)

ExitAssignment is called when production assignment is exited.

func (*KlangListener) ExitBlock

func (l *KlangListener) ExitBlock(ctx *parser.BlockContext)

func (*KlangListener) ExitExit_fn

func (l *KlangListener) ExitExit_fn(ctx *parser.Exit_fnContext)

func (*KlangListener) ExitIf_stat

func (l *KlangListener) ExitIf_stat(ctx *parser.If_statContext)

ExitIf_stat is called when production if_stat is exited.

func (*KlangListener) ExitJson_delete_fn

func (l *KlangListener) ExitJson_delete_fn(ctx *parser.Json_delete_fnContext)

ExitJson_delete_fn is called when production json_delete_fn is exited.

func (*KlangListener) ExitJson_edit_fn

func (l *KlangListener) ExitJson_edit_fn(ctx *parser.Json_edit_fnContext)

ExitJsonselector_assignment is called when production jsonselector_assignment is exited.

func (*KlangListener) ExitKube_json_delete_fn

func (l *KlangListener) ExitKube_json_delete_fn(ctx *parser.Kube_json_delete_fnContext)

ExitJson_delete_fn is called when production json_delete_fn is exited.

func (*KlangListener) ExitKube_json_edit_fn

func (l *KlangListener) ExitKube_json_edit_fn(ctx *parser.Kube_json_edit_fnContext)

ExitKube_json_edit_fn is called when production kube_yaml_edit_fn is exited.

func (*KlangListener) ExitKube_yaml_delete_fn

func (l *KlangListener) ExitKube_yaml_delete_fn(ctx *parser.Kube_yaml_delete_fnContext)

func (*KlangListener) ExitKube_yaml_edit_fn

func (l *KlangListener) ExitKube_yaml_edit_fn(ctx *parser.Kube_yaml_edit_fnContext)

ExitKube_yaml_edit_fn is called when production kube_yaml_edit_fn is exited.

func (*KlangListener) ExitLog

func (l *KlangListener) ExitLog(ctx *parser.LogContext)

ExitLog is called when production log is exited.

func (*KlangListener) ExitSleep_fn

func (l *KlangListener) ExitSleep_fn(ctx *parser.Sleep_fnContext)

func (*KlangListener) ExitStat

func (l *KlangListener) ExitStat(ctx *parser.StatContext)

func (*KlangListener) ExitStepInfo

func (l *KlangListener) ExitStepInfo(ctx *parser.StepInfoContext)

ExitStepInfo is called when production stepInfo is exited.

func (*KlangListener) ExitWhile_stat

func (l *KlangListener) ExitWhile_stat(ctx *parser.While_statContext)

ExitWhile_stat is called when production while_stat is exited.

func (*KlangListener) ExitYaml_delete_fn

func (l *KlangListener) ExitYaml_delete_fn(ctx *parser.Yaml_delete_fnContext)

ExitYaml_delete_fn is called when production yaml_delete_fn is exited.

func (*KlangListener) ExitYaml_edit_fn

func (l *KlangListener) ExitYaml_edit_fn(ctx *parser.Yaml_edit_fnContext)

ExitYamledit_fn is called when production yamledit_fn is exited.

func (*KlangListener) GetTextFromStringOrId

func (l *KlangListener) GetTextFromStringOrId(stringOrId *parser.String_or_idContext) string

func (*KlangListener) KubernetesResources

func (l *KlangListener) KubernetesResources() map[string][]Resource

func (*KlangListener) Values

func (l *KlangListener) Values() map[string]valHolder

type KlangStatusUpdater

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

func (*KlangStatusUpdater) ExitStepInfo

func (l *KlangStatusUpdater) ExitStepInfo(ctx *parser2.StepInfoContext)

ExitStepInfo is called when production stepInfo is exited.

func (*KlangStatusUpdater) ReceiveStep

func (l *KlangStatusUpdater) ReceiveStep(name string)

type ListRequest

type ListRequest struct {
	Namespace            string                      `protobuf:"bytes,1,req,name=namespace" json:"namespace,omitempty"`
	GroupVersionResource schema.GroupVersionResource `protobuf:"bytes,2,req,name=groupVersionResource" json:"groupVersionResource,omitempty"`
	metav1.ListOptions   `json:",inline"`
}

type ListResponse

type ListResponse struct {
	Manifests []string `protobuf:"bytes,1,req,name=manifests" json:"manifests,omitempty"`
}

type LogicalOperator

type LogicalOperator int
const (
	EQ LogicalOperator = iota
	NEQ
	LTEQ
	LT
	GTEQ
	GT
)

type ManifestResponse

type ManifestResponse struct {
	Manifest string `protobuf:"bytes,1,req,name=manifest" json:"manifest,omitempty"`
}

type Mapper

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

func NewMapperFactory

func NewMapperFactory() *Mapper

type MathematicalOperator

type MathematicalOperator int
const (
	PLUS MathematicalOperator = iota
	MINUS
	MULT
	DIV
	MOD
)

type Outputs

type Outputs struct {
	// Parameters holds the list of output parameters produced by a step
	// +patchStrategy=merge
	// +patchMergeKey=name
	Parameters []Parameter `json:"parameters,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,1,rep,name=parameters"`

	// Result holds the result (stdout) of a script template
	Result *string `json:"result,omitempty" protobuf:"bytes,3,opt,name=result"`

	// ExitCode holds the exit code of a script template
	ExitCode *string `json:"exitCode,omitempty" protobuf:"bytes,4,opt,name=exitCode"`
}

Outputs hold parameters, artifacts, and results from a step

type ParallelSteps

type ParallelSteps struct {
	Steps []WorkflowStep `json:"-" protobuf:"bytes,1,rep,name=steps"`
}

+kubebuilder:validation:Type=array

type Parameter

type Parameter struct {
	// Name is the parameter name
	Name string `json:"name" protobuf:"bytes,1,opt,name=name"`

	// Default is the default value to use for an input parameter if a value was not supplied
	Default *intstr.IntOrString `json:"default,omitempty" protobuf:"bytes,2,opt,name=default"`

	// Value is the literal value to use for the parameter.
	// If specified in the context of an input parameter, the value takes precedence over any passed values
	Value *intstr.IntOrString `json:"value,omitempty" protobuf:"bytes,3,opt,name=value"`

	// ValueFrom is the source for the output parameter's value
	ValueFrom *ValueFrom `json:"valueFrom,omitempty" protobuf:"bytes,4,opt,name=valueFrom"`

	// GlobalName exports an output parameter to the global scope, making it available as
	// '{{workflow.outputs.parameters.XXXX}} and in workflow.status.outputs.parameters
	GlobalName string `json:"globalName,omitempty" protobuf:"bytes,5,opt,name=globalName"`
}

Parameter indicate a passed string parameter to a service template with an optional default value

type PatchRequest

type PatchRequest struct {
	Name             string                  `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
	Namespace        string                  `protobuf:"bytes,2,req,name=namespace" json:"namespace,omitempty"`
	GroupVersionKind schema.GroupVersionKind `protobuf:"bytes,3,req,name=groupVersionKind" json:"groupVersionKind,omitempty"`
	Patch            string                  `protobuf:"bytes,4,req,name=patch" json:"patch,omitempty"`
	PatchType        string                  `protobuf:"bytes,5,req,name=patchType" json:"patchType,omitempty"`
}

type Resource

type Resource struct {
	Operation string
	Group     string
	Version   string
	Kind      string
	Namespace string
	Name      string
	Message   string
	Status    ResourceSyncStatusCode
	Health    *HealthStatus
}

type ResourceReceiver

type ResourceReceiver interface {
	ReceiveResource(resource Resource)
}

type ResourceSyncStatusCode

type ResourceSyncStatusCode string
const (
	ResourceSyncStatusCodeUnknown   ResourceSyncStatusCode = "Unknown"
	ResourceSyncStatusCodeSynced    ResourceSyncStatusCode = "Synced"
	ResourceSyncStatusCodeOutOfSync ResourceSyncStatusCode = "OutOfSync"
)

type StepReceiver

type StepReceiver interface {
	ReceiveStep(stepName string)
}

type Template

type Template struct {
	// Name is the name of the template
	Name string `json:"name" protobuf:"bytes,1,opt,name=name"`

	// Inputs describe what inputs parameters and artifacts are supplied to this template
	Inputs Inputs `json:"inputs,omitempty" protobuf:"bytes,2,opt,name=inputs"`

	// Outputs describe the parameters and artifacts that this template produces
	Outputs Outputs `json:"outputs,omitempty" protobuf:"bytes,3,opt,name=outputs"`

	// Steps define a series of sequential/parallel workflow steps
	Steps []ParallelSteps `json:"steps,omitempty" protobuf:"bytes,4,opt,name=steps"`

	// DAG template subtype which runs a DAG
	DAG *DAGTemplate `json:"dag,omitempty" protobuf:"bytes,5,opt,name=dag"`
}

type ValueFrom

type ValueFrom struct {
	// JSONPath of a resource to retrieve an output parameter value from in resource templates
	JSONPath string `json:"jsonPath,omitempty" protobuf:"bytes,2,opt,name=jsonPath"`

	// JQFilter expression against the resource object in resource templates
	JQFilter string `json:"jqFilter,omitempty" protobuf:"bytes,3,opt,name=jqFilter"`

	// Parameter reference to a step or dag task in which to retrieve an output parameter value from
	// (e.g. '{{steps.mystep.outputs.myparam}}')
	Parameter string `json:"parameter,omitempty" protobuf:"bytes,4,opt,name=parameter"`

	// Default specifies a value to be used if retrieving the value from the specified source fails
	Default *intstr.IntOrString `json:"default,omitempty" protobuf:"bytes,5,opt,name=default"`
}

ValueFrom describes a location in which to obtain the value to a parameter

type Version

type Version string

type WorkflowSpec

type WorkflowSpec struct {

	//Version of the workflow which is same as the version of the BOM
	Version `json:"version,omitempty" protobuf:"bytes,1,opt,name=templates"`

	// Templates is a list of workflow templates used in a workflow
	// +patchStrategy=merge
	// +patchMergeKey=name
	Templates []Template `json:"templates,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,2,opt,name=templates"`

	// Entrypoint is a template reference to the starting point of the workflow.
	Entrypoint string `json:"entrypoint,omitempty" protobuf:"bytes,3,opt,name=entrypoint"`

	// Arguments contain the parameters and artifacts sent to the workflow entrypoint
	// Parameters are referencable globally using the 'workflow' variable prefix.
	// e.g. {{workflow.parameters.myparam}}
	Arguments Arguments `json:"arguments,omitempty" protobuf:"bytes,4,opt,name=arguments"`
}

WorkflowSpec defines workflow to be executed

type WorkflowStep

type WorkflowStep struct {
	// Name of the step
	Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`

	// Template is the name of the template to execute as the step
	Template string `json:"template,omitempty" protobuf:"bytes,2,opt,name=template"`

	// Arguments hold arguments to the template
	Arguments Arguments `json:"arguments,omitempty" protobuf:"bytes,3,opt,name=arguments"`

	//Command hold commands to be executed
	Command *Command `json:"command" protobuf:"bytes,4,name=command"`

	// OnExit is a template reference which is invoked at the end of the
	// template, irrespective of the success, failure, or error of the
	// primary template.
	OnExit string `json:"onExit,omitempty" protobuf:"bytes,5,opt,name=onExit"`
}

WorkflowStep is a reference to a template to execute in a series of step

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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