For the complete documentation index, see llms.txt. This page is also available as Markdown.

Fill a configuration file from a template

Some tools only read their settings from a file, like appsettings.json, a YAML configuration, or a .npmrc. With devo secret inject, you keep a template with devo:// references in your repository, and generate the real file when you need it.

Write the template

Put a reference wherever a secret goes. Wrap it in {{ }} so Devolutions CLI knows exactly where it starts and ends:

{
  "Database": {
    "User": "{{ devo://ws/<workspace-id>/vault/<vault-id>/entry/<entry-id>/field/username }}",
    "Password": "{{ devo://ws/<workspace-id>/vault/<vault-id>/entry/<entry-id>/field/password }}"
  }
}

A reference without {{ }} also works. It ends at the first space, quote, <, >, ), ], or }.

Inside a reference, $NAME, ${NAME}, and ${NAME:-default} are replaced by the value of an environment variable before the reference is resolved. Use this to share one template between environments, for example devo://ws/${WORKSPACE_ID}/vault/….

Generate the file

devo secret inject --in-file appsettings.template.json --out-file appsettings.json
OPTION
WHAT IT DOES

--in-file, -i

The template to read. Without it, Devolutions CLI reads the template from standard input.

--out-file, -f

The file to write. Without it, the result goes to standard output.

--force

Replaces the output file if it already exists. Without it, the command stops before reading any secret.

You can also work with pipes, for example to pass the result straight to another program:

What you can rely on

  • All or nothing. If one reference can't be resolved, Devolutions CLI writes no file and none of the template. It lists the errors on standard error, prints a summary line such as References: 1/2 resolved on standard output, and exits with code 1.

  • Private file. The output file is created with private permissions: on macOS and Linux, only your user account can read it; on Windows, your account, the system account, and administrators.

  • No half-written file. Devolutions CLI writes to a temporary file in the same folder, then moves it into place.

  • Each reference is read once. A reference used several times in the template is resolved once.

With --output json, the command returns a summary instead of the content: how many references it found and resolved. The values aren't in it.

Good to know

  • With standard output, the values appear in your terminal or in whatever reads the pipe. Prefer --out-file when you don't need a pipe.

  • References resolve through the current context. Add --context <context-name> to use another workspace. Canonical references always resolve against the workspace that owns them.

  • A reference doesn't resolve: see A secret reference doesn't resolve.

Next

Last updated

Was this helpful?