Defining Variables

Nomatron is in early access. Some advanced workflows may not be covered in the public docs.

Writing the template file is only half of the job. The other half is defining the variables the template expects Nomatron to resolve.

What A Variable Needs

Each variable definition should answer four questions:

  • what is the key?
  • where does it belong?
  • what type is it?
  • is it sensitive?

In Nomatron, the important properties are:

  • key
  • description
  • value_type
  • sensitivity
  • an optional default value
  • any environment-specific overrides

Choose The Right Scope

Choose the scope based on who should own the value and how reusable it should be.

Use:

  • global for platform-wide values shared everywhere;
  • organization for tenant-level values;
  • app for values shared across jobs in one app; and
  • app job for values that only apply to one deployable job.

Examples:

VariableGood scopeWhy
GLOBAL_REGIONglobalshared platform setting
ORG_OWNERorganizationspecific to one tenant
APP_IMAGE_REPOSITORYappshared across one service
APP_JOB_COUNTapp jobspecific to one deployable workload

Choose The Right Type

Nomatron supports these value types:

  • string
  • number
  • bool
  • json

Pick the type that matches how the template uses the value.

Examples:

VariableGood typeWhy
IMAGE_TAGstringtextual container tag
COUNTnumbernumeric replica count
ENABLE_CANARYbooltrue/false behavior
DATACENTERSjsonstructured list or object

Choose The Right Sensitivity

Use:

  • normal for ordinary values; and
  • sensitive for secrets or values that should be masked in preview-style render flows.

Typical sensitive examples:

  • API tokens
  • passwords
  • DSNs containing credentials
  • private keys

Typical non-sensitive examples:

  • image tags
  • CPU and memory settings
  • region names
  • datacenter lists

Defaults And Environment Overrides

Nomatron resolves values in this pattern:

  1. environment-specific override, if one exists for the render target;
  2. default variable value, if one exists; then
  3. unresolved/missing, if neither exists.

That makes a good authoring pattern:

  • set a sensible default for values that usually stay the same; and
  • add environment-specific overrides only where behavior must differ.

Example:

VariableDefaultDev overrideProd override
IMAGE_TAGlatestdev-latestv1.2.3
APP_JOB_COUNT113

Example Variable Set

For a simple service template, you might define:

text
APP_IMAGE_REPOSITORY  string  normal
IMAGE_TAG             string  normal
APP_JOB_COUNT         number  normal
APP_JOB_CPU           number  normal
APP_JOB_MEMORY        number  normal
DATABASE_URL          string  sensitive

Then populate:

  • default values for the common baseline; and
  • environment overrides for anything that must differ across dev, staging, and prod.

Managing Variables

You can manage variables through:

Common Mistakes

The most common variable-definition mistakes are:

  • using the wrong type, such as string where the template expects a number;
  • storing secrets as normal instead of sensitive;
  • creating the variable in the wrong scope;
  • forgetting a default when no environment override exists; and
  • changing the key in Nomatron without changing the template token.