Skip to content

Support of locally embedded OCI layouts #35

Description

@lukasgr90

What happened:

ocm-kit failed to use the native access reference (as described here: https://ocm.software/docs/tutorials/working-with-oci/) for OCI images, which were embedded into the CV over an input-referenced, local OCI image layout. Instead it passed empty values as Host, Repository, Tag and Digest into the value render process.

What you expected to happen:

ocm-kit should be able to use the native access reference, where a local OCI image is referenced by the component name and the image's digest.

How to reproduce it (as minimally and precisely as possible):

First I save an OCI image as local OCI layout:

🐸💻 skopeo copy docker://ghcr.io/traefik/traefik:3.6.25 oci:./traefik:3.6.25 --insecure-policy
Getting image source signatures
Copying blob 55afa1ecc21d done   | 
Copying blob 43865a9fef03 done   | 
Copying blob 58e302bf3a34 done   | 
Copying blob de5cbc806753 done   | 
Copying config ee0b3aaa56 done   | 
Writing manifest to image destination

Then I use following simple values mapping values.yaml.tpl:

image:
    {{- $traefikImage := index .OCIResources "traefik-image" }}
    registry: {{ $traefikImage.Host }}
    repository: {{ $traefikImage.Repository }}
    tag: {{ $traefikImage.Tag }}@{{ $traefikImage.Digest }}

and following component constructor component-constructor-embedded.yaml:

name: example.org/traefik
version: 3.6.25
provider:
  name: Team
resources:
  - name: helm-chart
    type: helmChart
    version: 39.0.7
    relation: external
    access:
      type: OCIImage/v1
      imageReference: "ghcr.io/traefik/helm/traefik:39.0.7"
  - name: traefik-image
    type: ociArtifact
    version: 3.6.25
    input:
      type: dir/v1
      path: ./traefik
      mediaType: application/vnd.ocm.software.oci.layout.v1+tar
  - name: helm-values-template
    type: yaml
    labels:
      - name: "ext.ocm.software/helm.values-for"
        value: helm-chart
    relation: local
    input:
      type: File/v1
      path: values.yaml.tpl
      mediaType: application/x-yaml

Now I add the example component version my local OCI registry (listening on localhost:5000):

🐸💻 ~/bin/ocmv2 add cv --repository ctf::./test.ctf -c component-constructor-embedded.yaml
 COMPONENT           │ VERSION │ PROVIDER 
─────────────────────┼─────────┼──────────
 example.org/traefik │ 3.6.25  │ Team
🐸💻  ~/bin/ocmv2 transfer cv -r --copy-resources ctf::./test.ctf//example.org/traefik oci::http://localhost:5000/test
✓ Resolving component versions...
[...]
✓ Transferring component versions...
    ✓ transformExampleOrgTraefik3625AddtransformHelmValuesTemplate3625 [OCIAddLocalResource]
    ✓ transformExampleOrgTraefik3625AddtransformHelmChart3907 [OCIAddLocalResource]
    ✓ fileBufferCleanup [FileCleanup]
    ✓ transformExampleOrgTraefik3625Upload [OCIAddComponentVersion]
  [████████████████████████████████████████] 100% 8/8

I can fetch the image as described here: https://ocm.software/docs/tutorials/working-with-oci/

🐸💻 ~/bin/ocmv2 get cv http://localhost:5000/test//example.org/traefik:3.6.25 -oyaml | yq '.[].component.resources[] | select(.name=="traefik-image")'
access:
  localReference: sha256:996b026a32b1bb6c85c200e5cf25276c1caa84ddea6b1e3a33e78cdc5cbe8d0c
  mediaType: application/vnd.oci.image.manifest.v1+json
  type: LocalBlob/v1
digest:
  hashAlgorithm: SHA-256
  normalisationAlgorithm: genericBlobDigest/v1
  value: 996b026a32b1bb6c85c200e5cf25276c1caa84ddea6b1e3a33e78cdc5cbe8d0c
name: traefik-image
relation: local
type: ociArtifact
version: 3.6.25
🐸💻 oras pull --insecure localhost:5000/test/component-descriptors/example.org/traefik:3.6.25@sha256:996b026a32b1bb6c85c200e5cf25276c1caa84ddea6b1e3a33e78cdc5cbe8d0c
✓ Skipped     application/vnd.oci.image.layer.v1.tar+gzip                       3.67/3.67 MB 100.00%     0s
  └─ sha256:55afa1ecc21d2bb5e5045f32dafee56272ffd89860bac26f6c32123439af26a4                               
✓ Skipped     application/vnd.oci.image.layer.v1.tar+gzip                         399/399 KB 100.00%     0s
  └─ sha256:43865a9fef033d9d6f86da75b64ef9882d7d8092199d1d7e2f9aba44ce73384b                               
✓ Skipped     application/vnd.oci.image.layer.v1.tar+gzip                       48.2/48.2 MB 100.00%     0s
  └─ sha256:58e302bf3a345f32300c9f0eda2f70052a187dc0c0ef624fd3cf83cdf2a079b0                               
✓ Skipped     application/vnd.oci.image.layer.v1.tar+gzip                         369/369  B 100.00%     0s
  └─ sha256:de5cbc80675333dc60401fb660b745051dc25e67ae5c407179ae582b54b71aec                               
✓ Skipped     application/vnd.oci.image.config.v1+json                          3.15/3.15 KB 100.00%     0s
  └─ sha256:ee0b3aaa56c3f593da2c7d67ebbdbc600155bf6be2c3cece8f7870db29714a88                               
✓ Pulled      application/vnd.oci.image.manifest.v1+json                        1.69/1.69 KB 100.00%   67µs
  └─ sha256:996b026a32b1bb6c85c200e5cf25276c1caa84ddea6b1e3a33e78cdc5cbe8d0c                               
Skipped pulling layers without file name in "org.opencontainers.image.title"
Use 'oras copy localhost:5000/test/component-descriptors/example.org/traefik:3.6.25@sha256:996b026a32b1bb6c85c200e5cf25276c1caa84ddea6b1e3a33e78cdc5cbe8d0c --to-oci-layout <layout-dir>' to pull all layers.

But ocm-kit is not able to resolve the image reference:

🐸💻 ~/Development/community/ocm-kit/ocm-kit http://localhost:5000/test//example.org/traefik:3.6.25
image:
    registry: 
    repository: 
    tag: @

Anything else we need to know:

I think it is related to #34, but still a little bit different issue.

Environment:

  • Nixos 26.05
  • ocm-kit build based on commit "3b866d48da741488e4307d66de120e90bc11b503"
  • ocm(v2) CLI based on commit "eb3e97667b61e5193f998514465486579cba9d97"
  • Empty OCM configuration
  • Zot v2.1.15 as OCI registry
  • oras version 1.3.0
  • skopeo version 1.22.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions