Skip to content

Commit

Permalink
feat: add maubot rock (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandahla authored Sep 10, 2024
1 parent 310b16d commit c764822
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jobs:
channel: 1.28-strict/stable
charmcraft-channel: latest/edge
juju-channel: 3.4/stable
self-hosted-runner: true
self-hosted-runner: false
self-hosted-runner-label: "edge"
3 changes: 1 addition & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ jobs:
secrets: inherit
with:
charmcraft-channel: latest/edge
self-hosted-runner: true
self-hosted-runner-label: "edge"
self-hosted-runner: false
4 changes: 3 additions & 1 deletion .trivyignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Pebble CVE
# Pebble CVE - Go project issue
# Calling Decoder.Decode on a message which contains deeply nested
# structures can cause a panic due to stack exhaustion.
CVE-2024-34156

Check notice on line 4 in .trivyignore

View workflow job for this annotation

GitHub Actions / load-tests / Scan Image (ghcr.io-canonical-maubot-376327734c41c9b34914e3d4609eadab7991b9bc-_0.5.0_amd64.tar)

CVE-2024-34156 not present anymore, can be safely removed.
20 changes: 13 additions & 7 deletions maubot_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
name: maubot
summary: Maubot rock
description: Maubot OCI image for the Maubot charm
version: "1.0"
version: "0.5.0"
license: Apache-2.0

base: ubuntu@22.04
build-base: ubuntu@22.04
base: ubuntu@24.04
build-base: ubuntu@24.04
platforms:
amd64:
amd64:

environment:
PYTHONPATH: /usr/lib/python3.12/site-packages/

parts:
hello:
plugin: nil
maubot:
plugin: python
source: .
stage-packages:
- hello
- python3-venv
python-packages:
- maubot==0.5.0
16 changes: 8 additions & 8 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ def __init__(self, *args: typing.Any):
self.framework.observe(self.on.maubot_pebble_ready, self._on_maubot_pebble_ready)
self.framework.observe(self.on.config_changed, self._on_config_changed)

def _on_maubot_pebble_ready(self, event: ops.PebbleReadyEvent) -> None:
"""Handle maubot pebble ready event.
Args:
event: event triggering the handler.
"""
container = event.workload
def _on_maubot_pebble_ready(self, _: ops.PebbleReadyEvent) -> None:
"""Handle maubot pebble ready event."""
container = self.unit.get_container(MAUBOT_CONTAINER_NAME)
if not container.can_connect():
return
container.add_layer(MAUBOT_CONTAINER_NAME, self._pebble_layer, combine=True)
container.replan()
self.unit.status = ops.ActiveStatus()
Expand All @@ -47,6 +45,8 @@ def _on_config_changed(self, _: ops.ConfigChangedEvent) -> None:
"""Handle changed configuration."""
self.unit.status = ops.MaintenanceStatus()
container = self.unit.get_container(MAUBOT_CONTAINER_NAME)
if not container.can_connect():
return
container.add_layer(MAUBOT_SERVICE_NAME, self._pebble_layer, combine=True)
container.replan()
self.unit.status = ops.ActiveStatus()
Expand All @@ -61,7 +61,7 @@ def _pebble_layer(self) -> pebble.LayerDict:
MAUBOT_SERVICE_NAME: {
"override": "replace",
"summary": "maubot",
"command": 'bash -c "hello -t; sleep 10"',
"command": "bash -c \"python3 -c 'import maubot'; sleep 10\"",
"startup": "enabled",
}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_maubot_pebble_ready(self):
"maubot": {
"override": "replace",
"summary": "maubot",
"command": 'bash -c "hello -t; sleep 10"',
"command": "bash -c \"python3 -c 'import maubot'; sleep 10\"",
"startup": "enabled",
}
},
Expand Down

0 comments on commit c764822

Please sign in to comment.