This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/registry_model/__init__.py
Joseph Schorr d59bea3569 Enable a configurable whitelist of namespaces for V22
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
2018-12-03 17:37:28 -05:00

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('===============================')