types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Environ

func Environ(spec Spec, task Task) ([]string, error)

Types

type EnvVar

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

A environment variable.

func (EnvVar) MarshalJSON

func (v EnvVar) MarshalJSON() ([]byte, error)

func (EnvVar) String

func (v EnvVar) String() (string, error)

func (*EnvVar) UnmarshalJSON

func (v *EnvVar) UnmarshalJSON(data []byte) error

func (*EnvVar) Unstring

func (v *EnvVar) Unstring(s string) error

type EnvVars

type EnvVars map[string]string

A list of environment variables.

func (EnvVars) Environ

func (v EnvVars) Environ() ([]string, error)

Environ returns a list of environment variables. If an environment variable is defined in both the task and the host, the host value is used.

func (*EnvVars) UnmarshalJSON

func (v *EnvVars) UnmarshalJSON(data []byte) error

the legacy format for env vars was an array of named env vars

type Envfile

type Envfile Strings

func (Envfile) Environ

func (f Envfile) Environ(workingDir string) ([]string, error)

Environ reads the returns the environ

type HTTPGetAction

type HTTPGetAction struct {
	// Scheme to use for connecting to the host. Defaults to HTTP.
	Scheme string `json:"scheme,omitempty"`
	// Number of the port
	Port uint16 `json:"port,omitempty"`
	// Path to access on the HTTP server.
	Path string `json:"path,omitempty"`
}

HTTPGetAction describes an action based on HTTP Locks requests.

func (HTTPGetAction) GetPort

func (a HTTPGetAction) GetPort() uint16

func (HTTPGetAction) GetProto

func (a HTTPGetAction) GetProto() string

func (HTTPGetAction) GetURL

func (a HTTPGetAction) GetURL() string

func (HTTPGetAction) URL

func (a HTTPGetAction) URL() *url.URL

func (*HTTPGetAction) Unstring

func (a *HTTPGetAction) Unstring(s string) error

type HostPath

type HostPath struct {
	// Path of the directory on the host.
	Path string `json:"path"`
}

type Metadata

type Metadata struct {
	// Name is the name of the resource.
	Name string `json:"name,omitempty"`
	// Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.
	Annotations map[string]string `json:"annotations,omitempty"`
}

type Metrics

type Metrics struct {
	Mem uint64 `json:"mem"` // Memory usage in bytes
}

type NamedTask deprecated

type NamedTask struct {
	// The name of the task, must be unique
	Name string `json:"name"`
	Task
}

Deprecated: only used for legacy unmarshalling.

type Port

type Port struct {
	// The container port to expose
	ContainerPort uint16 `json:"containerPort,omitempty"`
	// The host port to route to the container port
	HostPort uint16 `json:"hostPort,omitempty"`
}

A port to expose.

func (Port) GetHostPort

func (p Port) GetHostPort() uint16

func (Port) MarshalJSON

func (p Port) MarshalJSON() ([]byte, error)

func (Port) String

func (p Port) String() string

func (*Port) UnmarshalJSON

func (p *Port) UnmarshalJSON(data []byte) error

func (*Port) Unstring

func (p *Port) Unstring(s string) error

type Ports

type Ports []Port

A list of ports to expose.

func (Ports) Len

func (p Ports) Len() int

func (Ports) Less

func (p Ports) Less(i, j int) bool

func (Ports) Map

func (p Ports) Map() map[uint16]uint16

func (Ports) MarshalJSON

func (p Ports) MarshalJSON() ([]byte, error)

func (Ports) Swap

func (p Ports) Swap(i, j int)

func (*Ports) UnmarshalJSON

func (p *Ports) UnmarshalJSON(data []byte) error

type Probe

type Probe struct {
	// The action to perform.
	TCPSocket *TCPSocketAction `json:"tcpSocket,omitempty"`
	// The action to perform.
	HTTPGet *HTTPGetAction `json:"httpGet,omitempty"`
	// Number of seconds after the process has started before the probe is initiated.
	InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"`
	// How often (in seconds) to perform the probe.
	PeriodSeconds int32 `json:"periodSeconds,omitempty"`
	// Minimum consecutive successes for the probe to be considered successful after having failed.
	SuccessThreshold int32 `json:"successThreshold,omitempty"`
	// Minimum consecutive failures for the probe to be considered failed after having succeeded.
	FailureThreshold int32 `json:"failureThreshold,omitempty"`
}

