Configure Inputs

In this section, you will find information about a formula config.json file

What is the config.json file?

The config.json file contains the formula’s input parameters. It allows the CLI to know what datas to ask the user when he runs the command in the terminal in order to process the formula correctly.

These input parameters are made up of the following fields:

  • a docker image builder (according to the programming language chose at the formula creation)
  • the formula inputs parameters list.
  • a require latest version boolean, indicating the need (or not) of the formula to run in the last available version of a repository.
{
  "dockerImageBuilder": "dockerImage",
  "inputs": [],
  "requireLatestVersion": false,
}

Input parameter configuration

Each input parameter is composed of the following fields:

Mandatory fields

  • name: variable name to extract.

A good practice is to add a _RIT_ suffix to each input name to avoid having conflicts with local variables.

Example: rit_file_name –> RIT_FILE_NAME

  • type:
    • text (string),
    • bool (boolean),
    • password (hidden string on CLI),
    • credentials (specific type, check out more on use crendential as formula inputs_),
    • dynamic (associated with the optional request_info field below),
    • path: enables the autocomplete to inform a path to a folder or a file (string).
  • label: text appearing on the CLI, asking for the input.

Input example with mandatory fields:

{
      "label": "Type your name:",
      "name": "rit_name",
      "type": "text",
}

Input example with the multiselect type:

{
      "label": "Choose one or more days: ",
      "name": "rit_days",
      "type": "multiselect",
      "required": true,
      "items": [
           "Monday",
           "Tuesday",
           "Wednesday",
           "Thursday",
           "Friday",
           "Saturday",
           "Friday"
      ]
}

Some observations regarding the multiselect type

  • To select one of the options with the multiselect type, you must press the space key (the enter key will move to the next input, if any)

  • The options selected in the multiselect type field will return a string with the options separated by pipe (|) and without space example: Monday | Wednesday | Friday

  • It is suggested to use the required field as true, otherwise, if no option is selected, the local variable will be saved as undefined

Parameter example using the autocomplete type:

{
      "label": "Type the path to the folder with your file:",
      "name": "rit_path",
      "type": "path"
}

Optional fields

  • default: default input value (if null).
{
      "label": "Type your name:",
      "name": "rit_name",
      "type": "text",
      "default": "Dennis"
}
  • 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)"
      }
}
  • 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']
      }
}

Conditional input example with Regex pattern:

"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."
    }
  ]