Handle containers without a namespace

Satellite server does not include a namespace when exposing containers.
This change fixes our image-serve metadata creation to understand this
concept and build the _catalog we provide correctly. We will only handle
two types of containers path structures with the image-serve.

   * host:port/namespace/container:tag
   * host:port/container:tag

Change-Id: I259a0d5fcbae8f8a6bbeffa5fdb744d3291315ad
Depends-On: https://review.opendev.org/c/openstack/tripleo-ansible/+/775158
Closes-Bug: #1913782
(cherry picked from commit 7e797317a3)
This commit is contained in:
Alex Schultz 2021-01-29 11:34:27 -07:00
parent e5d483b7ed
commit 7d7a983caa
1 changed files with 6 additions and 1 deletions

View File

@ -382,12 +382,17 @@ def build_catalog():
catalog_entries = [] catalog_entries = []
LOG.debug('Rebuilding %s' % catalog_path) LOG.debug('Rebuilding %s' % catalog_path)
images_path = os.path.join(IMAGE_EXPORT_DIR, 'v2') images_path = os.path.join(IMAGE_EXPORT_DIR, 'v2')
metadata_set = set(['blobs', 'manifests', 'tags'])
for namespace in os.listdir(images_path): for namespace in os.listdir(images_path):
namespace_path = os.path.join(images_path, namespace) namespace_path = os.path.join(images_path, namespace)
if not os.path.isdir(namespace_path): if not os.path.isdir(namespace_path):
continue continue
for image in os.listdir(namespace_path): contents_set = set(os.listdir(namespace_path))
# handle containers with no namespaces
if metadata_set.issubset(contents_set):
catalog_entries.append(namespace)
for image in list(contents_set - metadata_set):
catalog_entries.append('%s/%s' % (namespace, image)) catalog_entries.append('%s/%s' % (namespace, image))
catalog = {'repositories': catalog_entries} catalog = {'repositories': catalog_entries}