Skip to content

Commit

Permalink
Update argocd backend to match new charts
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelldls committed Aug 28, 2024
1 parent 845cd0c commit 424f8a7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
46 changes: 22 additions & 24 deletions src/edge_containers_cli/cmds/argo_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,14 @@ def restart(self, service_name):

def start(self, service_name):
self._check_service(service_name)
cmd = (
f"argocd app set {self.target} " f"-p services.{service_name}.enabled=true"
)
project, app = extract_project_app(self.target)
cmd = f"argocd app set {project}/{service_name} -p global.enabled=true"
shell.run_command(cmd, skip_on_dryrun=True)

def stop(self, service_name):
self._check_service(service_name)
cmd = (
f"argocd app set {self.target} " f"-p services.{service_name}.enabled=false"
)
project, app = extract_project_app(self.target)
cmd = f"argocd app set {project}/{service_name} -p global.enabled=false"
shell.run_command(cmd, skip_on_dryrun=True)

def _get_logs(self, service_name, prev) -> str:
Expand Down Expand Up @@ -106,25 +104,25 @@ def _get_services(self, running_only) -> ServicesDataFrame:
)
for resource_manifest in mani_resp.split("---")[1:]:
manifest = YAML(typ="safe").load(resource_manifest)
time_stamp = datetime.strptime(
manifest["metadata"]["creationTimestamp"],
"%Y-%m-%dT%H:%M:%SZ",
)
try:
if manifest["metadata"]["name"] == name:
kind = manifest["kind"]
resource_name = manifest["metadata"]["name"]
if kind == "StatefulSet" and resource_name == name:
try:
is_ready = bool(manifest["status"]["readyReplicas"])
except (KeyError, TypeError): # Not ready if doesnt exist
continue

# Fill app data
service_data["name"].append(name)
service_data["version"].append(
app["spec"]["source"]["targetRevision"]
)
service_data["ready"].append(is_ready)
service_data["deployed"].append(
datetime.strftime(time_stamp, TIME_FORMAT)
)
except (KeyError, TypeError): # Not ready if doesnt exist
is_ready = False

Check warning on line 113 in src/edge_containers_cli/cmds/argo_commands.py

View check run for this annotation

Codecov / codecov/patch

src/edge_containers_cli/cmds/argo_commands.py#L112-L113

Added lines #L112 - L113 were not covered by tests
time_stamp = datetime.strptime(
manifest["metadata"]["creationTimestamp"],
"%Y-%m-%dT%H:%M:%SZ",
)
service_data["name"].append(name)
service_data["version"].append(
app["spec"]["source"]["targetRevision"]
)
service_data["ready"].append(is_ready)
service_data["deployed"].append(
datetime.strftime(time_stamp, TIME_FORMAT)
)

services_df = polars.from_dict(service_data)

Expand Down
4 changes: 2 additions & 2 deletions tests/data/argocd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ restart:
rsp: ""

start:
- cmd: argocd app set project/bl01t -p services.bl01t-ea-test-01.enabled=true
- cmd: argocd app set project/bl01t-ea-test-01 -p global.enabled=true
rsp: ""

stop:
- cmd: argocd app set project/bl01t -p services.bl01t-ea-test-01.enabled=false
- cmd: argocd app set project/bl01t-ea-test-01 -p global.enabled=false
rsp: ""

0 comments on commit 424f8a7

Please sign in to comment.