Documentation
¶
Index ¶
- Constants
- Variables
- func Base64Decode(raw string) (*tes.Task, error)
- func Base64Encode(t *tes.Task) (string, error)
- func EncodeTaskCursor(created, id string) string
- func FilterBackendParameters(resources *tes.Resources, supported []string) ([]string, error)
- func GPUCount(resources *tes.Resources) (int, error)
- func GPUDevices(resources *tes.Resources, expectedCount int) ([]string, error)
- func GenerateID() string
- func GetBasicView(task *tes.Task) *tes.Task
- func GetExecLog(task *tes.Task, attempt int, i int) *tes.ExecutorLog
- func GetMinimalView(task *tes.Task) *tes.Task
- func GetPageSize(reqSize int32) int
- func GetTaskLog(task *tes.Task, i int) *tes.TaskLog
- func InitTask(task *tes.Task, overwrite bool) error
- func InitTaskWithForbiddenPathPrefixes(task *tes.Task, overwrite bool, forbiddenPathPrefixes []string) error
- func NormalizeBackendParameters(resources *tes.Resources) error
- func NormalizeView(view string) (string, error)
- func ParseGPUDevices(value string, expectedCount int) ([]string, error)
- func ValidateContainerImage(image string) error
- func ValidateMountPaths(task *tes.Task, executorBackend string) error
- func ValidateTransition(from, to tes.State) error
- func WithTaskPageBytes(ctx context.Context, size int) context.Context
- type ReadOnlyServer
- type TaskCursor
- type TaskPage
- type TransitionError
- type ValidationError
Constants ¶
const DefaultResponseBytes = 4 * 1024 * 1024
Variables ¶
var ErrConcurrentStateChange = errors.New("Concurrent stage change")
var ErrNotFound = errors.New("task not found")
ErrNotFound is returned when a task is not found.
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 ¶
Base64Decode decodes a base64 encoded string into a task
func Base64Encode ¶
Base64Encode encodes a task as a base64 encoded string
func EncodeTaskCursor ¶
func FilterBackendParameters ¶
FilterBackendParameters removes unsupported optional parameters and returns their keys.
func GPUDevices ¶
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 ¶
GetBasicView returns the basic view of a task.
func GetExecLog ¶
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 ¶
GetMinimalView returns the minimal view of a task.
func GetPageSize ¶
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 ¶
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 ¶
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 ¶
NormalizeBackendParameters rejects ambiguous keys and canonicalizes TES keys.
func NormalizeView ¶
NormalizeView validates and canonicalizes the requested TES view.
func ParseGPUDevices ¶
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 ¶
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 ¶
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 ¶
ValidateTransition validates a task state transition. Returns a TransitionError if the transition is not valid.
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 ¶
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 ¶
type TransitionError ¶
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