tasktemplate

package
v1.23.3 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromDir

func LoadFromDir(dbp zesty.DBProvider, dir string) error

LoadFromDir reads yaml-formatted task templates from a folder and upserts them in database

Types

type TaskTemplate

type TaskTemplate struct {
	ID              int64                  `json:"-" db:"id"`
	Name            string                 `json:"name" db:"name"`
	Description     string                 `json:"description" db:"description"`
	LongDescription *string                `json:"long_description,omitempty" db:"long_description"`
	DocLink         *string                `json:"doc_link,omitempty" db:"doc_link"`
	TitleFormat     string                 `json:"title_format,omitempty" db:"title_format"`
	ResultFormat    map[string]interface{} `json:"result_format,omitempty" db:"result_format"`

	AllowedResolverGroups     []string `json:"allowed_resolver_groups" db:"allowed_resolver_groups"`
	AllowedResolverUsernames  []string `json:"allowed_resolver_usernames" db:"allowed_resolver_usernames"`
	AllowAllResolverUsernames bool     `json:"allow_all_resolver_usernames" db:"allow_all_resolver_usernames"`
	AutoRunnable              bool     `json:"auto_runnable" db:"auto_runnable"`
	Blocked                   bool     `json:"blocked" db:"blocked"`
	Hidden                    bool     `json:"hidden" db:"hidden"`
	RetryMax                  *int     `json:"retry_max,omitempty" db:"retry_max"`
	AllowTaskStartOver        bool     `json:"allow_task_start_over" db:"allow_task_start_over"`

	Inputs             []input.Input              `json:"inputs,omitempty" db:"inputs"`
	ResolverInputs     []input.Input              `json:"resolver_inputs,omitempty" db:"resolver_inputs"`
	Variables          []values.Variable          `json:"variables,omitempty" db:"variables"`
	Tags               map[string]string          `json:"tags,omitempty" db:"tags"`
	Steps              map[string]*step.Step      `json:"steps,omitempty" db:"steps"`
	BaseConfigurations map[string]json.RawMessage `json:"base_configurations" db:"base_configurations"`
}

TaskTemplate holds the formal description for a process that can be executed by µTask It describes: - needed inputs and validation rules on them - a collection of named steps, full with their configurations and interdependencies - rules for execution rights (allowed resolvers, auto run, blocked), API exposition (hidden) - a format for result consolidation in tasks derived from the template

func Create

func Create(dbp zesty.DBProvider,
	name, description string,
	longDescription,
	docLink *string,
	inputs, resolverInputs []input.Input,
	allowedResolverGroups []string,
	allowedResolverUsernames []string,
	allowAllResolverUsernames, autoRunnable bool,
	steps map[string]*step.Step,
	variables []values.Variable,
	tags map[string]string,
	resultFormat map[string]interface{},
	titleFormat string,
	retryMax *int,
	allowTaskStartOver bool,
	baseConfig map[string]json.RawMessage) (tt *TaskTemplate, err error)

Create inserts a new task template in DB

func ListTemplates

func ListTemplates(dbp zesty.DBProvider, includeHidden bool, pageSize uint64, last *string) (tt []*TaskTemplate, err error)

ListTemplates returns a list of task templates, in a simplified form (steps not included)

func LoadFromID

func LoadFromID(dbp zesty.DBProvider, id int64) (tt *TaskTemplate, err error)

LoadFromID returns a task template, given its "private" identifier A shortcut only used internally, not exposed through API

func LoadFromName

func LoadFromName(dbp zesty.DBProvider, name string) (tt *TaskTemplate, err error)

LoadFromName returns a task template, given its unique human-readable identifier

func (*TaskTemplate) Delete

func (tt *TaskTemplate) Delete(dbp zesty.DBProvider) (err error)

Delete removes a template from DB

func (*TaskTemplate) FilterInputs

func (tt *TaskTemplate) FilterInputs(inputValues map[string]interface{}) map[string]interface{}

FilterInputs drops received inputs that are not declared by a template

func (*TaskTemplate) IsAutoRunnable

func (tt *TaskTemplate) IsAutoRunnable() bool

IsAutoRunnable asserts that a task issued from this template can be executed directly, ie. a resolution can be created and launched automatically

func (*TaskTemplate) Normalize

func (tt *TaskTemplate) Normalize()

Normalize transforms a template's name into a standard format

func (*TaskTemplate) Update

func (tt *TaskTemplate) Update(dbp zesty.DBProvider,
	description, longDescription, docLink *string,
	inputs, resolverInputs []input.Input,
	allowedResolverGroups []string,
	allowedResolverUsernames []string,
	allowAllResolverUsernames, autoRunnable, blocked, hidden *bool,
	steps map[string]*step.Step,
	variables []values.Variable,
	tags map[string]string,
	resultFormat map[string]interface{},
	titleFormat *string,
	retryMax *int,
	allowTaskStartOver *bool,
	baseConfig map[string]json.RawMessage) (err error)

Update introduces changes to a template in DB

func (*TaskTemplate) Valid

func (tt *TaskTemplate) Valid() (err error)

Valid asserts that the content of a task template is correct: - metadata (name, description, etc...) is valid - inputs are correctly expressed - steps are coherent (dependency graph, templating handles)

func (*TaskTemplate) ValidateInputs

func (tt *TaskTemplate) ValidateInputs(inputValues map[string]interface{}) error

ValidateInputs asserts that input values provided by a task's requester conform to the template's spec for requester inputs

func (*TaskTemplate) ValidateResolverInputs

func (tt *TaskTemplate) ValidateResolverInputs(inputValues map[string]interface{}) error

ValidateResolverInputs asserts that input values provided by a task's resolver conform to the template's spec for resolver inputs

Jump to

Keyboard shortcuts

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