forked from Hostea/dashboard
Merge pull request 'clone instead of fetch' (#19) from dachary/dashboard:wip-pull into master
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/19wip-site
commit
147eead388
|
@ -116,9 +116,12 @@ class Infra:
|
|||
|
||||
ssh_cmd = f"/usr/bin/ssh -oStrictHostKeyChecking=no -i {conf['SSH_KEY']}"
|
||||
self.env = {"GIT_SSH_COMMAND": ssh_cmd}
|
||||
try:
|
||||
self.repo = Repo(path=self.repo_path)
|
||||
except InvalidGitRepositoryError:
|
||||
self._clone()
|
||||
|
||||
def _clone(self):
|
||||
conf = settings.HOSTEA["INFRA"]["HOSTEA_REPO"]
|
||||
if os.path.exists(self.repo_path):
|
||||
shutil.rmtree(self.repo_path)
|
||||
self.repo = Repo.clone_from(conf["REMOTE"], self.repo_path, env=self.env)
|
||||
|
||||
def _host_vars_dir(self, subdomain: str) -> Path:
|
||||
|
@ -227,11 +230,6 @@ class Infra:
|
|||
author="Dashboard Bot <bot@dashboard.hostea.org>",
|
||||
)
|
||||
|
||||
def _pull(self):
|
||||
self.repo.git.fetch(env=self.env)
|
||||
|
||||
# TODO: switch to using Git cmd
|
||||
|
||||
@staticmethod
|
||||
def translate_size(instance: Instance) -> str:
|
||||
"""
|
||||
|
@ -252,7 +250,7 @@ class Infra:
|
|||
|
||||
The gitea user password is returned
|
||||
"""
|
||||
self._pull()
|
||||
self._clone()
|
||||
|
||||
subdomain = instance.name
|
||||
host_vars_dir = self._host_vars_dir(subdomain)
|
||||
|
@ -331,7 +329,7 @@ class Infra:
|
|||
"""
|
||||
Remove a VM from infrastructure repository
|
||||
"""
|
||||
self._pull()
|
||||
self._clone()
|
||||
subdomain = instance.name
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue