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 CheckColumns ¶ added in v0.9.0
CheckColumns reports a column that is not in its data set. The message names the file and the column, not a cell.
func ParseData ¶
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 ¶
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 ¶
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) DatasetNames ¶
DatasetNames lists the data file names, sorted.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is one data file's rows.
func LoadSet ¶
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) First ¶ added in v0.9.0
First is a copy of the first row. It does not move the next-row counter.
func (*Set) Next ¶
Next returns the next row in file order, shared by every caller, and starts again from the first row after the last.
type Template ¶ added in v0.9.0
type Template struct {
// contains filtered or unexported fields
}
Template is a string split once into literal parts and slots. Filling a template that has no slots returns the original string.
func Parse ¶ added in v0.9.0
Parse splits s into literals and placeholders. asArgs is true for an -opt args value: a placeholder with no suffix is replaced by the JSON form of the cell. Everywhere else the cell is inserted as plain text.
func (Template) Fill ¶ added in v0.9.0
Fill replaces each placeholder from rows, which maps a data set name to the one row this call drew. A template with no slots returns the original string and does not allocate.