Skip to content

Commit eb94066

Browse files
author
Vitaliy Zakaznikov
committed
Fixing issue service missing other env vars used inside the config.
1 parent 6e1b652 commit eb94066

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

testflows/github/hetzner/runners/config/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
from .config import read, write
2727
from .config import parse_config
2828
from .config import default_user_config
29+
from .config import config_vars

testflows/github/hetzner/runners/config/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
default_user_config = os.path.expanduser("~/.github-hetzner-runners/config.yaml")
3131

32+
# store all the environment variables used inside the config file
33+
config_vars = {}
34+
3235

3336
def env_constructor(loader, node):
3437
value = loader.construct_scalar(node)
@@ -39,6 +42,7 @@ def env_constructor(loader, node):
3942
False
4043
), f"environment variable ${group} used in the config is not defined"
4144
value = value.replace(f"${{{group}}}", env_value)
45+
config_vars[group] = env_value
4246
return value
4347

4448

testflows/github/hetzner/runners/service.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from .actions import Action
2323
from .logger import decode_message
24+
from .config import config_vars
2425

2526

2627
def command_options(
@@ -115,8 +116,14 @@ def install(args, config):
115116
f"Environment=GITHUB_TOKEN={config.github_token}\n"
116117
f"Environment=GITHUB_REPOSITORY={config.github_repository}\n"
117118
f"Environment=HETZNER_TOKEN={config.hetzner_token}\n"
118-
f"ExecStart={binary}"
119119
)
120+
# add all other environment variables used inside the config file
121+
for var, value in config_vars.items():
122+
if var in ["GITHUB_TOKEN", "GITHUB_REPOSITORY", "HETZNER_TOKEN"]:
123+
continue
124+
contents += f"Environment={var}={value}\n"
125+
126+
contents += f"ExecStart={binary}"
120127
contents += f" --ssh-key {config.ssh_key}"
121128
contents += command_options(config)
122129
contents += "\n" "[Install]\n" "WantedBy=multi-user.target\n"

0 commit comments

Comments
 (0)