inputs

package
v0.7.0-rc.1 Latest Latest
Warning

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

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

Documentation

Overview

Package inputs gives scenario scripts the data and settings they read from outside the script (FR-CLI-17): data files whose rows feed virtual users, and environment variables the run exposes by name.

A script can only read an environment variable the run named with -env or -secret-env. Nothing else in the process environment is reachable through the `env` global, so a scenario written by someone else (or by an agent) cannot sweep up unrelated secrets. A value named with -secret-env is registered with internal/secrets, which keeps it out of the report, the JSON output, the audit record and logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseData

func ParseData(specs []string) (map[string]*Set, error)

ParseData loads each -data value. A value is a path, or name=path. A bare path is named after the file, without its extension, so users.csv is `data.users`. Names must be usable as an identifier in a script.

func ResolveEnv

func ResolveEnv(plain, secret []string) (map[string]string, error)

ResolveEnv reads the named environment variables. Names in secret are also registered as secrets. A name may be listed in both; it is then a secret. Each name may be a comma-separated list. A variable that is not set is an error, so a typo shows before any load is sent.

Types

type Inputs

type Inputs struct {
	// contains filtered or unexported fields
}

Inputs implements netapi.Inputs.

func New

func New(env map[string]string, sets map[string]*Set) *Inputs

New returns Inputs for the given variables and data files, or nil when there are none, which is how the scripting runtimes know to expose nothing.

func (*Inputs) Dataset

func (in *Inputs) Dataset(name string) (netapi.Dataset, bool)

Dataset returns the data file named name.

func (*Inputs) DatasetNames

func (in *Inputs) DatasetNames() []string

DatasetNames lists the data file names, sorted.

func (*Inputs) Env

func (in *Inputs) Env(name string) (string, bool)

Env returns an exposed variable.

func (*Inputs) EnvNames

func (in *Inputs) EnvNames() []string

EnvNames lists the exposed variable names, sorted.

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set is one data file's rows.

func LoadSet

func LoadSet(name, path string) (*Set, error)

LoadSet reads a CSV file (a header row, then one row per line) or a JSON file (an array of objects). The extension picks the format.

func (*Set) Len

func (s *Set) Len() int

Len is the number of rows.

func (*Set) Next

func (s *Set) Next() map[string]any

Next returns the next row in file order, shared by every caller, and starts again from the first row after the last.

func (*Set) Random

func (s *Set) Random() map[string]any

Random returns any row.

Jump to

Keyboard shortcuts

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