Skip to content

Commit

Permalink
rename peer relation
Browse files Browse the repository at this point in the history
  • Loading branch information
kelkawi-a committed Jul 16, 2024
1 parent 1fe8706 commit 49296f2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
11 changes: 8 additions & 3 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ description: |
links:
documentation: https://discourse.charmhub.io/t/charmed-airbyte-k8s-overview/14530
source: https://github.com/canonical/airbyte-k8s-operator
issues: https://github.com/canonical/airbyte-k8s-operator/issues
source:
- https://github.com/canonical/airbyte-k8s-operator
issues:
- https://github.com/canonical/airbyte-k8s-operator/issues

# (Required for 'charm' type)
bases:
Expand All @@ -27,10 +29,13 @@ bases:
- name: ubuntu
channel: "22.04"

assumes:
- juju >= 3.1
- k8s-api

# Metadata
peers:
peer:
airbyte-peer:
interface: airbyte

requires:
Expand Down
4 changes: 2 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def __init__(self, *args):
args: Ignore.
"""
super().__init__(*args)
self._state = State(self.app, lambda: self.model.get_relation("peer"))
self._state = State(self.app, lambda: self.model.get_relation("airbyte-peer"))

self.framework.observe(self.on.config_changed, self._on_config_changed)
self.framework.observe(self.on.peer_relation_changed, self._on_peer_relation_changed)
self.framework.observe(self.on.airbyte_peer_relation_changed, self._on_peer_relation_changed)
self.framework.observe(self.on.update_status, self._on_update_status)

# Handle postgresql relation.
Expand Down
4 changes: 2 additions & 2 deletions src/relations/minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def _get_interfaces(self):
charm = self.charm
# Hack: get_interfaces checks for peer relation which does not exist under
# requires/provides list in charmcraft.yaml
if "peer" in charm.meta.relations:
del charm.meta.relations["peer"]
if "airbyte-peer" in charm.meta.relations:
del charm.meta.relations["airbyte-peer"]
interfaces = get_interfaces(charm)
except NoVersionsListed as err:
raise ErrorWithStatus(err, WaitingStatus) from err
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def setUp(self):
self.harness.set_can_connect(container_name, True)
self.harness.set_leader(True)
self.harness.set_model_name("airbyte-model")
self.harness.add_network("10.0.0.10", endpoint="peer")
self.harness.add_network("10.0.0.10", endpoint="airbyte-peer")
self.harness.begin()

def test_initial_plan(self):
Expand All @@ -78,7 +78,7 @@ def test_blocked_by_db(self):
harness = self.harness

# Simulate peer relation readiness.
harness.add_relation("peer", "airbyte")
harness.add_relation("airbyte-peer", "airbyte")

simulate_pebble_readiness(harness)

Expand All @@ -93,7 +93,7 @@ def test_blocked_by_minio(self):
harness = self.harness

# Simulate peer relation readiness.
harness.add_relation("peer", "airbyte")
harness.add_relation("airbyte-peer", "airbyte")

simulate_pebble_readiness(harness)

Expand All @@ -114,7 +114,7 @@ def test_blocked_by_s3(self):
harness.update_config({"storage-type": "S3"})

# Simulate peer relation readiness.
harness.add_relation("peer", "airbyte")
harness.add_relation("airbyte-peer", "airbyte")

simulate_pebble_readiness(harness)

Expand Down Expand Up @@ -262,7 +262,7 @@ def simulate_lifecycle(
set_bucket_lifecycle_policy: Mock of "set_bucket_lifecycle_policy" method.
"""
# Simulate peer relation readiness.
harness.add_relation("peer", "airbyte")
harness.add_relation("airbyte-peer", "airbyte")

simulate_pebble_readiness(harness)

Expand Down

0 comments on commit 49296f2

Please sign in to comment.