Skip to content

Output Colors

The opentf-ctl get workflow command supports colors when showing a workflow status in ‘log’ format.

By default, command outputs are green, and errors are red. The rest of the output is not colored.

Note

Coloration is disabled on a non-TTY output (say, a regular file) by default, and enabled otherwise. This behavior can be overridden using environment variables.

Enabling or Disabling Colors

Coloration is configurable, and follows the common environment variables conventions:

  • if FORCE_COLOR is set to 1, on, true, or yes, then colors are enabled.
  • if NO_COLOR is set to 1, on, true, or yes, then colors are disabled.
  • if OPENTF_COLORS is set to 1, on, true, or yes, the colors are enabled.

OPENTF_COLORS takes precedence over NO_COLOR, which in turn takes precedence over FORCE_COLOR.

Alternatively, you can set your user’s profile colors to '', in which case there will never be colors in your outputs.

Configuring Colors

Colors are specified in a format like LS_COLORS in the user section of your configuration file.

You can use opentf-ctl config set-credentials my_user --colors=... to set the colors for your user, or you can edit your configuration file as usual.

There is one optional colors entry per user entry.

Configuration file
apiVersion: opentestfactory.org/v1alpha1
kind: CtlConfig
contexts:
- name: local
  context:
    orchestrator: local
    user: me
current-context: local
orchestrators:
- name: local
  orchestrator:
    ...
users:
- name: me
  user:
    colors: 'out=32:err=31'

The colors entry is a colon-separated list of name=color pairs, where name is the name of the area to color, and color is the color to use. The color is an ANSI color code, or a series of ANSI color codes separated by semi-colons:

out=32:err=31:pre=97;105

Here, environment output will be green, errors red, and prefix bright white on magenta.

If no colors entry is defined, green for out and red for err are the defaults:

out=32:err=31

The following area are defined:

name area
pre prefix
inv invalid prefix
req environment request
rel environment release
idx nested indent
run running command
grp group event
ntf notification
att attachment
out environment output
ret running command non-zero return code
err execution error
ttl title
ns namespace
fun running function or bundle
sta workflow status
rsn workflow failure reason

Examples

Default colors

Default colors: green for outputs

When no specific colors entry is defined, and if coloration is enabled (the default for TTY outputs), environment output is in green and error are in red.

Fancy colors

Fancy colors: green for outputs

If your colors entry is:

out=32:err=31:grp=4:pre=97;105:ns=1:idx=7:rel=4;93:req=4;93

environment output will be green, errors red, group events underlined, prefix bright white on magenta, namespace bright white, indent level reversed, and environment requests and releases underlined orange.

No color

No color: same color for everything

If your colors entry is defined as '' or if you are using commands such as:

NO_COLOR=1 opentf-ctl get workflow ab12
opentf-ctl get workflow ab12 > logs
opentf-ctl get workflow ab12 | less