Skip to content

Commit d64c2c4

Browse files
committed
Enable passing a FullStatus object to jockey.query
1 parent 03e2588 commit d64c2c4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/jockey/core.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@
1010
import os
1111
import re
1212
import subprocess
13-
from typing import Any, Dict, Generator, Iterable, List, Optional
13+
from typing import Generator, Iterable, List, Optional
1414

15+
from juju.client.client import FullStatus as JujuStatus
1516
from jockey.cache import load_cache, new_cache_context, update_cache
1617
from jockey.log import configure_logging
1718

1819

1920
logger = logging.getLogger(__name__)
2021

2122

22-
JujuStatus = Dict[str, Any]
23-
24-
2523
class FilterMode(Enum):
2624
EQUALS = "="
2725
CONTAINS = "~"
@@ -301,7 +299,7 @@ def is_app_principal(status: JujuStatus, app_name: str) -> bool:
301299
is_principal (bool)
302300
Whether the indicated application is principal.
303301
"""
304-
return "subordinate-to" not in status["applications"][app_name]
302+
return status["applications"][app_name].get("subordinate-to") is None
305303

306304

307305
def get_principal_unit_for_subordinate(status: JujuStatus, unit_name: str) -> str:
@@ -957,7 +955,7 @@ def get_juju_status(
957955
logger.debug("Loading local Juju status from %r", file)
958956
# print(dir(file))
959957
with open(file, "r") as f:
960-
return json.loads(f.read())
958+
return JujuStatus.from_json(f.read())
961959

962960
# Get model name and build a CacheContext
963961
model_name = model_name or os.environ.get("JUJU_MODEL", None)

0 commit comments

Comments
 (0)