Attribute

An attribute is part of a packet and defines a field for that packet.

Attributes can be displayed as single- or multiline text, checkbox, date or number.

Lists

There are several ways to populate lists:

  • Comma separated values.
  • From instances in the environment.
  • From a script in the packet.
  • From a custom Docker image.

To create list, the attribute type should always be “Text (One line)".
If a user should be able to specify an item that’s not in the list, then select option “New items allowed”.

Comma separated values

Use field “List of values” in the attribute to specify the values separated by comma’s.
Each item can just a value, or a name-value pair.

Value list

Example: red,green,blue

The result of $instance.getAttribute("<attribute name>") will be red, green, …

Name-value list

Example: GREEN=green,RED=red,BLUE=blue

The result of $instance.getAttribute("<attribute name>") will be GREEN, RED, …

Instances in the environment.

A dropdown can contain a list of the values of a specific attribute from other instances.
These instances can be selected in several ways. To way instances are retrieved depends on the value of the “Source”-attribute:

Velocity Name

An instance with Velocity name equal to attribute ‘Reference filter’ is selected as the root to search under. An error is displayed if no instance is found in the current environment with the specified Velocity name.

Container Instance

Only instances that exist on the current container can be added to the list.

Environment Instance

Any instance in the environment can be added to the list.

Script

See Dynamic lists in Infraxys-by-example.

A script can be used to generate the contents of a list.
The script is executed while opening instance forms and the form is only displayed after the list is populated.

Script results can be cached using field “Cache minutes”. The script (or Docker container) is only run again if the cache for the attribute has expired.
The cache for an attribute can be cleared through the “Clear list cache”-button in the attribute definition screen.

Attribute “Reference filter” should contain the filename of a script in the same packet.
The script is run in a Docker container.

You can change the default Docker image by providing one like ubuntu:18.04 in the “Ref. value attribute”-field.
This allows you to specify images that have pre-populated lists in them or software that retrieves values from a database, object store, REST API, …

The structure of the output of the script is parsed in the following ways:

  1. If the output is one line, it’s processed is if it was the value of the “List of values”-attribute.
  2. If the output doesn’t contain a line like specified below, every line is treated as an entry for the list.
  3. If the output has a line !!!values (exact match), then all subsequent lines are treated as entries for the list.
  4. If the output has a line !!!name-values (exact match), then all subsequent lines are treated as entries for the list. The name-part is stored in the attribute value and the value-part is displayed in the list.

Examples:

echo "us-east-1,eu-west-1";
echo "us-east-1=United States,eu-west-1=Europe"
echo "US=us-east-1
BE=be-north-2"
#!/usr/bin/env sh

echo "Generating contents" # this is displayed nowhere when this script is run for dropdown population

cat << EOF
!!!values
us-east-1
eu-west-1
EOF
#!/usr/bin/env sh

echo "Generating contents" # this is displayed nowhere when this script is run for dropdown population

cat << EOF
!!!name-values
us-east-1=United States
eu-west-1=Europe
EOF

Custom Docker image.

See Dynamic lists in Infraxys-by-example.

Infraxys lets you use a script or a custom Docker image to generate the contents of dropdowns. Same structure applies as the output from scripts explained above, except that the Docker image, like ubuntu:18.04 is specified in the “Reference filter”.
Another difference is that the value of field “Ref. value attribute” is added to the command-line that’s used to run the Docker container.
This enables the use of one Docker image for several types of attributes.