Skip to content

Commit

Permalink
Merge pull request #24 from onesteinbv/16.0-deployment-fixes
Browse files Browse the repository at this point in the history
[FIX] argocd_deployer - Pre-commit again
  • Loading branch information
MrGigSolutions authored Apr 3, 2024
2 parents 32034b5 + 70d4e3b commit 76cd03f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions argocd_deployer/models/application_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def _compute_is_deployed(self):
for app_set in self:
if app_set.is_master:
path = app_set._get_master_repository_directory("ignore")
path = os.path.join(path, "master_application_set/templates")
else:
path = app_set._get_application_set_deployment_directory("ignore")
path = os.path.join(
Expand Down Expand Up @@ -263,15 +264,23 @@ def _get_argocd_template(self):
return template_yaml

def _create_master_application_set(self):
"""The master application set will be deployed in a master_application_set folder
in the root of the repository. There will be a templates folder in it, and a
Chart.yaml file."""
self.ensure_one()
template_yaml = self._get_argocd_template()
application_set_dir = self._get_master_repository_directory("create")
yaml_file = os.path.join(application_set_dir, "application_set.yaml")
repo_dir = self._get_master_repository_directory("create")
application_set_dir = os.path.join(repo_dir, "master_application_set")
template_dir = os.path.join(application_set_dir, "templates")
if not os.path.exists(template_dir):
os.makedirs(template_dir)
message = "Added application set `%s`."

yaml_file = os.path.join(template_dir, "application_set.yaml")
with open(yaml_file, "w") as fh:
fh.write(template_yaml)

chart_file = os.path.join(application_set_dir, "..", "Chart.yaml")
chart_file = os.path.join(application_set_dir, "Chart.yaml")
with open(chart_file, "w") as fh:
fh.write(
f"""apiVersion: v2
Expand Down Expand Up @@ -300,14 +309,15 @@ def _create_application_set(self):
def _remove_master_application_set(self):
"""Remove an application set for ArgoCD."""
self.ensure_one()
deployment_directory = self._get_master_deployment_directory("error")
repo_dir = self._get_master_repository_directory("error")
application_set_dir = os.path.join(repo_dir, "master_application_set")
template_dir = os.path.join(application_set_dir, "templates")
message = "Removed application set `%s`."
application_set_dir = deployment_directory
yaml_file = os.path.join(application_set_dir, "application_set.yaml")
yaml_file = os.path.join(template_dir, "application_set.yaml")
chart_file = os.path.join(application_set_dir, "Chart.yaml")
os.remove(chart_file)
os.remove(yaml_file)
if not self.is_master:
os.removedirs(application_set_dir)
chart_file = os.path.join(application_set_dir, "..", "Chart.yaml")
os.removedirs(template_dir)

return {REMOVE_FILES: [yaml_file, chart_file]}, message

Expand Down

0 comments on commit 76cd03f

Please sign in to comment.