From 50e88c5aa61a45187f10fe1d9bb79c419ca0be46 Mon Sep 17 00:00:00 2001 From: Fitz Elliott Date: Fri, 3 Jan 2025 16:05:40 -0500 Subject: [PATCH] teach boa to use wb config --- addon_imps/computing/boa.py | 5 +++++ addon_service/common/waterbutler_compat.py | 18 +++++++++++++----- addon_toolkit/interfaces/computing.py | 3 +++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/addon_imps/computing/boa.py b/addon_imps/computing/boa.py index 4d7a76ab..d9a4a35c 100644 --- a/addon_imps/computing/boa.py +++ b/addon_imps/computing/boa.py @@ -32,3 +32,8 @@ def create_client(credentials): boa_client = BoaClient(endpoint=BOA_API_ENDPOINT) boa_client.login(credentials.username, credentials.password) return boa_client + + async def build_wb_config(self) -> dict: + return { + "host": BOA_API_ENDPOINT, + } diff --git a/addon_service/common/waterbutler_compat.py b/addon_service/common/waterbutler_compat.py index aca6db78..f194a67b 100644 --- a/addon_service/common/waterbutler_compat.py +++ b/addon_service/common/waterbutler_compat.py @@ -1,8 +1,8 @@ from asgiref.sync import async_to_sync from rest_framework_json_api import serializers -from addon_service.addon_imp.instantiation import get_storage_addon_instance__blocking -from addon_service.configured_addon.storage.models import ConfiguredStorageAddon +from addon_service.addon_imp.instantiation import get_addon_instance__blocking +from addon_service.configured_addon.models import ConfiguredAddon from addon_toolkit import ( credentials, json_arguments, @@ -14,6 +14,11 @@ class WaterButlerConfigSerializer(serializers.Serializer): The returned data should share a shape with the existing `serialize_waterbutler_credentials` and `serialize_waterbutler_settings` functions used by the OSF-based Addons. + + NB: The Boa addon needs credentials from GV, and this seems like a good short-term + place to hang it. Boa doesn't actually connect with WB, so this will probably be + refactored in the future. But for now, any configured_storage_addon could actually + be a configured_computed_addon. """ class JSONAPIMeta: @@ -27,6 +32,7 @@ def __init__(self, *args, **kwargs): self._wb_config = None def _credentials_for_waterbutler(self, configured_storage_addon): + """NB: see class docstring about configured_storage_addon""" _creds_data = configured_storage_addon.credentials wb_config = self._config_for_waterbutler(configured_storage_addon) @@ -48,14 +54,16 @@ def _credentials_for_waterbutler(self, configured_storage_addon): case _: raise ValueError(f"unknown credentials type: {_creds_data}") - def _config_for_waterbutler(self, configured_storage_addon: ConfiguredStorageAddon): + def _config_for_waterbutler(self, configured_storage_addon: ConfiguredAddon): + """NB: see class docstring about configured_storage_addon""" if not self._wb_config: self._wb_config = self._fetch_wb_config(configured_storage_addon) return self._wb_config @staticmethod - def _fetch_wb_config(configured_storage_addon: ConfiguredStorageAddon): - imp = get_storage_addon_instance__blocking( + def _fetch_wb_config(configured_storage_addon: ConfiguredAddon): + """NB: see class docstring about configured_storage_addon""" + imp = get_addon_instance__blocking( configured_storage_addon.imp_cls, configured_storage_addon.base_account, configured_storage_addon.config, diff --git a/addon_toolkit/interfaces/computing.py b/addon_toolkit/interfaces/computing.py index 1bd91f90..4a1d218d 100644 --- a/addon_toolkit/interfaces/computing.py +++ b/addon_toolkit/interfaces/computing.py @@ -44,6 +44,9 @@ class ComputingAddonImp(AddonImp): config: ComputingConfig + async def build_wb_config(self) -> dict: + return {} + @dataclasses.dataclass class ComputingAddonHttpRequestorImp(ComputingAddonImp):