Detectors

The [detectors] table allows you to define custom tags based on the output of a command. This is useful for creating tags that are specific to your environment.

The key is the name of the tag to be created. The value is a table specifying how to determine the tag’s state.

There are three types of detectors:

KeyTypeDescription
enable_ifStringA command to run. If the command exits with a success code (0), the tag is activated (with no value).
enable_if_notStringA command to run. If the command exits with a non-zero exit code, the tag is activated (with no value).
value_ofStringA command to run. The standard output of the command is used as the value for the tag. For example, if the command outputs bar, the tag will be foo=bar (for a detector named foo).

Example

[detectors]
# The `k9s` tag is activated if the command returns a successful exit code.
k9s = { enable_if = "command -v kubectl" }
# The `is_container` tag is activated if the command returns a non-zero exit code.
is_container = { enable_if_not = "grep -q 'systemd' /proc/1/cmdline" }
# Upon successful execution, the command's standard output is used to set a tag's value,
# for example `shell=/bin/bash`.
shell = { value_of = "echo $SHELL" }