Documentation
¶
Index ¶
- type Container
- func (c *Container) Args(args ...string) *Container
- func (c *Container) CPU(request string, limit ...string) *Container
- func (c *Container) Command(cmd ...string) *Container
- func (c *Container) ContinueOn(continueOn *v1alpha1.ContinueOn) *Container
- func (c *Container) Env(name, value string) *Container
- func (c *Container) EnvFrom(name string, source corev1.EnvVarSource) *Container
- func (c *Container) ImagePullPolicy(policy corev1.PullPolicy) *Container
- func (c *Container) Memory(request string, limit ...string) *Container
- func (c *Container) Steps() ([]v1alpha1.WorkflowStep, error)
- func (c *Container) Templates() ([]v1alpha1.Template, error)
- func (c *Container) VolumeMount(name, mountPath string, readOnly bool) *Container
- func (c *Container) When(condition string) *Container
- func (c *Container) WithRetry(retry *v1alpha1.RetryStrategy) *Container
- func (c *Container) WorkingDir(dir string) *Container
- type ContainerOption
- func WithArgs(args ...string) ContainerOption
- func WithCPU(request string, limit ...string) ContainerOption
- func WithCommand(cmd ...string) ContainerOption
- func WithEnv(name, value string) ContainerOption
- func WithImagePullPolicy(policy corev1.PullPolicy) ContainerOption
- func WithMemory(request string, limit ...string) ContainerOption
- func WithOTelConfig(cfg *otel.Config) ContainerOption
- func WithWhen(condition string) ContainerOption
- func WithWorkingDir(dir string) ContainerOption
- type HTTP
- func (h *HTTP) Body(body string) *HTTP
- func (h *HTTP) Header(name, value string) *HTTP
- func (h *HTTP) Method(method string) *HTTP
- func (h *HTTP) Steps() ([]v1alpha1.WorkflowStep, error)
- func (h *HTTP) SuccessCondition(cond string) *HTTP
- func (h *HTTP) Templates() ([]v1alpha1.Template, error)
- func (h *HTTP) Timeout(seconds int32) *HTTP
- func (h *HTTP) URL(url string) *HTTP
- func (h *HTTP) When(condition string) *HTTP
- type HTTPOption
- func WithHTTPBody(body string) HTTPOption
- func WithHTTPHeader(name, value string) HTTPOption
- func WithHTTPMethod(method string) HTTPOption
- func WithHTTPOTelConfig(cfg *otel.Config) HTTPOption
- func WithHTTPSuccessCond(cond string) HTTPOption
- func WithHTTPTimeout(seconds int32) HTTPOption
- func WithHTTPURL(url string) HTTPOption
- type Noop
- type Script
- func (s *Script) CPU(request string, limit ...string) *Script
- func (s *Script) Command(cmd ...string) *Script
- func (s *Script) Env(name, value string) *Script
- func (s *Script) Image(image string) *Script
- func (s *Script) Memory(request string, limit ...string) *Script
- func (s *Script) Script(content string) *Script
- func (s *Script) Source(source string) *Script
- func (s *Script) Steps() ([]v1alpha1.WorkflowStep, error)
- func (s *Script) Templates() ([]v1alpha1.Template, error)
- func (s *Script) VolumeMount(name, mountPath string, readOnly bool) *Script
- func (s *Script) When(condition string) *Script
- func (s *Script) WorkingDir(dir string) *Script
- type ScriptOption
- func WithScriptCommand(cmd ...string) ScriptOption
- func WithScriptContent(content string) ScriptOption
- func WithScriptEnv(name, value string) ScriptOption
- func WithScriptImage(image string) ScriptOption
- func WithScriptOTelConfig(cfg *otel.Config) ScriptOption
- func WithScriptWorkingDir(dir string) ScriptOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is a WorkflowSource that creates a container-based workflow step. It provides a fluent API for configuring containers with common options like commands, arguments, environment variables, and resource requests.
Example:
deploy := template.NewContainer("deploy", "myapp:v1").
Command("deploy.sh").
Args("--env", "production").
Env("DATABASE_URL", "postgres://...").
CPU("1000m").
Memory("512Mi")
func NewContainer ¶
func NewContainer(name, image string, opts ...ContainerOption) *Container
NewContainer creates a new container workflow source.
Parameters:
- name: Step name (used in workflow step definition)
- image: Container image (e.g., "alpine:latest", "myapp:v1")
- opts: Optional configuration functions
Example:
container := template.NewContainer("deploy", "myapp:v1",
template.WithCommand("deploy.sh"),
template.WithArgs("--env", "production"),
template.WithOTelConfig(otelConfig))
func (*Container) Args ¶
Args sets the container arguments. Can be called multiple times or with multiple arguments.
Example:
container.Args("--port", "8080", "--host", "0.0.0.0")
func (*Container) CPU ¶
CPU sets CPU request and limit.
Example:
container.CPU("500m") // request and limit
container.CPU("500m", "1000m") // request and limit separately
func (*Container) Command ¶
Command sets the container command (entrypoint override). Can be called multiple times or with multiple arguments.
Example:
container.Command("python", "app.py")
// or
container.Command("python").Command("app.py")
func (*Container) ContinueOn ¶
func (c *Container) ContinueOn(continueOn *v1alpha1.ContinueOn) *Container
ContinueOn sets the step to continue on specific conditions.
Example:
container.ContinueOn(&v1alpha1.ContinueOn{
Failed: true, // continue even if step fails
})
func (*Container) Env ¶
Env adds an environment variable to the container.
Example:
container.Env("DATABASE_URL", "postgres://...").
Env("LOG_LEVEL", "debug")
func (*Container) EnvFrom ¶
func (c *Container) EnvFrom(name string, source corev1.EnvVarSource) *Container
EnvFrom adds an environment variable from a source (ConfigMap or Secret).
Example:
container.EnvFrom("API_KEY", corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: "api-secrets"},
Key: "api-key",
},
})
func (*Container) ImagePullPolicy ¶
func (c *Container) ImagePullPolicy(policy corev1.PullPolicy) *Container
ImagePullPolicy sets the image pull policy.
Example:
container.ImagePullPolicy(corev1.PullAlways)
func (*Container) Memory ¶
Memory sets memory request and limit.
Example:
container.Memory("256Mi") // request and limit
container.Memory("256Mi", "512Mi") // request and limit separately
func (*Container) Steps ¶
func (c *Container) Steps() ([]v1alpha1.WorkflowStep, error)
Steps implements WorkflowSource interface.
func (*Container) VolumeMount ¶
VolumeMount adds a volume mount to the container.
Example:
container.VolumeMount("config", "/etc/config", true)
func (*Container) When ¶
When sets a conditional expression for when this step should run.
Example:
container.When("{{workflow.status}} == Succeeded")
func (*Container) WithRetry ¶
func (c *Container) WithRetry(retry *v1alpha1.RetryStrategy) *Container
WithRetry sets a retry strategy for this specific step.
Example:
container.WithRetry(&v1alpha1.RetryStrategy{
Limit: intstr.FromInt(3),
RetryPolicy: "Always",
})
func (*Container) WorkingDir ¶
WorkingDir sets the working directory for the container.
Example:
container.WorkingDir("/app")
type ContainerOption ¶
type ContainerOption func(*Container)
ContainerOption is a functional option for configuring Container.
func WithArgs ¶
func WithArgs(args ...string) ContainerOption
WithArgs sets the container arguments.
func WithCPU ¶
func WithCPU(request string, limit ...string) ContainerOption
WithCPU sets CPU request and limit.
func WithCommand ¶
func WithCommand(cmd ...string) ContainerOption
WithCommand sets the container command.
func WithEnv ¶
func WithEnv(name, value string) ContainerOption
WithEnv adds an environment variable.
func WithImagePullPolicy ¶
func WithImagePullPolicy(policy corev1.PullPolicy) ContainerOption
WithImagePullPolicy sets the image pull policy.
func WithMemory ¶
func WithMemory(request string, limit ...string) ContainerOption
WithMemory sets memory request and limit.
func WithOTelConfig ¶
func WithOTelConfig(cfg *otel.Config) ContainerOption
WithOTelConfig enables OpenTelemetry instrumentation.
func WithWhen ¶
func WithWhen(condition string) ContainerOption
WithWhen sets a conditional expression.
func WithWorkingDir ¶
func WithWorkingDir(dir string) ContainerOption
WithWorkingDir sets the working directory.
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP is a WorkflowSource that creates an HTTP request workflow step. It's useful for making API calls, health checks, or webhooks.
Example:
http := template.NewHTTP("health-check").
URL("https://myapp/health").
Method("GET").
SuccessCond("response.statusCode >= 200 && response.statusCode < 300")
func NewHTTP ¶
func NewHTTP(name string, opts ...HTTPOption) *HTTP
NewHTTP creates a new HTTP workflow source.
Parameters:
- name: Step name
- opts: Optional configuration functions
Example:
http := template.NewHTTP("api-call",
template.WithHTTPURL("https://api.example.com/v1/resource"),
template.WithHTTPMethod("POST"),
template.WithHTTPBody(`{"key": "value"}`))
func (*HTTP) Header ¶
Header adds an HTTP header.
Example:
http.Header("Content-Type", "application/json").
Header("Authorization", "Bearer {{workflow.parameters.token}}")
func (*HTTP) Steps ¶
func (h *HTTP) Steps() ([]v1alpha1.WorkflowStep, error)
Steps implements WorkflowSource interface.
func (*HTTP) SuccessCondition ¶
SuccessCondition sets the condition for considering the request successful.
Example:
http.SuccessCondition("response.statusCode == 200")
func (*HTTP) Timeout ¶
Timeout sets the request timeout in seconds.
Example:
http.Timeout(60) // 60 seconds
type HTTPOption ¶
type HTTPOption func(*HTTP)
HTTPOption is a functional option for configuring HTTP.
func WithHTTPHeader ¶
func WithHTTPHeader(name, value string) HTTPOption
WithHTTPHeader adds a header.
func WithHTTPMethod ¶
func WithHTTPMethod(method string) HTTPOption
WithHTTPMethod sets the HTTP method.
func WithHTTPOTelConfig ¶
func WithHTTPOTelConfig(cfg *otel.Config) HTTPOption
WithHTTPOTelConfig enables OpenTelemetry instrumentation.
func WithHTTPSuccessCond ¶
func WithHTTPSuccessCond(cond string) HTTPOption
WithHTTPSuccessCond sets the success condition.
func WithHTTPTimeout ¶
func WithHTTPTimeout(seconds int32) HTTPOption
WithHTTPTimeout sets the timeout.
type Noop ¶
type Noop struct {
// contains filtered or unexported fields
}
Noop is a no-operation workflow source that produces a single step that does nothing. This is useful as a placeholder or for testing workflow structures.
Example:
noop := template.NewNoop() builder.Add(noop)
func NewNoop ¶
func NewNoop() *Noop
NewNoop creates a new no-op workflow source. The step will print "noop" to demonstrate execution.
Example:
noop := template.NewNoop()
wf, err := builder.NewWorkflowBuilder("test", "argo").
Add(noop).
Build()
func NewNoopWithName ¶
NewNoopWithName creates a no-op workflow source with a custom name. Useful when you need multiple no-op steps with different names.
Example:
placeholder1 := template.NewNoopWithName("placeholder-1")
placeholder2 := template.NewNoopWithName("placeholder-2")
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script is a WorkflowSource that creates a script-based workflow step. It's useful for running inline scripts in various languages (bash, python, etc.).
Example:
script := template.NewScript("backup", "bash").
Script("tar -czf /backup/data.tar.gz /data").
Env("BACKUP_DIR", "/backup")
func NewScript ¶
func NewScript(name, language string, opts ...ScriptOption) *Script
NewScript creates a new script workflow source. The image should contain the interpreter for the script language.
Parameters:
- name: Step name
- language: Script language ("bash", "python", "sh", etc.) - determines the default image
- opts: Optional configuration functions
Example:
script := template.NewScript("process", "python",
template.WithScriptContent("print('Processing data...')"),
template.WithScriptEnv("API_KEY", "secret"))
func (*Script) Command ¶
Command overrides the default command.
Example:
script.Command("python3", "-u")
func (*Script) Image ¶
Image overrides the default image for the script.
Example:
script.Image("custom/python:3.11")
func (*Script) Memory ¶
Memory sets memory request and limit.
Example:
script.Memory("256Mi", "512Mi")
func (*Script) Script ¶
Script sets the inline script content.
Example:
script.Script("echo 'Hello, World!'")
func (*Script) Source ¶
Source sets the script source (from artifact or configmap).
Example:
script.Source("{{inputs.artifacts.script}}")
func (*Script) Steps ¶
func (s *Script) Steps() ([]v1alpha1.WorkflowStep, error)
Steps implements WorkflowSource interface.
func (*Script) VolumeMount ¶
VolumeMount adds a volume mount.
Example:
script.VolumeMount("data", "/data", false)
func (*Script) When ¶
When sets a conditional expression.
Example:
script.When("{{workflow.status}} == Succeeded")
func (*Script) WorkingDir ¶
WorkingDir sets the working directory.
Example:
script.WorkingDir("/workspace")
type ScriptOption ¶
type ScriptOption func(*Script)
ScriptOption is a functional option for configuring Script.
func WithScriptCommand ¶
func WithScriptCommand(cmd ...string) ScriptOption
WithScriptCommand sets the command.
func WithScriptContent ¶
func WithScriptContent(content string) ScriptOption
WithScriptContent sets the script content.
func WithScriptEnv ¶
func WithScriptEnv(name, value string) ScriptOption
WithScriptEnv adds an environment variable.
func WithScriptImage ¶
func WithScriptImage(image string) ScriptOption
WithScriptImage sets the container image.
func WithScriptOTelConfig ¶
func WithScriptOTelConfig(cfg *otel.Config) ScriptOption
WithScriptOTelConfig enables OpenTelemetry instrumentation.
func WithScriptWorkingDir ¶
func WithScriptWorkingDir(dir string) ScriptOption
WithScriptWorkingDir sets the working directory.