The config.json file contains the formula’s input parameters. It allows the CLI to know what data to ask the user when he runs the command in the terminal to process the formula correctly.
These input parameters are made up of the following fields:
{
"dockerImageBuilder": "dockerImage",
"dockerVolumes": [],
"inputs": [],
"requireLatestVersion": false,
}
For each volume that will be mapped, you must inform its origin and destination, using a colon ":" as a separator.
The source directory being /home/user-name/folder
and the destination directory /mount/folder
{
"dockerVolumes": [
"/home/user-name/folder:/mount/folder"
],
}
Each input parameter is composed of the following fields:
name
: variable name to extract.Once an input value is informed on Ritchie CLI, it is saved as a local variable during the formula execution.
The variable name will be convert uppercase as the local variable name.
A good practice is to add a _
RIT_
suffix to eachinput name
to avoid having conflicts with local variables.Example:
rit_file_name
–>RIT_FILE_NAME
type
:request_info
field below).label
: text appearing on the CLI, asking for the input.{
"label": "Type your name:",
"name": "rit_name",
"type": "text",
}
{
"label": "Choose one or more days: ",
"name": "rit_days",
"type": "multiselect",
"required": true,
"items": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Friday"
]
}
multiselect
typemultiselect
type,space
key (the enter
key will move to the next input, if any).multiselect
type field will return a string with:|
) and without space example: Monday | Wednesday | Friday
required
field as true
, otherwise, if no option is selected, the local variable will be saved as undefined
.{
"label": "Type the path to the folder with your file:",
"name": "rit_path",
"type": "path"
}
default
: default input value (if value is null).{
"label": "Type your name:",
"name": "rit_name",
"type": "text",
"default": "Dennis"
}
You also can make this default configuration with the default flag, which allows you to attribute default values configured on the formula.
In case of fields without a default value, the flag will keep asking for this inputs that must be configured on your config.json file.
required
: Boolean that indicates if the input value is required or optional.{
"label": "Type your name:",
"name": "rit_name",
"type": "text",
"required": true
}
tutorial
: Input helper message [? for help]{
"label": "Type your name:",
"name": "rit_name",
"type": "text",
"tutorial": "We are expecting you to write your name (ex: John)"
}
items
: List of input variable options.{
"label": "Type your name:",
"name": "rit_name",
"type": "text",
"items": [
"Dennis",
"John",
"Bill"
]
}
cache
: Saves former input values.active
: If the cache is enabled or not.qty
: Amount of values to store.newLabel
: Text appearing on the CLI asking for new input.{
"label": "Type your name:",
"name": "rit_name",
"type": "text",
"cache": {
"active": true,
"qty": 5,
"newLabel": "Type another name:"
}
}
condition
: It shows an input if the given condition succeeds.variable
: The variable name used on a previous input for comparison.operator
: A logical operator to compare. Supports ==
, !=
, <
, >
, <=
and >=
.value
: The desired value to compare to.{
"label": "Type your name:",
"name": "rit_name",
"type": "text",
"default": "Dennis"
},
{
"condition": {
"variable": "rit_name",
"operator": "!=",
"value": "Dennis"
}
"label": "What is your date of birth?",
"name": "rit_date_of_birth",
"type": "text",
}
pattern
: Configure the input value validation.regex
: The regex pattern to validate the input.mismatchText
: An error message when the input doesn’t match the regex pattern.{
"label": "What is your age",
"name": "rit_age",
"type": "text",
"pattern": {
"regex": "[0-9]",
"mismatchText": "Only a integer value is allowed here (ex: 20)"
}
}
dynamic input
type will be deprecated in the next releases.requestInfo
: A configuration to get the dynamic input type.url
: An URL to consume a GET service that will return a list of objects.jsonPath
: A JSON path where the variable extracts a returned list for every object, see "jsonPath": $['user']['name']
(Check out how the JSON path works).{
"label": "Type your name:",
"name": "rit_name",
"type": "text",
"requestInfo": {
"url": "https://my-url.com",
"jsonPath": $['user']['name']
}
}
"inputs": [
{
"label": "Select a system:",
"name": "rit_system",
"type": "text",
"items": [
"LINUX",
"MACOS",
"WINDOWS"
],
"required": true,
"tutorial": "Select a System from the list."
},
{
"condition": {
"variable":"rit_system",
"operator":"==",
"value":"LINUX"
},
"label": "Select a LINUX OS:",
"name": "rit_linux_os",
"type": "text",
"items": [
"UBUNTU",
"FEDORA",
"CENTOS"
],
"pattern": {
"regex": "UBUNTU|FEDORA|CENTOS",
"mismatchText": "Invalid option"
},
"required": false,
"tutorial": "Select an Linux Operating System from the list."
}
]
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.