Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] argocd_deployer - Pre-commit again #24

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading