Running a Configuration
Usage
Use the run command to execute a configuration file:
srotas run [CONFIG]config: The path to the yaml configuration file.
For more details on configuring Srotas, check out the Configuration.
For a complete list of available flags and usage details, run:
srotas run --helpExample
srotas run config.yamlFlags and Options
Debug Mode
Enable detailed logs:
srotas run config.yaml --debugAlias:
srotas run config.yaml -DEnvironment
The --env flag is used to load global headers and static variables from a JSON string or a file containing JSON data.
Usage
srotas run config.yaml --env env.jsonAlias:
srotas run config.yaml -E env.jsonFormat
The JSON structure consists of two fields:
Variables: A map where keys are variable names and values are expressions. These variables are static, meaning they do not have access to other values at the time of definition.Headers: A map where keys are header names and values are lists of expressions. The expressions for headers can reference static variables.
You can provide the JSON data directly as a string or specify a file path containing the JSON.
{
"Variables": {
"auth_token": "'Bearer abc123'"
},
"Headers": {
"Authorization": ["auth_token"],
}
}Example
srotas run --env '{"Variables":{"user":"John Doe","token":"ey1234"},"Headers":{"Authorization":["\"Bearer \" + token"]}}' config.yamlsrotas run --env env.json config.yamlImportant
At least one of Variables or Headers must be present in the JSON.
Warning
Duplicate variable and header names will result in an error.
For more details, refer Global Fields and Variables.
Headers
The --header flag is used to define global headers dynamically when running a Srotas configuration. Headers specified using this flag override any global headers defined in the configuration file.
Usage
srotas run --header "key1:'value1'" --header "key2: 'value2'" config.yamlAlias:
srotas run -H "key1:'value1'" -H "key2: 'value2'" config.yamlFormat
The --header flag follows the format:
"key:value"key: The name of the header.value: An expression that evaluates to a string. It has access to all static variables.
Multiple headers can be specified by using the flag multiple times.
Examples
Define an Authorization header dynamically:
srotas run --header "Authorization: 'Bearer $TOKEN'" config.yamlTip
This flag is useful when adding authentication headers dynamically instead of modifying the configuration file.
Warning
Multiple headers with the same name cannot be defined globally (in --header, --env, or the config file). If a duplicate header is defined, an error is raised.
Note
Headers specified using --header take precedence over those defined in --env and the configuration file.
For more details, refer Global Headers.
Variables
The --var flag in Srotas allows users to define global variables directly through the command line. It is useful for setting static values that can be referenced within the configuration file.
Usage
srotas run --var key1=value1 --var key2=value2 config.yamlAlias:
srotas run -V key1=value1 -V key2=value2 config.yamlFormat
Each --var flag must follow the format:
key=value- key: The name of the variable. Must be unique.
- value: An expr expression. This expression is evaluated without access to any other variables.
Multiple variables can be specified by using the flag multiple times.
Examples
srotas run --var timeout=30 --var api_version="v2" config.yamlNote
No variable references: The expressions in --var do not have access to any static or dynamic variables.
Warning
If a duplicate variable name is detected, Srotas will return an error.
For more details, refer Variables.
Chaining Configurations
Srotas supports piping output between executions:
srotas run fetch_users.yaml | srotas run process_tasks.yamlThis transfers the execution context from the first configuration to the second. Only the specified Output will be transfered.
Note
The output or output_all field is mandatory for proper configuration chaining.