Repository navigation
Conversation
inqrphl
commented
Nov 9, 2026
| {"multiple", "$ENV{SNCLIENT_TEST_ENV}/$ENV{SNCLIENT_TEST_ENV}", "value/value", ""}, | ||
| {"quoted", `"$ENV{SNCLIENT_TEST_ENV}"`, `"value"`, ""}, | ||
| {"empty", "[$ENV{SNCLIENT_TEST_ENV_EMPTY}]", "[]", ""}, | ||
| {"spaces", "$ENV{ SNCLIENT_TEST_ENV }", "value", ""}, |
Contributor
Author
There was a problem hiding this comment.
i am not completely sure about this. The code strips the string inside the braces before looking up
| {"spaces", "$ENV{ SNCLIENT_TEST_ENV }", "value", ""}, | ||
| {"escape", "$$ENV{SNCLIENT_TEST_ENV}", "$ENV{SNCLIENT_TEST_ENV}", ""}, | ||
| {"unclosed", "$ENV{SNCLIENT_TEST_ENV", "$ENV{SNCLIENT_TEST_ENV", ""}, | ||
| {"nested", "$ENV{SNCLIENT_TEST_ENV_NESTED}", "$ENV{SNCLIENT_TEST_ENV}", ""}, |
Contributor
Author
There was a problem hiding this comment.
environment variables are resolved only one time, and that is intended.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI summary of the changes, I verified the code myself.
Support environment variables in INI config values
Summary
This adds a new
$ENV{NAME}syntax for referencing environment variables inSNClient configuration values. It allows distributing the same configuration
files to many nodes and only changing the environment per node.
Example:
Motivation
Configuration files are often distributed from a central place, while a few
values differ per node (hostnames, IPs, paths, credentials, include files).
Environment variables make it possible to keep a single configuration template
without generating per-node files.
Syntax and behavior
$ENV{NAME}is replaced with the value of the environment variableNAME.$$ENV{NAME}escapes the syntax and produces a literal$ENV{NAME}.snclient config checkreportsthe variable name and the config file/line.
$ENV{...}inside an environment variable value isnot expanded again.
+=appends,[/paths], and includepaths.
runtime macros, so environment values cannot be exposed through
user-controlled check templates.
The exact form
$ENV{...}is not used by any existing macro tokenizer(
${...},$(...),%{...},%(...),$...$,%...%,{{...}}), soexisting configurations are unaffected.
Implementation
pkg/snclient/config_env.go.ConfigSection.SetRaw.rewrites do not replace it with the node-specific value.
command strings, which are built from the raw value, get the environment
value.
errors for empty include paths.
ReadConfiguration, so missingvariables fail
snclient config checkand daemon startup instead of beingsilently ignored.
Documentation
docs/configuration/_index.md, including service environment caveats forsystemd and Windows.
next:.Tests
Added unit tests covering:
$$ENV{...}escaping+=appends[/paths]expansion throughReadConfigurationVerified with:
Also verified end-to-end with
snclient config check:OK - no configuration issues detectedenvironment variable "SNCLIENT_TEST_HOSTS" is not setNotes
is loaded. Changing service environment variables requires a service restart;
a config reload alone does not pick them up.
the current behavior is to fail the config check explicitly rather than
silently substituting an empty value.