32 lines
828 B
Python
32 lines
828 B
Python
import sys
|
|
import os
|
|
import json
|
|
|
|
CONSTRUCTED_CONFIG_FILE = "/tmp/runner-config.json"
|
|
|
|
|
|
def main() -> str:
|
|
try:
|
|
config = {
|
|
"registration_token": os.environ["SEMAPHORE_RUNNER_REGISTRATION_TOKEN"],
|
|
"config_file": os.getenv(
|
|
"SEMAPHORE_RUNNER_CONFIG_FILE", "/semaphore/runner.json"
|
|
),
|
|
"api_url": os.environ["SEMAPHORE_RUNNER_API_URL"],
|
|
"max_parallel_tasks": int(
|
|
os.getenv("SEMAPHORE_RUNNER_MAX_PARALLEL_TASKS", "1")
|
|
),
|
|
}
|
|
except KeyError as err:
|
|
print(f"Missing required configuration value {err}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
with open(CONSTRUCTED_CONFIG_FILE, "w") as outfile:
|
|
json.dump(config, outfile, indent=4)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|