restask

package
v3.0.0-rc49 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Keywords = []*keywords.Keyword{
		{
			Attr:       "Check",
			Candidates: []string{"last_run", "last_run_warn", ""},
			Example:    "last_run",
			Option:     "check",
			Scopable:   true,
			Text:       keywords.NewText(fs, "text/kw/check"),
		},
		{
			Attr:      "Confirmation",
			Converter: converters.Bool,
			Option:    "confirmation",
			Text:      keywords.NewText(fs, "text/kw/confirmation"),
		},
		{
			Attr:      "Install",
			Converter: converters.List,
			Example:   "fs#1",
			Option:    "install",
			Scopable:  true,
			Validate:  validInstall,
			Text:      keywords.NewText(fs, "text/kw/install"),
		},
		{
			Attr:      "LogOutputs",
			Converter: converters.Bool,
			Default:   "true",
			Option:    "log",
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/log"),
		},
		{
			Attr:      "MaxParallel",
			Converter: converters.Int,
			Default:   "1",
			Example:   "2",
			Option:    "max_parallel",
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/max_parallel"),
		},
		{
			Attr:      "On",
			Converter: converters.List,
			Example:   "NetworkPeersUpdated,name=backend1",
			Option:    "on",
			Scopable:  true,
			Validate:  validOn,
			Text:      keywords.NewText(fs, "text/kw/on"),
		},
		{
			Attr:     "Pace",
			Default:  schedule.DefaultPace,
			Example:  "@30s backoff @1m",
			Option:   "pace",
			Scopable: true,
			Validate: validPace,
			Text:     keywords.NewText(fs, "text/kw/pace"),
		},
		{
			Attr:     "OnErrorCmd",
			Example:  "/srv/{name}/data/scripts/task_on_error.sh",
			Option:   "on_error",
			Scopable: true,
			Text:     keywords.NewText(fs, "text/kw/on_error"),
		},
		{
			Attr:     "RetCodes",
			Default:  "0:up 1:down",
			Example:  "0:up 1:down 3:warn 4: n/a 5:undef",
			Option:   "retcodes",
			Required: false,
			Scopable: true,
			Text:     keywords.NewText(fs, "text/kw/retcodes"),
		},
		{
			Attr:      "RunTimeout",
			Converter: converters.Duration,
			Example:   "1m30s",
			Option:    "run_timeout",
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/run_timeout"),
		},
		{
			Attr:          "Schedule",
			DefaultOption: "run_schedule",
			Example:       "00:00-01:00 mon",
			Option:        "schedule",
			Scopable:      true,
			Text:          keywords.NewText(fs, "text/kw/schedule"),
		},
		{
			Attr:      "Snooze",
			Converter: converters.Duration,
			Example:   "10m",
			Option:    "snooze",
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/snooze"),
		},
		{
			Attr:      "Timeout",
			Converter: converters.Duration,
			Example:   "5m",
			Option:    "timeout",
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/timeout"),
		},
	}
)

Functions

This section is empty.

Types

type BaseTask

type BaseTask struct {
	resource.T
	Check        string
	Confirmation bool
	Install      []string
	LogOutputs   bool
	MaxParallel  int
	On           []string
	Pace         string
	OnErrorCmd   string
	RetCodes     string
	RunTimeout   *time.Duration
	Schedule     string
	Snooze       *time.Duration
}

func (*BaseTask) ExitCodeToStatus

func (t *BaseTask) ExitCodeToStatus(exitCode int) (status.T, error)

func (*BaseTask) Provisioned

func (t *BaseTask) Provisioned(ctx context.Context) (provisioned.T, error)

Provisioned returns NotApplicable: a task has nothing to provision.

func (*BaseTask) RunDir

func (t *BaseTask) RunDir() runfiles.Dir

func (*BaseTask) RunIf

func (t *BaseTask) RunIf(ctx context.Context, fn func(context.Context) error) error

func (*BaseTask) RunInstall

func (t *BaseTask) RunInstall(ctx context.Context) error

RunInstall installs again the files of the resources the install keyword names, rendering their templates from what the node knows now, before the task does its own work. The files it changes are recorded, which the daemon tells the tasks on FileInstalled.

A failed install is the failed run of the task.

func (*BaseTask) Running

func (t *BaseTask) Running() (resource.RunningInfoList, error)

func (*BaseTask) ScheduleOptions

func (t *BaseTask) ScheduleOptions() resource.ScheduleOptions

func (*BaseTask) Status

func (t *BaseTask) Status(ctx context.Context) status.T

func (*BaseTask) StatusInfo

func (t *BaseTask) StatusInfo(ctx context.Context) map[string]any

func (*BaseTask) WriteLastRun

func (t *BaseTask) WriteLastRun(retcode int) error

type LastRun

type LastRun struct {
	At        time.Time `json:"at"`
	ExitCode  int       `json:"exitcode"`
	SessionID uuid.UUID `json:"session_id"`
}

Jump to

Keyboard shortcuts

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