Documentation
¶
Overview ¶
Package runtime provides functions to manage the runtime environment of the application. It will provide abstractions around the Kubernetes runtime environment, creating an executing containers, and managing the lifecycle of the application.
Index ¶
- Constants
- func BuildJob(resourceName string, id schemas.ExecutionID, ...) batchV1.Job
- func BuildServiceForJob(job *batchV1.Job, namespace string, port int32, opts ...ServiceOpt) v1.Service
- func CreateAnnotations(additional map[string]string) map[string]string
- func CreateContainer(name string, container schemas.UserContainer, secretVolumeName string, ...) v1.Container
- func CreateLabels(additional map[string]string) map[string]string
- func EnvForParameters(params map[string]string, definitions map[string]schemas.ParameterDefinition) []v1.EnvVar
- func GetJob(ctx context.Context, jobInterface typedBatchV1.JobInterface, ...) (*batchV1.Job, error)
- func IDFromJob(job *batchV1.Job) (schemas.ExecutionID, error)
- func ListJobs(ctx context.Context, jobInterface typedBatchV1.JobInterface, ...) ([]batchV1.Job, error)
- func RunStatusFromJobStatus(s batchV1.JobStatus) schemas.RunStatus
- func StopJob(ctx context.Context, jobInterface typedBatchV1.JobInterface, ...) error
- type ContainerOpt
- func ContainerArgsOpt(args ...string) ContainerOpt
- func ContainerEnvOpt(envVars ...v1.EnvVar) ContainerOpt
- func ContainerPortOpt(ports ...v1.ContainerPort) ContainerOpt
- func ContainerRestartPolicyOpt(restartPolicy v1.ContainerRestartPolicy) ContainerOpt
- func ContainerVolumesOpt(volumes ...v1.VolumeMount) ContainerOpt
- func ContainerWorkingDirOpt(workingDir string) ContainerOpt
- type JobOpt
- type ListOption
- type ServiceOpt
Constants ¶
const ( // LabelResource is the label used to identify the resource type. LabelResource = "resource" // LabelID is the label used to identify the resource ID. LabelID = "id" // LabelExecution is the label used to identify the execution type. // either a pipeline or a search LabelExecution = "execution" AnnotationVersion = "ocularproject.io/version" )
Variables ¶
This section is empty.
Functions ¶
func BuildJob ¶
func BuildJob( resourceName string, id schemas.ExecutionID, initContainers, containers []v1.Container, opts ...JobOpt, ) batchV1.Job
BuildJob creates a new Job object with the given parameters. It takes a resource name, an ID, and a list of containers. It also accepts a variadic number of JobOpt options to modify the Job object.
func BuildServiceForJob ¶
func BuildServiceForJob( job *batchV1.Job, namespace string, port int32, opts ...ServiceOpt, ) v1.Service
BuildServiceForJob creates a Service object for a Job. It sets the name, namespace, and owner reference of the Service to match the Job. It also sets the selector to match the Job's labels.
func CreateAnnotations ¶ added in v0.1.1
func CreateContainer ¶
func CreateContainer( name string, container schemas.UserContainer, secretVolumeName string, opts ...ContainerOpt, ) v1.Container
CreateContainer creates a new container with the given name and configuration. It will create the container based on the provided [types.UserContainer] and apply the ContainerOpt options to it. For any secrets that are mounted as files, it will create a volume mount for the secret and configure it to come from the volume with the name [secretVolumeName].
func CreateLabels ¶
CreateLabels creates a map of labels for the container. It merges the labels defined in the configuration file with the additional labels provided as input.
func EnvForParameters ¶
func EnvForParameters( params map[string]string, definitions map[string]schemas.ParameterDefinition, ) []v1.EnvVar
EnvForParameters converts a map of parameters to a list of environment variables that can be passed to a container. It will check that the parameters are defined in the parameter definitions and that the required parameters are set.
func GetJob ¶
func GetJob( ctx context.Context, jobInterface typedBatchV1.JobInterface, id schemas.ExecutionID, resourceType string, ) (*batchV1.Job, error)
func ListJobs ¶
func ListJobs( ctx context.Context, jobInterface typedBatchV1.JobInterface, resourceType string, opts ...ListOption, ) ([]batchV1.Job, error)
func RunStatusFromJobStatus ¶
RunStatusFromJobStatus converts a Kubernetes JobStatus to a [schema.RunStatus]. It will return a schemas.RunStatus based on the JobStatus. schemas.RunStatusUnknown is returned if the status cannot be determined. schemas.RunStatusError is returned if the job has failed, and the reason is not "Deleted". schemas.RunStatusCancelled is returned if the job has failed and the reason is "Deleted". schemas.RunStatusNotRan is never returned, as it is not applicable to JobStatus.
func StopJob ¶
func StopJob( ctx context.Context, jobInterface typedBatchV1.JobInterface, id schemas.ExecutionID, resourceType string, ) error
StopJob stops a job with the given ID. It uses the provided typedBatchV1.JobInterface to delete the job. It returns an error if the job cannot be deleted or if it is not found.
Types ¶
type ContainerOpt ¶
func ContainerArgsOpt ¶
func ContainerArgsOpt(args ...string) ContainerOpt
func ContainerEnvOpt ¶
func ContainerEnvOpt(envVars ...v1.EnvVar) ContainerOpt
func ContainerPortOpt ¶
func ContainerPortOpt(ports ...v1.ContainerPort) ContainerOpt
func ContainerRestartPolicyOpt ¶
func ContainerRestartPolicyOpt(restartPolicy v1.ContainerRestartPolicy) ContainerOpt
func ContainerVolumesOpt ¶
func ContainerVolumesOpt(volumes ...v1.VolumeMount) ContainerOpt
func ContainerWorkingDirOpt ¶
func ContainerWorkingDirOpt(workingDir string) ContainerOpt
type JobOpt ¶
JobOpt is a function that modifies a Job object.
func JobOptWithAnnotations ¶
JobOptWithAnnotations adds annotations to the Job object.
func JobOptWithLabels ¶
JobOptWithLabels adds labels to the Job object.
func JobOptWithServiceAccountName ¶
JobOptWithServiceAccountName sets the service account name for the Job object. This is useful for setting the service account that the job should run as.
func JobOptWithTimeout ¶
JobOptWithTimeout sets the timeout for the Job object.
func JobOptWithVolumes ¶
JobOptWithVolumes adds volumes to the Job object.
type ListOption ¶
type ListOption = func(meta metav1.ListOptions) metav1.ListOptions
type ServiceOpt ¶
ServiceOpt is a function that modifies a Service object.
func ServiceOptPublishNotReadyAddresses ¶
func ServiceOptPublishNotReadyAddresses(publishNotReadyAddresses bool) ServiceOpt
ServiceOptPublishNotReadyAddresses sets the 'PublishNotReadyAddresses' field of the Service object.