cnabio / cnab-to-oci

Tool to convert CNAB bundle.json to OCI index
Apache License 2.0
54 stars 41 forks source link

Copy a bundle with a relocation map to another registry #108

Closed carolynvs closed 3 years ago

carolynvs commented 3 years ago

Here's the scenario that a Porter user is encountering:

  1. Push a bundle to a public registry, example/mybun:v1.0.0
  2. Copy the bundle to local registry, localhost:5000/mybun:v1.0.0. The copy now has a relocation map that maps example/mybun-invocation-image:v1.0.0 => localhost:5000/mybun-invocation-image:v1.0.0.
  3. Disconnect your internet connection.
  4. Copy the bundle from localhost:5000/mybun:v1.0.0 to localhost:5000/newbun:v1.0.0.

The copy fails because it tries to copy the invocation image from its original location defined in the bundle, instead of copying the relocated invocation image.

I'm not sure if there is a way to make this work right now? It seems like FixupBundle should take a relocation map for the bundle, and take any relocations into account before pulling and copying images?

carolynvs commented 3 years ago

Oh I just found WithRelocationMap! I think that will do what I need.

carolynvs commented 3 years ago

I think that there is a bug in the implementation that causes the relocation map to be ignored. I have a fix locally that I'll submit in a bit as soon as I figure out how to test the fix.