template
Render gear templates using cookiecutter and show the generated files in stdout.
This command works like gsf install — it accepts gear specifications (Docker image,
tar.gz archive, or source directory), downloads them (with registry credentials if needed),
finds the templates included in the gear, and renders them.
Display help text
To list the help on any command just execute the command, followed by the --help option
Arguments
| Name | Description | Example |
|---|---|---|
GEARS |
One or more gears to render templates from, specified as:
|
my-gear@1.0.0 |
Options
| Name | Description | Mandatory | Default value | Environment variable | Example |
|---|---|---|---|---|---|
--extravar |
Extra context variable for template rendering: variable name and value (repeatable) | - | - | - | project_name my-proj |
--registry-type |
Specify the registry type or use automatic detection | - | Autodetect |
- | Autodetect, Dockerhub, Artifactory, Nexus, Custom |
--registry |
Custom registry URL for authentication (required when --registry-type=Custom) |
- | - | - | https://my-registry.com |
--registry-username |
Username for basic authentication in the registry when downloading Gears | - | - | GSF_REGISTRY_USERNAME |
myusername |
--registry-password |
Password for basic authentication in the registry when downloading Gears | - | - | GSF_REGISTRY_PASSWORD |
MyPa$$w0rd |
--insecure-registry |
Allow insecure connections to the registry (use HTTP instead of HTTPS) | - | False |
- | |
-d, --directory |
Directory where generated files will be written. If not specified, a preview is shown in stdout | - | - | - | /opt/gsf-templated |
-o, --output |
File where the rendered template output will be captured (instead of stdout) | - | - | - | /opt/gsf-templated/preview.txt |
--debug |
Show debug level messages | - | False |
- |
Note
The banner, the start-parameters box, and the final "written to ..."
confirmation messages are printed by the logger to stderr.
The examples below show the stdout output only, which is exactly what the
template command is designed to produce.
Authentication
When the gear is a Docker image from a registry, the --registry-username and
--registry-password options (or GSF_REGISTRY_USERNAME/GSF_REGISTRY_PASSWORD
environment variables) are used to authenticate the image download.
Credentials are resolved in the following priority order:
- Command-line parameters (
--registry-username/--registry-password) - Stdin:
echo "<username>:<password>" | gsf template ... - Environment variables (
GSF_REGISTRY_USERNAME/GSF_REGISTRY_PASSWORD) - Interactive prompt if only one of username/password is specified
Command-line parameters take precedence over stdin, and stdin takes precedence over environment variables.
Examples
Render templates from a gear and show what files they would look like (stdout only):
Render templates from a gear and write the generated files into a directory:
The Files have been written to /opt/gsf-templated confirmation is printed to stderr
(see note above), in addition to the stdout preview shown above.
Render templates from a gear and capture the preview output into a file instead of stdout:
Stdout is empty — the preview is written to /opt/gsf-templated/preview.txt instead.
Only the confirmation message is printed to stderr:
Render a gear from a Docker registry using basic authentication: