runplan

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package runplan turns a run's invocation (the flags of `sonde run`, as given) and the environment into what the engine runs: the runner's Options and the jobs, with the user config file and the HURL_*/SONDE_* environment variables applied in the documented precedence (config file < environment < flag). The CLI and the desktop app both build their runs with it, so a run means the same thing in both.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyCaptures

func ApplyCaptures(opts *engine.Options, job *engine.Job, plain map[string]any, secret map[string]string)

ApplyCaptures layers the captures of earlier entries over a run, the way a front end reruns one entry of a file after a full run (the desktop's Send): plain captures join Options.Variables and `redact` captures Options.Secrets, above every other source. A plain capture removes its name from the secrets of opts and job, so it is not masked; a `redact` capture removes its name from opts.Variables. opts and job are updated in place; their maps are copied first, never shared with the caller's. A data file must be opened with the `redact` capture names among its overridden names, so that a row does not report them as clashing secrets.

func DefaultUserAgent

func DefaultUserAgent(env config.Env, version string) string

DefaultUserAgent is the User-Agent sent when neither the command line nor the entry sets one: SONDE_DEFAULT_USER_AGENT, else sonde/<version>.

func ReadLimited

func ReadLimited(r io.Reader) ([]byte, error)

ReadLimited reads all of r but stops past syntax.MaxFileSize.

func ResolveBool

func ResolveBool(inv *Invocation, flag, envName string, cliVal bool, env config.Env) bool

ResolveBool applies the flag-then-env-then-default precedence of a "presence" boolean flag: one with no negating counterpart, true only when the flag itself was given.

Types

type Input

type Input struct {
	Name  string
	Stdin bool
}

Input is a file to run: a path, or standard input.

type Invocation

type Invocation struct {
	// Cmd is "test" for `sonde test` (test mode forced on), else "run".
	Cmd string
	// Files are the FILE arguments ("-" is standard input); Glob the
	// --glob patterns.
	Files []string
	Glob  []string
	// Set names the flags given explicitly.
	Set map[string]bool

	// Variables and secrets.
	Variables      []string
	VariablesFiles []string
	Secrets        []string
	SecretsFiles   []string

	// Transport.
	CACert          string
	Cert            string
	Key             string
	Compressed      bool
	ConnectTimeout  string
	ConnectTo       []string
	Insecure        bool
	IPv4            bool
	IPv6            bool
	HTTP10          bool
	HTTP11          bool
	HTTP2           bool
	HTTP3           bool
	LimitRate       string
	Location        bool
	LocationTrusted bool
	MaxFilesize     string
	MaxRedirs       string
	MaxTime         string
	Netrc           bool
	NetrcFile       string
	NetrcOptional   bool
	NoProxy         string
	PathAsIs        bool
	PinnedPubKey    string
	Proxy           string
	Resolve         []string
	UnixSocket      string
	User            string
	UserAgent       string
	Header          []string
	Digest          bool
	Negotiate       bool
	NTLM            bool
	SSLNoRevoke     bool
	AWSSigV4        string

	// Cookies.
	Cookie        string
	CookieJar     string
	NoCookieStore bool

	// Run control.
	ContinueOnError bool
	Delay           string
	FromEntry       int
	ToEntry         int
	NoAssert        bool
	Repeat          string
	Retry           string
	RetryInterval   string
	FileRoot        string
	Jobs            int
	Parallel        bool
	ProgressBar     bool
	Test            bool
	Env             string
	Config          string
	Data            string
	DataSecrets     []string
	OpenAPI         OpenAPI

	// Output.
	Include     bool
	JSON        bool
	NoOutput    bool
	NoPretty    bool
	Pretty      bool
	Output      string
	ErrorFormat string
	Curl        string
	ReportHTML  string
	ReportJSON  string
	ReportJUnit string
	ReportTAP   string

	// Logging.
	Verbose     bool
	VeryVerbose bool
	Verbosity   string
}

Invocation is every flag of `sonde run` as given, and the positional FILE arguments. A flag counts as given when Set names it (its long name, e.g. "max-time"); a flag not given falls through to the environment and the config file, like an absent flag on the command line. List flags (Variables, Header, ...) apply as they are.

func (*Invocation) Changed

func (inv *Invocation) Changed(flag string) bool

Changed reports whether flag was given explicitly.

type OpenAPI

type OpenAPI struct {
	Spec        string
	Server      string
	Strict      bool
	AllowRemote bool
}

OpenAPI are the --openapi* flags.

type Plan

type Plan struct {
	// Options are the runner's options. Stdout and BufferedLogs are left
	// to the caller; Validator is set by Resolve.
	Options engine.Options
	// Test is test mode (--test, or `sonde test`); Parallel whether the
	// parallel runner is used (test mode or --parallel); Workers the
	// number of files run at a time (--jobs); Repeat the passes over the
	// files (-1: forever).
	Test     bool
	Parallel bool
	Workers  int
	Repeat   int
	// Data is the --data file, checked in full (nil: none).
	Data *datarow.Run
	// Provenance lists the settings that came from the environment or
	// the config file rather than a flag.
	Provenance []Source
	// Warnings are sonde.yaml discovery warnings (Resolve); they only
	// name paths.
	Warnings []string
	// contains filtered or unexported fields
}

Plan is a run built from an Invocation: the runner's Options and the run control settings (New), then each input file's sonde.yaml values and contract (Resolve), from which Jobs builds the jobs.

Layers, lowest first: a job's sonde.yaml values (Job.Variables and Job.Secrets), then Options.Variables (--variable, the environment and variables files), then a data row. Options.Secrets are applied last.

func New

func New(inv *Invocation, env config.Env, version string) (*Plan, error)

New builds a run's options from inv and env, in the documented precedence order: config file < environment variables (HURL_*/SONDE_*) < flag. version names the default User-Agent (sonde/<version>). An *UnsupportedError reports an option sonde does not implement; every other error is a usage error.

func (*Plan) Jobs

func (p *Plan) Jobs(stdinSrc []byte, dataErr *error) iter.Seq[engine.Job]

Jobs returns the sequence of jobs of the run: the input files, repeated Repeat times (-1: forever). A real file's Source is left nil so RunAll reads it (lazily, once per attempt); stdin's Source is stdinSrc, the bytes read once, reused for every repeat. A file's sonde.yaml values and contract come from Resolve.

With a data file, each file runs once per row; a data file that fails to read midway ends the sequence and sets *dataErr.

func (*Plan) Resolve

func (p *Plan) Resolve(ctx context.Context, files []Input) error

Resolve finds each input file's sonde.yaml and resolves its environment and contract: the second half of building a run, once the input files are known. ctx bounds the loading of OpenAPI specs. Every error is a usage error.

type Source

type Source struct {
	// Setting is the flag ("--max-time"), or "variable NAME" / "secret
	// NAME".
	Setting string
	// Origin is the environment variable ("HURL_MAX_TIME") or the config
	// file's path.
	Origin string
}

Source is where a setting of a run came from, when not a flag.

type UnsupportedError

type UnsupportedError struct{ Name string }

UnsupportedError reports an option sonde does not implement: a runtime error, not a usage error.

func (*UnsupportedError) Error

func (e *UnsupportedError) Error() string

Jump to

Keyboard shortcuts

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