porter icon indicating copy to clipboard operation
porter copied to clipboard

Relocate dependent bundles during publish from archive

Open carolynvs opened this issue 1 year ago • 0 comments

During porter publish --from-archive, normally the cnab-to-oci library handles relocating referenced images used by a bundle and updating the relocation mapping files. That library does not understand dependencies however. During publish, either in Porter or a fork of cnab-to-oci, we need to push dependencies when they don't exist, and ensure that the relocation mapping file is updated with their new location.

For example:

# porter.yaml
dependencies:
  requires:
    - name: mysql
      bundle:
        reference: example.com/mysql:v1.2.3

When the bundle is published to --registry=localhost:5000, the referenced mysql bundle should be copied to localhost:5000/mysql:v1.2.3 (following porter's existing relocation naming conventions).

The dependency in the final porter.yaml should be rewritten to use the repository digest of the bundle (just like we do with invocation images):

# porter.yaml
dependencies:
  requires:
    - name: mysql
      bundle:
        reference: example.com/mysql@sha256:REPOSTIORY_DIGEST

Then an entry should be added to relocation-mapping.json

{
  "example.com/mysql@sha256:abc123": "localhost:5000/mysql@sha256:RELOCATED_DIGEST"
}

Notes

  • We do not want to relocate dependent bundles during a normal publish, only when we are publishing from an archive, because dependent bundles should be reused and not making copies of its dependencies everywhere. We do want to copy when publishing across an airgap though, since the original dependency bundle will be unreachable.
  • Bundles should be published in reverse dependency order, so that we don't ever push a bundle before its dependencies

Dependencies

  • #2690

ℹ️ Read PEP003 - Advanced Dependencies for context about how dependencies should work, design details, and notes about desired behavior.

carolynvs avatar Mar 30 '23 17:03 carolynvs