Skip to content

Commit

Permalink
feat: add a manually updated collection of excluded facades
Browse files Browse the repository at this point in the history
These are facades that python-libjuju does not yet support. They should
not be included in client_facades.

Update validate test to reflect this.
  • Loading branch information
james-garner-canonical committed Oct 10, 2024
1 parent 0bc2a5f commit d64d786
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion juju/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import weakref
from http.client import HTTPSConnection
from dateutil.parser import parse
from typing import Dict, List

import macaroonbakery.bakery as bakery
import macaroonbakery.httpbakery as httpbakery
Expand All @@ -20,7 +21,12 @@

log = logging.getLogger('juju.client.connection')

# Manual list of facades present in schemas + codegen which python-libjuju does not yet support
excluded_facades: Dict[str, List[int]] = {
'Charms': [7],
}
# Please keep in alphabetical order
# in future this will likely be generated automatically (perhaps at runtime)
client_facades = {
'Action': {'versions': [7]},
'ActionPruner': {'versions': [1]},
Expand Down Expand Up @@ -51,7 +57,7 @@
'CAASUnitProvisioner': {'versions': [2]},
'CharmDownloader': {'versions': [1]},
'CharmRevisionUpdater': {'versions': [2]},
'Charms': {'versions': [6, 7]},
'Charms': {'versions': [6]},
'Cleaner': {'versions': [2]},
'Client': {'versions': [6, 7]},
'Cloud': {'versions': [7]},
Expand Down
3 changes: 3 additions & 0 deletions tests/validate/test_facades.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ def make_client_facades_from_generated_code(project_root: Path) -> ClientFacades
first, *rest = facades_by_version.values()
sorted_facade_names: list[str] = sorted(first.union(*rest))

excluded_facades = connection.excluded_facades
client_facades: ClientFacades = {}
# {facade_name: {'versions': [1, 2, 3, ...]}, ...}
for name in sorted_facade_names:
versions: List[int] = []
for version, facades in facades_by_version.items():
if version in excluded_facades.get(name, []):
continue
if name in facades:
versions.append(version)
client_facades[name] = {'versions': versions}
Expand Down

0 comments on commit d64d786

Please sign in to comment.