Skip to content

Commit

Permalink
Fix docker ps labels format issue
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelldls committed Mar 20, 2024
1 parent ff2cdc6 commit 9db46a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/edge_containers_cli/cmds/local_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ def ps(self, all: bool, wide: bool):
for line in str(result_json).strip().split("\n"):
services_dicts.append(json.load(StringIO(line)))

# Docker returns labels as a single string "key0=x,key1=y"
for service_dict in services_dicts:
labels_list = service_dict["Labels"].split(",")
labels_dict = {
entry[0].split("="): entry[1].split("=") for entry in labels_list
}
service_dict["Labels"] = labels_dict

if not services_dicts:
if all_arg:
print("No deployed services found")
Expand Down
2 changes: 1 addition & 1 deletion tests/data/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ps:
{
"CreatedAt":"",
"Image": "",
"Labels":{"version":""},
"Labels":"is_IOC=true,version=0",
"Names":[""],
"State":"",
"Restarts":""
Expand Down

0 comments on commit 9db46a0

Please sign in to comment.