|
18 | 18 | Container Repository object to exist in Pyxis. This will typically be created as part |
19 | 19 | of product onboarding to RHTAP. |
20 | 20 |
|
| 21 | +Flatpak images use different Quay namespaces and a different Pyxis registry: they are |
| 22 | +pushed to quay.io/rh-flatpaks-prod/* or quay.io/rh-flatpaks-stage/*. For these, the |
| 23 | +registry value in Pyxis is set to flatpaks.registry.redhat.io (for both prod and stage). |
| 24 | +
|
21 | 25 | For stage, if you want to be able to pull an image from registry.stage.redhat.io, |
22 | 26 | the image is pushed to quay.io/redhat-pending, the Container Image is created |
23 | 27 | in stage Pyxis, but the registry value in Pyxis is still set to registry.access.redhat.com. |
@@ -125,12 +129,14 @@ def setup_argparser() -> Any: # pragma: no cover |
125 | 129 | ) |
126 | 130 | parser.add_argument( |
127 | 131 | "--rh-push", |
128 | | - help="If set to true, a second item will be created in ContainerImage.repositories " |
129 | | - "with the registry and repository entries converted to use Red Hat's official " |
130 | | - "registry. E.g. a mapped repository of " |
131 | | - "quay.io/redhat-pending/product---my-image will be converted to use " |
132 | | - "registry registry.access.redhat.com and repository product/my-image. Also, " |
133 | | - "the image will be marked as published.", |
| 132 | + help="If set to true, the item created in ContainerImage.repositories " |
| 133 | + "will have the registry and repository entries converted to use Red Hat's official " |
| 134 | + "registry. For standard images (quay.io/redhat-prod/*, quay.io/redhat-pending/*) " |
| 135 | + "registry is registry.access.redhat.com; for flatpaks (quay.io/rh-flatpaks-prod/*, " |
| 136 | + "quay.io/rh-flatpaks-stage/*) registry is flatpaks.registry.redhat.io. " |
| 137 | + "E.g. quay.io/redhat-pending/product----my-image becomes registry " |
| 138 | + "registry.access.redhat.com and repository product/my-image. The image will be " |
| 139 | + "marked as published.", |
134 | 140 | default="false", |
135 | 141 | ) |
136 | 142 | parser.add_argument( |
@@ -340,28 +346,46 @@ def update_container_image_repositories( |
340 | 346 | raise Exception("Image metadata was not successfully added to Pyxis.") |
341 | 347 |
|
342 | 348 |
|
| 349 | +def _rh_push_registry(image_name: str) -> str: |
| 350 | + """Return the Pyxis registry string for rh_push when --rh-push is true. |
| 351 | +
|
| 352 | + For flatpak images (quay.io/rh-flatpaks-prod/* or quay.io/rh-flatpaks-stage/*) |
| 353 | + returns flatpaks.registry.redhat.io. For other Red Hat images |
| 354 | + (e.g. quay.io/redhat-prod/*, quay.io/redhat-pending/*) returns |
| 355 | + registry.access.redhat.com. |
| 356 | + """ |
| 357 | + parts = image_name.split("/") |
| 358 | + if len(parts) >= 2 and parts[1] in ("rh-flatpaks-prod", "rh-flatpaks-stage"): |
| 359 | + return "flatpaks.registry.redhat.io" |
| 360 | + return "registry.access.redhat.com" |
| 361 | + |
| 362 | + |
343 | 363 | def construct_repository(args, tags): |
| 364 | + """Build the repository dict for the Container Image. |
| 365 | +
|
| 366 | + When rh_push is true, the repository entry it adds will be for Red Hat |
| 367 | + registries: registry is either registry.access.redhat.com (for standard |
| 368 | + images like quay.io/redhat-prod/*, quay.io/redhat-pending/*) or |
| 369 | + flatpaks.registry.redhat.io (for flatpak images quay.io/rh-flatpaks-prod/*, |
| 370 | + quay.io/rh-flatpaks-stage/*). The repository path is derived via proxymap |
| 371 | + (e.g. product----image -> product/image). |
| 372 | + """ |
344 | 373 | image_name = args.name |
345 | | - image_registry = image_name.split("/")[0] |
346 | | - image_repo = image_name.split("/", 1)[1] |
347 | | - |
348 | 374 | date_now = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f+00:00") |
349 | 375 |
|
350 | | - # For images released to registry.redhat.io we need a special repository item |
351 | | - # with published=true and registry and repository converted. |
352 | | - # E.g. if the name in the oras manifest result is |
353 | | - # "quay.io/redhat-prod/rhtas-tech-preview----cosign-rhel9", |
354 | | - # repository will be "rhtas-tech-preview/cosign-rhel9" |
355 | 376 | if args.rh_push == "true": |
356 | | - LOGGER.info("--rh-push is true. Associating registry.access.redhat.com repository.") |
| 377 | + registry = _rh_push_registry(image_name) |
| 378 | + LOGGER.info("--rh-push is true. Associating %s repository.", registry) |
357 | 379 | repo = { |
358 | 380 | "published": True, |
359 | | - "registry": "registry.access.redhat.com", |
| 381 | + "registry": registry, |
360 | 382 | "repository": proxymap(image_name), |
361 | 383 | "push_date": date_now, |
362 | 384 | "tags": pyxis_tags(tags, date_now), |
363 | 385 | } |
364 | 386 | else: |
| 387 | + image_registry = image_name.split("/")[0] |
| 388 | + image_repo = image_name.split("/", 1)[1] |
365 | 389 | repo = { |
366 | 390 | "published": False, |
367 | 391 | "registry": image_registry, |
|
0 commit comments