Update to use GIT_SSH_COMMAND

This commit is contained in:
Guilhem Lavaux 2024-12-08 11:12:46 +01:00
parent 9eb189decd
commit f3d197dc9b

View File

@ -19,10 +19,13 @@ API_PASSWORD = os.environ['API_PASSWORD']
DATA_DIR = os.environ['DATA_DIR'] DATA_DIR = os.environ['DATA_DIR']
GIT_AUTH_MODE = os.environ['GIT_AUTH_MODE'] GIT_AUTH_MODE = os.environ['GIT_AUTH_MODE']
GIT_ENV = os.environ.copy()
if GIT_AUTH_MODE == 'http': if GIT_AUTH_MODE == 'http':
auth_option = [] auth_option = []
elif GIT_AUTH_MODE == 'ssh': elif GIT_AUTH_MODE == 'ssh':
auth_option = ['--config','core.sshCommand="ssh -i /ssh/ssh-key"','-o','StrictHostKeyChecking=accept-new'] GIT_ENV["GIT_SSH_COMMAND"] = "ssh -i /ssh/ssh-key"
auth_option=['-o','StrictHostKeyChecking=accept-new']
else: else:
raise ValueError("Invalid GIT_AUTH_MODE") raise ValueError("Invalid GIT_AUTH_MODE")
@ -127,6 +130,7 @@ def execute_git_pull(repo_path):
['git', 'pull'] + auth_option, ['git', 'pull'] + auth_option,
cwd=repo_path, cwd=repo_path,
capture_output=True, capture_output=True,
env=GIT_ENV,
text=True, text=True,
timeout=300 # 5-minute timeout timeout=300 # 5-minute timeout
) )