Skip to content

fix: Normalize scheme handling and update identity type to OCIRegistry#1964

Merged
jakobmoellerdev merged 2 commits into
open-component-model:mainfrom
jakobmoellerdev:fixup-identity
Mar 13, 2026
Merged

fix: Normalize scheme handling and update identity type to OCIRegistry#1964
jakobmoellerdev merged 2 commits into
open-component-model:mainfrom
jakobmoellerdev:fixup-identity

Conversation

@jakobmoellerdev

@jakobmoellerdev jakobmoellerdev commented Mar 12, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it

  • Fix matching logic (bindings/go/runtime/identity_match.go)
    • Added normalizeScheme() helper that maps "oci" → "https"
    • Changed IdentityMatchesURL to tolerate empty scheme (only fail if both non-empty and
      different)
    • Use effective scheme for port defaulting when one side has empty scheme
    • Added 6 new test cases in identity_match_test.go
  • Fix identity generation (bindings/go/oci/spec/credentials/identity/v1/type.go)
    • Simplified IdentityFromOCIRepository() to delegate to runtime.ParseURLToIdentity() —
      removes scheme/port defaulting
    • Updated test expectations: removed defaulted scheme/port values, paths now have
      leading / stripped
  • Fix consumer identity type name
    • Changed Type from "OCIRepository" to "OCIRegistry" in credential identity package
    • Fixed resource_repository.go to use credidentityv1.Type instead of
      runtime.NewUnversionedType(ociv1.Type)
    • Updated OCI integration test (2 occurrences)

Which issue(s) this PR fixes

fixes part of the inconsistencies across Consumer Identities: open-component-model/ocm-project#916

once this is complete I will need to bump both OCI + runtime and then patch it in both CLI + Controllers to take effect fully.

Testing

How to test the changes

Required files to test the changes:

.ocmconfig

type: generic.config.ocm.software/v1
configurations:
- type: credentials.config.ocm.software
    consumers:
      - identity:
          type: OCIRegistry
          hostname: ghcr.io
          pathprefix: open-component-model
        credentials:
          - type: Credentials/v1
            properties:
              username: my-user
              password: my-token

Commands that test the change:

ocm get cv xxx

ocm transfer xxx
Verification
  • I have tested the changes locally by running ocm

Summary by CodeRabbit

  • Bug Fixes

    • Improved OCI registry URL parsing and scheme matching logic.
    • Enhanced hostname and port validation for registry connections.
    • Added support for OCI scheme normalization to improve registry compatibility.
  • Tests

    • Expanded test coverage for URL matching edge cases and scheme handling.

Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
@github-actions github-actions Bot added the kind/bugfix Bug label Mar 12, 2026
@coderabbitai

coderabbitai Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This change refactors OCI identity type naming from "OCIRepository" to "OCIRegistry" and simplifies URL parsing logic by replacing manual URL component extraction with a centralized ParseURLToIdentity helper. Runtime identity matching is updated with scheme normalization to handle "oci" scheme mapping to "https".

Changes

Cohort / File(s) Summary
OCI Identity Type Refactoring
bindings/go/oci/spec/credentials/identity/v1/type.go, bindings/go/oci/spec/credentials/identity/v1/type_test.go
Renamed Type from "OCIRepository" to "OCIRegistry". Simplified IdentityFromOCIRepository to use ParseURLToIdentity instead of manual URL component extraction. Removed port and scheme attribute assertions from test expectations.
Runtime Identity Matching
bindings/go/runtime/identity_match.go, bindings/go/runtime/identity_match_test.go
Added normalizeScheme helper to map "oci" scheme to "https". Updated scheme comparison logic to allow empty schemes to match non-empty ones. Added test cases for OCI scheme and empty scheme matching scenarios.
Integration & Usage Updates
bindings/go/oci/integration/integration_test.go, bindings/go/oci/repository/resource/resource_repository.go
Updated test identity type assertions from "OCIRepository" to "OCIRegistry". Added credidentityv1 import alias and switched identity type assignment to use credidentityv1.Type.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Skarlso
  • matthiasbruns

Poem

🐰 The Registry renamed, a cleaner approach,
No longer manual URLs we must broach,
Scheme normalization brings harmony true,
OCI to HTTPS, the identity renews! 🔐

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: normalizing scheme handling and updating the identity type from OCIRepository to OCIRegistry across the codebase.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the size/m Medium label Mar 12, 2026
@jakobmoellerdev jakobmoellerdev marked this pull request as ready for review March 12, 2026 17:32
@jakobmoellerdev jakobmoellerdev requested a review from a team as a code owner March 12, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants