Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented fetching settings from GV side #10789

Open
wants to merge 2 commits into
base: feature/gravy_valet_integration
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions osf/external/gravy_valet/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from addons.gitlab.apps import GitLabAddonConfig
from addons.googledrive.apps import GoogleDriveAddonConfig
from addons.s3.apps import S3AddonAppConfig
from addons.s3.settings import ENCRYPT_UPLOADS_DEFAULT
from . import request_helpers as gv_requests


Expand Down Expand Up @@ -95,6 +94,7 @@ class EphemeralNodeSettings:

# retrieved from WB on-demand and cached
_credentials: dict = None
_config: dict = None

@property
def short_name(self):
Expand Down Expand Up @@ -142,20 +142,9 @@ def serialize_waterbutler_credentials(self):
return self._credentials

def serialize_waterbutler_settings(self):
# sufficient for Box
# TODO: Define per-service translation (and/or common schemes)
match self.wb_key:
case _LegacyConfigsForWBKey.s3.name:
return {
'bucket': self.folder_id.split(':/')[0],
'id': self.folder_id,
'encrypt_uploads': ENCRYPT_UPLOADS_DEFAULT,
}

return {
'folder': self.folder_id.split(':')[1],
'service': self.short_name,
}
if self._config is None:
self._fetch_wb_config()
return self._config

def _fetch_wb_config(self):
result = gv_requests.get_waterbutler_config(
Expand All @@ -164,6 +153,7 @@ def _fetch_wb_config(self):
requesting_user=self.active_user
)
self._credentials = result.get_attribute('credentials')
self._config = result.get_attribute('config')

def create_waterbutler_log(self, *args, **kwargs):
pass
Expand Down
Loading