Skip to content

Transfer with resolvers #905

@matthiasbruns

Description

@matthiasbruns

Description

While testing transfer für the transformation tutorial
#864
I added a section about transfer.

It turns out that we are not taking resolvers into account when calling transfer.

app-constructor.yaml

components:
  - name: ocm.software/tutorials/app
    version: "1.0.1"
    provider:
      name: ocm.software
    componentReferences:
      - name: backend-service
        componentName: ocm.software/tutorials/backend
        version: "1.0.1"
      - name: frontend-service
        componentName: ocm.software/tutorials/frontend
        version: "1.0.1"
    resources:
      - name: config
        version: "1.0.1"
        type: plainText
        input:
          type: utf8
          text: "app deployment configuration"

backend-constructor.yaml

components:
  - name: ocm.software/tutorials/backend
    version: "1.0.1"
    provider:
      name: ocm.software
    resources:
      - name: config
        version: "1.0.1"
        type: plainText
        input:
          type: utf8
          text: "backend service configuration"

frontend-constructor.yaml

components:
  - name: ocm.software/tutorials/frontend
    version: "1.0.1"
    provider:
      name: ocm.software
    resources:
      - name: config
        version: "1.0.1"
        type: plainText
        input:
          type: utf8
          text: "frontend service configuration"

.ocmconfig

type: generic.config.ocm.software/v1
configurations:
  - type: credentials.config.ocm.software
    repositories:
      - repository:
          type: DockerConfig/v1
          dockerConfigFile: "~/.docker/config.json"
  - type: resolvers.config.ocm.software/v1alpha1
    resolvers:
      - repository:
          type: OCIRepository/v1
          baseUrl: ghcr.io
          subPath: matthiasbruns/ocm-tutorial-frontend
        componentNamePattern: "ocm.software/tutorials/frontend"
      - repository:
          type: OCIRepository/v1
          baseUrl: ghcr.io
          subPath: matthiasbruns/ocm-tutorial-backend
        componentNamePattern: "ocm.software/tutorials/backend"

The script:

#!/bin/bash

set -x

echo $GITHUB_TOKEN | docker login ghcr.io -u ${GITHUB_USERNAME} --password-stdin

./ocm add cv --repository ghcr.io/matthiasbruns/ocm-tutorial-backend \
  --constructor backend-constructor.yaml \
  --component-version-conflict-policy replace \
  --config .ocmconfig-no-resolvers

./ocm add cv --repository ghcr.io/matthiasbruns/ocm-tutorial-frontend \
  --constructor frontend-constructor.yaml \
  --component-version-conflict-policy replace \
  --config .ocmconfig-no-resolvers

 ./ocm add cv --repository ghcr.io/matthiasbruns/ocm-tutorial-multirepo \
   --constructor app-constructor.yaml \
   --component-version-conflict-policy replace \
   --config .ocmconfig

 # Verify all three exist
 ./ocm get cv ghcr.io/matthiasbruns/ocm-tutorial-backend//ocm.software/tutorials/backend:1.0.1 \
   --config .ocmconfig
 ./ocm get cv ghcr.io/matthiasbruns/ocm-tutorial-frontend//ocm.software/tutorials/frontend:1.0.1 \
   --config .ocmconfig

 ./ocm get cv ghcr.io/matthiasbruns/ocm-tutorial-multirepo//ocm.software/tutorials/app:1.0.1 \
   --config .ocmconfig --recursive=-1


# now transfer to another repo
./ocm transfer cv ghcr.io/matthiasbruns/ocm-tutorial-multirepo//ocm.software/tutorials/app:1.0.1 \
  ghcr.io/matthiasbruns/ocm-tutorial-tranfer --recursive \
  --config .ocmconfig

The transfer call fails with:

 ./ocm transfer cv ghcr.io/matthiasbruns/ocm-tutorial-multirepo//ocm.software/tutorials/app:1.0.1 ghcr.io/matthiasbruns/ocm-tutorial-tranfer --recursive --config .ocmconfig

