Skip to content

Commit

Permalink
Merge pull request #36 from canonical/jsonschema_dependency
Browse files Browse the repository at this point in the history
Document ingress_per_unit lib dependencies
  • Loading branch information
PietroPasotti authored Apr 13, 2022
2 parents ab5306e + 0fecf52 commit 5b42a51
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/charms/traefik_k8s/v0/ingress_per_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
charmcraft fetch-lib charms.traefik_k8s.v0.ingress_per_unit
```
Add the `jsonschema` dependency to the `requirements.txt` of your charm.
```yaml
requires:
ingress:
Expand Down Expand Up @@ -50,7 +52,14 @@ def _handle_ingress_per_unit(self, event):
import warnings
from typing import Any, Dict, List, Optional, Tuple, TypeVar, Union

import jsonschema
try:
import jsonschema
except ModuleNotFoundError:
raise Exception(
"The ingress_per_unit library needs the jsonschema package as dependency; "
"add 'jsonschema' to the 'requirements.txt' of your charm."
)

import yaml
from ops.charm import CharmBase, RelationBrokenEvent, RelationEvent
from ops.framework import EventSource, Object, ObjectEvents
Expand All @@ -65,7 +74,7 @@ def _handle_ingress_per_unit(self, event):
)

# The unique Charmhub library identifier, never change it
LIBID = "7ef06111da2945ed84f4f5d4eb5b353a" # can't register a library until the charm is in the store 9_9
LIBID = "7ef06111da2945ed84f4f5d4eb5b353a"

# Increment this major API version when introducing breaking changes
LIBAPI = 0
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ ops == 1.3.0 # 1.4.0 breaks SDI-based tests
deepmerge
lightkube >= 0.8.1
lightkube-models >= 1.22.0.4
serialized-data-interface>=0.4.0
# The following is needed by lib/charms/traefik_k8s/v0/ingress_per_unit.py
jsonschema
# The following is needed by lib/charms/traefik_k8s/v0/ingress.py
serialized-data-interface==0.4.0 # Pin to avoid incompatible changes until dropped

0 comments on commit 5b42a51

Please sign in to comment.