A probe to check if the task is alive, it will be restarted if not.

func (Probe) GetFailureThreshold

func (p Probe) GetFailureThreshold() int

func (Probe) GetInitialDelay

func (p Probe) GetInitialDelay() time.Duration

func (Probe) GetPeriod

func (p Probe) GetPeriod() time.Duration

func (Probe) GetSuccessThreshold

func (p Probe) GetSuccessThreshold() int

func (Probe) MarshalJSON

func (p Probe) MarshalJSON() ([]byte, error)

func (Probe) String

func (p Probe) String() string

func (Probe) URL

func (p Probe) URL() *url.URL

func (*Probe) UnmarshalJSON

func (p *Probe) UnmarshalJSON(data []byte) error

func (*Probe) Unstring

func (p *Probe) Unstring(s string) error

type Spec

type Spec struct {
	// Port is the port that should be used for the user interface.
	Port *uint16 `json:"port,omitempty"`
	// TerminationGracePeriodSeconds is the grace period for terminating the workflow.
	TerminationGracePeriodSeconds *int32 `json:"terminationGracePeriodSeconds,omitempty"`
	// Tasks is a list of tasks that should be run.
	Tasks Tasks `json:"tasks,omitempty"`
	// Volumes is a list of volumes that can be mounted by containers belonging to the workflow.
	Volumes []Volume `json:"volumes,omitempty"`
	// Semaphores is a list of semaphores that can be acquired by tasks.
	Semaphores map[string]int `json:"semaphores,omitempty"`
	// Environment variables to set in the container or on the host
	Env EnvVars `json:"env,omitempty"`
	// Environment file (e.g. .env) to use
	Envfile Envfile `json:"envfile,omitempty"`
}

Task is a unit of work that should be run.

func (*Spec) Environ

func (s *Spec) Environ() ([]string, error)

Retuns the environment variables for the spec.

func (*Spec) GetTerminationGracePeriod

func (s *Spec) GetTerminationGracePeriod() time.Duration

type Strings

type Strings []string

func (Strings) String

func (p Strings) String() string

func (*Strings) UnmarshalJSON

func (p *Strings) UnmarshalJSON(data []byte) error

type TCPSocketAction

type TCPSocketAction struct {
	// Port number of the port to probe.
	Port uint16 `json:"port"`
}

TCPSocketAction describes an action based on opening a socket

func (TCPSocketAction) URL

func (a TCPSocketAction) URL() *url.URL

type Task