Transferring component versions...
  ✗ transformOcmSoftwareTutorialsBackend101Gettransform101Config [OCIGetLocalResource]
  ⊘ transformOcmSoftwareTutorialsApp101GettransformConfig101 [OCIGetLocalResource]
  ⊘ transformOcmSoftwareTutorialsFrontend101GettransformConfig101 [OCIGetLocalResource]

  [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0% 0/9 (1 failed) (2 cancelled)

Errors:
  ✗ transformOcmSoftwareTutorialsBackend101Gettransform101Config
    ↳ failed to transform transformation "transformOcmSoftwareTutorialsBackend101Gettransform101Config"
      ↳ failed getting local resource name=config,version=1.0.1 from component ocm.software/tutorials/backend:1.0.1
        ↳ component version not found
          component version ocm.software/tutorials/backend/1.0.1 not found
          ↳ failed to get component version
            ↳ failed to get manifest
              ↳ failed to resolve reference "ghcr.io/matthiasbruns/ocm-tutorial-multirepo/component-descriptors/ocm.software/tutorials/backend:1.0.1"
                ↳ ghcr.io/matthiasbruns/ocm-tutorial-multirepo/component-descriptors/ocm.software/tutorials/backend:1.0.1
                  ↳ not found

    ▶ Transformation "transformOcmSoftwareTutorialsBackend101Gettransform101Config" of type OCIGetLocalResource/v1alpha1 failed. 
      Spec data shown below for debugging.
    ┌────────────────────────────────────────────────────────┐
    │ {                                                      │
    │   "component": "ocm.software/tutorials/backend",       │
    │   "repository": {                                      │
    │     "baseUrl": "ghcr.io",                              │
    │     "subPath": "matthiasbruns/ocm-tutorial-multirepo", │
    │     "type": "OCIRepository/v1"                         │
    │   },                                                   │
    │   "resourceIdentity": {                                │
    │     "name": "config",                                  │
    │     "version": "1.0.1"                                 │
    │   },                                                   │
    │   "version": "1.0.1"                                   │
    │ }                                                      │
    └────────────────────────────────────────────────────────┘

Error: graph execution failed

Full log:

/bin/bash /Users/mbruns/dev/sap/open-component-model/tmp/resolver-tutorial/transfer-resolvers.sh
+ echo ghp_XXXXXXXXXXXX
+ docker login ghcr.io -u matthiasbruns --password-stdin
Login Succeeded
+ ./ocm add cv --repository ghcr.io/matthiasbruns/ocm-tutorial-backend --constructor backend-constructor.yaml --component-version-conflict-policy replace --config .ocmconfig
time=2026-02-23T09:10:07.717+01:00 level=WARN msg="REPLACING component version in target repository, old component version will no longer be available if it was present before." realm=constructor component=ocm.software/tutorials/backend version=1.0.1
 COMPONENT                      │ VERSION │ PROVIDER     
────────────────────────────────┼─────────┼──────────────
 ocm.software/tutorials/backend │ 1.0.1   │ ocm.software 
+ ./ocm add cv --repository ghcr.io/matthiasbruns/ocm-tutorial-frontend --constructor frontend-constructor.yaml --component-version-conflict-policy replace --config .ocmconfig
time=2026-02-23T09:10:11.395+01:00 level=WARN msg="REPLACING component version in target repository, old component version will no longer be available if it was present before." realm=constructor component=ocm.software/tutorials/frontend version=1.0.1
 COMPONENT                       │ VERSION │ PROVIDER     
─────────────────────────────────┼─────────┼──────────────
 ocm.software/tutorials/frontend │ 1.0.1   │ ocm.software 
+ ./ocm add cv --repository ghcr.io/matthiasbruns/ocm-tutorial-multirepo --constructor app-constructor.yaml --component-version-conflict-policy replace --config .ocmconfig
time=2026-02-23T09:10:15.819+01:00 level=WARN msg="REPLACING component version in target repository, old component version will no longer be available if it was present before." realm=constructor component=ocm.software/tutorials/app version=1.0.1
 COMPONENT                       │ VERSION │ PROVIDER     
─────────────────────────────────┼─────────┼──────────────
 ocm.software/tutorials/app      │ 1.0.1   │ ocm.software 
 ocm.software/tutorials/backend  │ 1.0.1   │              
 ocm.software/tutorials/frontend │ 1.0.1   │              
+ ./ocm get cv ghcr.io/matthiasbruns/ocm-tutorial-backend//ocm.software/tutorials/backend:1.0.1 --config .ocmconfig
 COMPONENT                      │ VERSION │ PROVIDER     
────────────────────────────────┼─────────┼──────────────
 ocm.software/tutorials/backend │ 1.0.1   │ ocm.software 
+ ./ocm get cv ghcr.io/matthiasbruns/ocm-tutorial-frontend//ocm.software/tutorials/frontend:1.0.1 --config .ocmconfig
 COMPONENT                       │ VERSION │ PROVIDER     
─────────────────────────────────┼─────────┼──────────────
 ocm.software/tutorials/frontend │ 1.0.1   │ ocm.software 
+ ./ocm transfer cv ghcr.io/matthiasbruns/ocm-tutorial-multirepo//ocm.software/tutorials/app:1.0.1 ghcr.io/matthiasbruns/ocm-tutorial-tranfer --recursive --config .ocmconfig

Transferring component versions...
  ✗ transformOcmSoftwareTutorialsBackend101Gettransform101Config [OCIGetLocalResource]
  ⊘ transformOcmSoftwareTutorialsApp101GettransformConfig101 [OCIGetLocalResource]
  ⊘ transformOcmSoftwareTutorialsFrontend101GettransformConfig101 [OCIGetLocalResource]

  [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0% 0/9 (1 failed) (2 cancelled)

Errors:
  ✗ transformOcmSoftwareTutorialsBackend101Gettransform101Config
    ↳ failed to transform transformation "transformOcmSoftwareTutorialsBackend101Gettransform101Config"
      ↳ failed getting local resource name=config,version=1.0.1 from component ocm.software/tutorials/backend:1.0.1
        ↳ component version not found
          component version ocm.software/tutorials/backend/1.0.1 not found
          ↳ failed to get component version
            ↳ failed to get manifest
              ↳ failed to resolve reference "ghcr.io/matthiasbruns/ocm-tutorial-multirepo/component-descriptors/ocm.software/tutorials/backend:1.0.1"
                ↳ ghcr.io/matthiasbruns/ocm-tutorial-multirepo/component-descriptors/ocm.software/tutorials/backend:1.0.1
                  ↳ not found

    ▶ Transformation "transformOcmSoftwareTutorialsBackend101Gettransform101Config" of type OCIGetLocalResource/v1alpha1 failed. 
      Spec data shown below for debugging.
    ┌────────────────────────────────────────────────────────┐
    │ {                                                      │
    │   "component": "ocm.software/tutorials/backend",       │
    │   "repository": {                                      │
    │     "baseUrl": "ghcr.io",                              │
    │     "subPath": "matthiasbruns/ocm-tutorial-multirepo", │
    │     "type": "OCIRepository/v1"                         │
    │   },                                                   │
    │   "resourceIdentity": {                                │
    │     "name": "config",                                  │
    │     "version": "1.0.1"                                 │
    │   },                                                   │
    │   "version": "1.0.1"                                   │
    │ }                                                      │
    └────────────────────────────────────────────────────────┘

Error: graph execution failed

Done Criteria

  • Resolvers should be taken into account in transfer
  • Code has been reviewed by other team members
  • Analysis of existing tests (Unit and Integration)
  • Unit Tests created for new code or existing Unit Tests updated
  • Integration Test Suite updated (includes deletion of existing unnecessary Integration Test and/or creation of new ones if required)
  • Enduser Documentation updated (if applicable)
  • Internal technical Documentation created/updated (if applicable)
  • Successful demonstration in Review

Metadata

Metadata

Assignees

Labels

area/ipceiImportant Project of Common European Interestkind/tasksmall task, normally part of feature or epic

Type

No fields configured for Bug.

Projects

Status
🍺 Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions