task

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultResponseBytes = 4 * 1024 * 1024

Variables

View Source
var ErrConcurrentStateChange = errors.New("Concurrent stage change")
View Source
var ErrNotFound = errors.New("task not found")

ErrNotFound is returned when a task is not found.

View Source
var ErrNotPermitted = errors.New("permission denied")

ErrNotPermitted is returned when the owner of a task does not match the current non-admin user.

Functions

func Base64Decode

func Base64Decode(raw string) (*tes.Task, error)

Base64Decode decodes a base64 encoded string into a task

func Base64Encode

func Base64Encode(t *tes.Task) (string, error)

Base64Encode encodes a task as a base64 encoded string

func EncodeTaskCursor

func EncodeTaskCursor(created, id string) string

func FilterBackendParameters

func FilterBackendParameters(resources *tes.Resources, supported []string) ([]string, error)

FilterBackendParameters removes unsupported optional parameters and returns their keys.

func GPUCount

func GPUCount(resources *tes.Resources) (int, error)

GPUCount returns the requested GPU count, or zero if no GPU was requested.

func GPUDevices

func GPUDevices(resources *tes.Resources, expectedCount int) ([]string, error)

GPUDevices returns validated device IDs from backend_parameters.gpu_devices. expectedCount may be zero when the caller does not have a separate count.

func GenerateID

func GenerateID() string

GenerateID generates a task ID string. IDs are globally unique and sortable.

func GetBasicView

func GetBasicView(task *tes.Task) *tes.Task

GetBasicView returns the basic view of a task.

func GetExecLog

func GetExecLog(task *tes.Task, attempt int, i int) *tes.ExecutorLog

GetExecLog gets the executor log entry at the given index "i". If the entry doesn't exist, empty logs will be appended up to "i".

func GetMinimalView

func GetMinimalView(task *tes.Task) *tes.Task

GetMinimalView returns the minimal view of a task.

func GetPageSize

func GetPageSize(reqSize int32) int

GetPageSize takes in the page size from a request and returns a new page size taking into account the minimum, maximum and default as documented in the TES spec.

func GetTaskLog

func GetTaskLog(task *tes.Task, i int) *tes.TaskLog

GetTaskLog gets the task log entry at the given index "i". If the entry doesn't exist, empty logs will be appended up to "i".

func InitTask

func InitTask(task *tes.Task, overwrite bool) error

InitTask intializes task fields which are commonly set by CreateTask, such as Id, CreationTime, State, etc. If the task fails validation, an error is returned. See Validate(). The given task is modified.

If "overwrite" is true, the fields Id, State, and CreationTime will always be overwritten, even if already set, otherwise they will only be set if they are empty.

func InitTaskWithForbiddenPathPrefixes

func InitTaskWithForbiddenPathPrefixes(task *tes.Task, overwrite bool, forbiddenPathPrefixes []string) error

InitTaskWithForbiddenPathPrefixes initializes and validates a task while rejecting mounts at or beneath the configured container path prefixes.

func NormalizeBackendParameters

func NormalizeBackendParameters(resources *tes.Resources) error

NormalizeBackendParameters rejects ambiguous keys and canonicalizes TES keys.

func NormalizeView

func NormalizeView(view string) (string, error)

NormalizeView validates and canonicalizes the requested TES view.

func ParseGPUDevices

func ParseGPUDevices(value string, expectedCount int) ([]string, error)

ParseGPUDevices validates a comma-separated list of Docker GPU device IDs. expectedCount may be zero when the caller does not have a separate count.

func ValidateContainerImage

func ValidateContainerImage(image string) error

ValidateContainerImage checks that an image is a nonempty runtime argument, rather than an option or a sequence of command-line words. Reference resolution remains the container runtime's responsibility.

func ValidateMountPaths

func ValidateMountPaths(task *tes.Task, executorBackend string) error

ValidateMountPaths rejects task paths that would create a container mount at the filesystem root. Docker can instead mount declared root-level executor streams as individual files.

func ValidateTransition

func ValidateTransition(from, to tes.State) error

ValidateTransition validates a task state transition. Returns a TransitionError if the transition is not valid.

func WithTaskPageBytes

func WithTaskPageBytes(ctx context.Context, size int) context.Context

Types

type ReadOnlyServer

type ReadOnlyServer interface {
	ListTasks(ctx context.Context, in *tes.ListTasksRequest) (*tes.ListTasksResponse, error)
	GetTask(ctx context.Context, in *tes.GetTaskRequest) (*tes.Task, error)
	Close()
}

ReadOnlyServer describes the TES interface with only the Get/List tasks methods

type TaskCursor

type TaskCursor struct {
	Created string
	ID      string
}

TaskCursor matches descending creation-time and ID ordering.

func DecodeTaskCursor

func DecodeTaskCursor(token string) (TaskCursor, bool, error)

DecodeTaskCursor also accepts legacy ID-only tokens, which backends resolve to timestamps.

type TaskPage

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

func NewTaskPage

func NewTaskPage(ctx context.Context) *TaskPage

func (*TaskPage) Add

func (p *TaskPage) Add(task *tes.Task, nextToken string) (bool, error)

Add retains the exclusive cursor after each accepted task, so a refused task is retried.

func (*TaskPage) Finish

func (p *TaskPage) Finish(hasMore bool) *tes.ListTasksResponse

type TransitionError

type TransitionError struct {
	From, To tes.State
}

TransitionError describes an invalid state transition.

func (*TransitionError) Error

func (te *TransitionError) Error() string

type ValidationError

type ValidationError []error

ValidationError contains task validation errors.

func Validate

func Validate(t *tes.Task) ValidationError

Validate validates the given task and returns ValidationError, or nil if the task is valid.

func ValidateWithForbiddenPathPrefixes

func ValidateWithForbiddenPathPrefixes(t *tes.Task, forbiddenPathPrefixes []string) ValidationError

ValidateWithForbiddenPathPrefixes validates the given task and rejects inputs, outputs, volumes, and working directories at or beneath any of the configured container path prefixes.

func (ValidationError) Error

func (v ValidationError) Error() string

Jump to

Keyboard shortcuts

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