johnpoth commented on PR #4350:
URL: https://github.com/apache/camel-k/pull/4350#issuecomment-1547600096

   > > > I think I did some exploration with go-containerregistry in the past, 
but I have not seen an option to define a custom media type or annotations for 
the layers, do you know if that's possible ?
   > > 
   > > 
   > > Yes it does! BUT setting a custom media type comes at the cost of the 
image being rejected in most registries or clients. This is why I didn't set 
the custom media type when working on local dependencies. Although very 
appealing it wasn't worth the interoperability drawbacks IMO. This was ~1 years 
ago so maybe things have changed but looking at the list of supported 
registries it doesn't look like it...
   > 
   > Yeah, that is essentially also the conclusion in #2732, but I had hope for 
things to have become better, but looks like it is not. The alternative would 
be to use some annotations to help distinguish between the type of layers but, 
given the spec from the ORAS Artifacts have been merged to the OpenContainers 
specs I had an hope to get things more widely supported :)
   > 
   > Happy to switch to `go-containerregistry` at some point, @johnpoth do you 
by chance have some code I can take a look ?
   
   Sure! So for building the Image I would just use Spectrum or 
[Crane](https://github.com/google/go-containerregistry/blob/main/cmd/crane/recipes.md)
 tbh.. both are built on top of `go-containerregistry` anyway so:
   
   ```
   spectrum build -b scratch  -t docker.io/jpoth/camel-kamelets 
camel-kamelets/kamelets:/
   ```
   
   or Crane
   
   ```
   crane append  -f <(tar -f - -c camel-kamelets/kamelets/) -t 
docker.io/jpoth/camel-kamelets
   ```
   
   This will create an Image with just the Kamelet files in a single layer
   
   And for the Operator part I would use the equivalent of
   
   ```
   crane pull  jpoth/camel-kamelets kamelets.tar
   ```
   
   which is just a Crane 
[Pull](https://github.com/google/go-containerregistry/blob/a927d7c995a991edeb54e840f66d8cfffcf30d62/cmd/crane/cmd/export.go#L73)
 followed by an 
[Export](https://github.com/google/go-containerregistry/blob/a927d7c995a991edeb54e840f66d8cfffcf30d62/cmd/crane/cmd/export.go#LL79C21-L79C21).
 The 
[mutate.Export](https://github.com/google/go-containerregistry/blob/a927d7c995a991edeb54e840f66d8cfffcf30d62/pkg/v1/mutate/mutate.go#L249)
 is used which returns a _stream_. This allows you to not create a temporary 
file when extracting the Kamelets: for 
[example](https://github.com/google/go-containerregistry/blob/a927d7c995a991edeb54e840f66d8cfffcf30d62/pkg/v1/mutate/mutate_test.go#L57).
   
   **For authentication**, you can reuse the Spectrum auth we already 
[have](https://github.com/apache/camel-k/blob/main/pkg/builder/spectrum.go#LL116C1-L116C1)...
 
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to