Skip to content

Commit

Permalink
teach boa to use wb config
Browse files Browse the repository at this point in the history
  • Loading branch information
felliott committed Jan 3, 2025
1 parent 9b5b240 commit 50e88c5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions addon_imps/computing/boa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
18 changes: 13 additions & 5 deletions addon_service/common/waterbutler_compat.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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:
Expand All @@ -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)

Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions addon_toolkit/interfaces/computing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class ComputingAddonImp(AddonImp):

config: ComputingConfig

async def build_wb_config(self) -> dict:
return {}


@dataclasses.dataclass
class ComputingAddonHttpRequestorImp(ComputingAddonImp):
Expand Down

0 comments on commit 50e88c5

Please sign in to comment.