from werkzeug.routing import BaseConverter import features class QuayBaseConverter(BaseConverter): def __init_subclass__(cls, **kwargs): super().__init_subclass__(**kwargs) if "part_isolating" not in cls.__dict__: cls.part_isolating = "/" not in cls.regex class APIRepositoryPathConverter(QuayBaseConverter): """ Converter for handling repository paths. Does not handle library paths. """ def __init__(self, url_map): super().__init__(url_map) self.weight = 200 self.regex = r"([^/]+(/[^/]+)+)" # TODO(kleesc): Remove after fully deprecating V1 push/pull class V1CreateRepositoryPathConverter(QuayBaseConverter): """ Converter for handling PUT repository path. Handles both library and non-library paths (if configured). This is needed so that v1.create_repository does not match possibly nested path from other routes. For example: PUT /repositories//tags/ when no tag is given should 404, and not fallback to v1.create_repository route. """ def __init__(self, url_map): super().__init__(url_map) self.weight = 200 if features.LIBRARY_SUPPORT: # Allow names without namespaces. self.regex = r"[^/]+(/[^/]+)*(?