d59bea3569
If a namespace is present in the whitelist, all calls are sent to the OCI model instead of the Pre OCI model Note that this does increase overhead for registry calls (since we need to lookup the namespace for every single call), but it should only be temporary until we've migrated all users over to the OCI data model
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
import os
|
|
import logging
|
|
|
|
from data.registry_model.registry_pre_oci_model import pre_oci_model
|
|
from data.registry_model.registry_oci_model import oci_model
|
|
from data.registry_model.modelsplitter import SplitModel
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class RegistryModelProxy(object):
|
|
def __init__(self):
|
|
self._model = oci_model if os.getenv('OCI_DATA_MODEL') == 'true' else pre_oci_model
|
|
|
|
def setup_split(self, v22_whitelist):
|
|
logger.info('===============================')
|
|
logger.info('Enabling split registry model with namespace whitelist `%s`', v22_whitelist)
|
|
logger.info('===============================')
|
|
self._model = SplitModel(v22_whitelist)
|
|
|
|
def set_for_testing(self, use_oci_model):
|
|
self._model = oci_model if use_oci_model else pre_oci_model
|
|
logger.debug('Changed registry model to `%s` for testing', self._model)
|
|
|
|
def __getattr__(self, attr):
|
|
return getattr(self._model, attr)
|
|
|
|
registry_model = RegistryModelProxy()
|
|
logger.info('===============================')
|
|
logger.info('Using registry model `%s`', registry_model._model)
|
|
logger.info('===============================')
|