Skip to content

Commit 7450582

Browse files
committed
chore: improve charm storage
Signed-off-by: Dario Faccin <[email protected]>
1 parent 987b265 commit 7450582

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

charms/jupyter-ui/metadata.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ charm-user: non-root
8888
storage:
8989
config:
9090
type: filesystem
91-
location: /etc/config
9291
minimum-size: 1M
9392
logos:
9493
type: filesystem
95-
location: /src/apps/default/static/assets/logos/
9694
minimum-size: 1M

charms/jupyter-ui/src/charm.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
TOLERATIONS_OPTIONS_CONFIG_DEFAULT = f"{TOLERATIONS_OPTIONS_CONFIG}-default"
7171
DEFAULT_PODDEFAULTS_CONFIG = "default-poddefaults"
7272
JWA_CONFIG_FILE = "src/templates/spawner_ui_config.yaml.j2"
73+
JWA_CONFIG_FILE_DST = "spawner_ui_config.yaml"
7374

7475
IMAGE_CONFIGS = [
7576
JUPYTER_IMAGES_CONFIG,
@@ -121,6 +122,9 @@ def __init__(self, *args):
121122
)
122123
self._container_name = "jupyter-ui"
123124
self._container = self.unit.get_container(self._name)
125+
self._config_storage_name = "config"
126+
self._logos_storage_name = "logos"
127+
self._container_meta = self.meta.containers[self._container_name]
124128

125129
# setup context to be used for updating K8S resources
126130
self._context = {
@@ -302,10 +306,11 @@ def _upload_logos_files_to_container(self):
302306
splits it into files as expected by the workload,
303307
and pushes the files to the container.
304308
"""
309+
logos_storage_path = Path(self._container_meta.mounts[self._logos_storage_name].location)
305310
for file_name, file_content in yaml.safe_load(
306311
Path("src/logos-configmap.yaml").read_text()
307312
)["data"].items():
308-
logo_file = "/src/apps/default/static/assets/logos/" + file_name
313+
logo_file = logos_storage_path / file_name
309314
self.container.push(
310315
logo_file,
311316
file_content,
@@ -474,8 +479,9 @@ def _render_jwa_spawner_inputs(
474479

475480
def _upload_jwa_file_to_container(self, file_content):
476481
"""Pushes the JWA spawner config file to the workload container."""
482+
config_storage_path = Path(self._container_meta.mounts[self._config_storage_name].location)
477483
self.container.push(
478-
"/etc/config/spawner_ui_config.yaml",
484+
config_storage_path / JWA_CONFIG_FILE_DST,
479485
file_content,
480486
make_dirs=True,
481487
)

0 commit comments

Comments
 (0)