Add dedicated operator Git identity
This commit is contained in:
@@ -14,6 +14,7 @@ import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import socketserver
|
||||
import subprocess
|
||||
@@ -70,8 +71,19 @@ def compact(text: str) -> str:
|
||||
|
||||
|
||||
def run(argv: list[str], *, cwd: Path = STACK, timeout: int = 900, check: bool = False) -> dict[str, Any]:
|
||||
environment = {
|
||||
"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
"LANG": "C.UTF-8",
|
||||
"HOME": "/root",
|
||||
}
|
||||
git_key = Path(os.environ.get("ATHENA_OPERATOR_GIT_SSH_KEY", "/etc/mike-ai/athena-operator-git"))
|
||||
if git_key.is_file():
|
||||
environment["GIT_SSH_COMMAND"] = (
|
||||
f"ssh -i {shlex.quote(str(git_key))} -o IdentitiesOnly=yes "
|
||||
"-o StrictHostKeyChecking=yes"
|
||||
)
|
||||
completed = subprocess.run(
|
||||
argv, cwd=cwd, env={"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "LANG": "C.UTF-8", "HOME": "/root"},
|
||||
argv, cwd=cwd, env=environment,
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
text=True, errors="replace", timeout=timeout, check=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user