taskrun

package
v0.0.0-...-348835b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package taskrun loads and executes named commands from a hydra.yml config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands struct {
	Model    string            `yaml:"model"`
	APIType  string            `yaml:"api_type"`
	GiteaURL string            `yaml:"gitea_url"`
	Timeout  *Duration         `yaml:"timeout"`
	Notify   string            `yaml:"notify"`
	Teardown string            `yaml:"teardown"`
	Commands map[string]string `yaml:"commands"`
}

Commands holds the named commands loaded from hydra.yml.

func Load

func Load(path string) (*Commands, error)

Load reads and parses a hydra.yml file.

func (*Commands) EffectiveCommands

func (c *Commands) EffectiveCommands(workDir string) map[string]string

EffectiveCommands returns the commands map including Makefile fallbacks. For each standard command name (clean, dev, test, lint) not configured in hydra.yml, if a matching Makefile target exists in workDir, it is included as "make <name>".

func (*Commands) HasCommand

func (c *Commands) HasCommand(name, workDir string) bool

HasCommand reports whether a command is available for the given name, either from hydra.yml or via a Makefile target in workDir.

func (*Commands) Run

func (c *Commands) Run(name, workDir string) error

Run executes the named command in the given working directory. The command is run via $SHELL -c, so shell features like pipes and variable expansion work. Falls back to "make <name>" if the command is not configured in hydra.yml but a Makefile with that target exists. Returns nil if neither is available.

func (*Commands) RunDev

func (c *Commands) RunDev(ctx context.Context, workDir string) error

RunDev executes the named "dev" command in the given working directory. The command runs until it exits or the context is cancelled. Falls back to "make dev" if no dev command is configured but a Makefile with a dev target exists. Returns an error if neither is available.

func (*Commands) RunNotify

func (c *Commands) RunNotify(title, message string) (bool, error)

RunNotify executes the configured notify command with title and message as arguments. Returns false if no notify command is configured.

func (*Commands) RunTeardown

func (c *Commands) RunTeardown(workDir string) error

RunTeardown executes the configured teardown command in the given working directory. Returns nil if no teardown command is configured.

type Duration

type Duration struct {
	time.Duration
}

Duration wraps time.Duration for YAML unmarshaling from Go duration strings.

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML parses a Go duration string like "30m" or "2h".

Jump to

Keyboard shortcuts

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