type Task struct {
	// Type is the type of the task: "service" or "job". If omitted, if there are ports, it's a service, otherwise it's a job.
	// This is only needed when you have service that does not listen on ports.
	// Services are running in the background.
	Type TaskType `json:"type,omitempty"`
	// Where to log the output of the task. E.g. if the task is verbose. Defaults to /dev/stdout. Maybe a file, or /dev/null.
	Log string `json:"log,omitempty"`
	// Either the container image to run, or a directory containing a Dockerfile. If omitted, the process runs on the host.
	Image string `json:"image,omitempty"`
	// Pull policy, e.g. Always, Never, IfNotPresent
	ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
	// A probe to check if the task is alive, it will be restarted if not. If omitted, the task is assumed to be alive.
	LivenessProbe *Probe `json:"livenessProbe,omitempty"`
	// A probe to check if the task is ready to serve requests. If omitted, the task is assumed to be ready if when the first port is open.
	ReadinessProbe *Probe `json:"readinessProbe,omitempty"`
	// The command to run in the container or on the host. If both the image and the command are omitted, this is a noop.
	Command Strings `json:"command,omitempty"`
	// The arguments to pass to the command
	Args Strings `json:"args,omitempty"`
	// The shell script to run, instead of the command
	Sh string `json:"sh,omitempty"`
	// A directories or files of Kubernetes manifests to apply. Once running the task will wait for the resources to be ready.
	Manifests Strings `json:"manifests,omitempty"`
	// The namespace to run the Kubernetes resource in. Defaults to the namespace of the current Kubernetes context.
	Namespace string `json:"namespace,omitempty"`
	// The working directory in the container or on the host
	WorkingDir string `json:"workingDir,omitempty"`
	// The user to run the task as.
	User string `json:"user,omitempty"`
	// Environment variables to set in the container or on the host
	Env EnvVars `json:"env,omitempty"`
	// Environment file (e.g. .env) to use
	Envfile Envfile `json:"envfile,omitempty"`
	// The ports to expose
	Ports Ports `json:"ports,omitempty"`
	// Volumes to mount in the container
	VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"`
	// Use a pseudo-TTY
	TTY bool `json:"tty,omitempty"`
	// A list of files to watch for changes, and restart the task if they change
	Watch Strings `json:"watch,omitempty"`
	// A mutex to prevent multiple tasks with the same mutex from running at the same time
	Mutex string `json:"mutex,omitempty"`
	// A semaphore to limit the number of tasks with the same semaphore that can run at the same time
	Semaphore string `json:"semaphore,omitempty"`
	// A list of tasks to run before this task
	Dependencies Strings `json:"dependencies,omitempty"`
	// A list of files this task will create. If these exist, and they're newer than the watched files, the task is skipped.
	Targets Strings `json:"targets,omitempty"`
	// The restart policy, e.g. Always, Never, OnFailure. Defaults depends on the type of task.
	RestartPolicy string `json:"restartPolicy,omitempty"`
	// The timeout for the task to be considered stalled. If omitted, the task will be considered stalled after 30 seconds of no activity.
	StalledTimeout *metav1.Duration `json:"stalledTimeout,omitempty"`
	// The group this task belongs to. Tasks in the same group will be visually grouped together in the UI.
	Group string `json:"group,omitempty"`
	// Whether this is the default task to run if no task is specified.
	Default bool `json:"default,omitempty"`
}

A task is a container or a command to run.

func (*Task) Environ

func (t *Task) Environ() ([]string, error)

func (*Task) GetCommand

func (t *Task) GetCommand() Strings

func (*Task) GetHostPorts

func (t *Task) GetHostPorts() []uint16

func (*Task) GetLivenessProbe

func (t *Task) GetLivenessProbe() *Probe

func (*Task) GetReadinessProbe

func (t *Task) GetReadinessProbe() *Probe

func (*Task) GetRestartPolicy

func (t *Task) GetRestartPolicy() string

func (*Task) GetStalledTimeout

func (t *Task) GetStalledTimeout() time.Duration

func (*Task) GetType

func (t *Task) GetType() TaskType

func (*Task) HasMutex

func (t *Task) HasMutex() bool

func (*Task) Skip

func (t *Task) Skip() bool

Skip Determines if all the targets exist. And if they're all newer that the newest source file.

func (*Task) String

func (t *Task) String() string

type TaskType

type TaskType string
const (
	TaskTypeJob     TaskType = "Job"
	TaskTypeService TaskType = "Service"
)

type Tasks

type Tasks map[string]Task

func (*Tasks) UnmarshalJSON

func (t *Tasks) UnmarshalJSON(data []byte) error

the legacy format for tasks was an array of named tasks

type Volume

type Volume struct {
	// Volume's name.
	Name string `json:"name"`
	// HostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container.
	HostPath HostPath `json:"hostPath"`
}

type VolumeMount

type VolumeMount struct {
	// This must match the name of a volume.
	Name string `json:"name"`
	// Path within the container at which the volume should be mounted.
	MountPath string `json:"mountPath"`
}

VolumeMount describes a mounting of a Volume within a container.

type Workflow

type Workflow Spec

func (*Workflow) UnmarshalJSON

func (p *Workflow) UnmarshalJSON(data []byte) error

when unmarshalling legacy format, we need to convert it to the new format

Jump to

Keyboard shortcuts

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