33 lines
829 B
Python
33 lines
829 B
Python
|
import sys
|
||
|
import os
|
||
|
import json
|
||
|
import tempfile
|
||
|
|
||
|
|
||
|
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)
|
||
|
|
||
|
path = tempfile.mkstemp(prefix="semaphore-runner-")
|
||
|
|
||
|
with open(path, "w") as outfile:
|
||
|
json.dump(config, outfile, indent=4)
|
||
|
|
||
|
return path
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|