Skip to content

Refactor the nested lookup for component descriptors #1782

@Skarlso

Description

@Skarlso

Context

When having a component in different repositories and trying to do an ocm get cv call to them, the nested lookup logic is a bit inconvenient.

It will output errors even though the component is found after proper resolvers are configured.

This is this codepath here (

out.Errf(octx, "Warning: lookup nested component version %q:%s [%s]: %s\n", ref.ComponentName, vers, hist, err)
):

		nested, err := o.Repository.LookupComponentVersion(ref.ComponentName, vers)
		if err != nil {
			out.Errf(octx, "Warning: lookup nested component version %q:%s [%s]: %s\n", ref.ComponentName, vers, hist, err)
		}
		if nested == nil && lookup != nil {
			nested, err = lookup.LookupComponentVersion(ref.ComponentName, vers)
			if err != nil {
				if !errors.IsErrNotFound(err) {
					out.Errf(octx, "Warning: fallback lookup nested component version \"%s:%s\" [%s]: %s\n", ref.ComponentName, vers, hist, err)
				} else {
					err = nil
				}
			}
		}
		if err != nil {
			continue
		}

This is cumbersome and needs a bit of love to properly inform the user about what's going on.

Version

To Reproduce

Create two component versions in different repositories, parent and child. The parent should reference the child as a componentReference. Then configure your resolver like this so the child can be found in the repository you configured for the child:

type: generic.config.ocm.software/v1
configurations:
  - type: ocm.config.ocm.software
    resolvers:
      - repository:
          type: OCIRepository/v1
          baseUrl: ghcr.io/repo2
          subPath: subpath
        prefix: github.com/open-component-model/child1

Then try to get the parent component with --recursive. The "Warning" should be displayed but the components should be found correctly.

Actual behavior

Expected behavior

Additional Comments

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    🛠️ Needs Refinement

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions