Skip to content

feat!: migrate constructor binding to runtime.Typed credentials#2598

Merged
jakobmoellerdev merged 3 commits into
open-component-model:mainfrom
jakobmoellerdev:feat/migrate-constructor-to-typed-credentials
May 21, 2026
Merged

feat!: migrate constructor binding to runtime.Typed credentials#2598
jakobmoellerdev merged 3 commits into
open-component-model:mainfrom
jakobmoellerdev:feat/migrate-constructor-to-typed-credentials

Conversation

@jakobmoellerdev

Copy link
Copy Markdown
Member

What this PR does / why we need it

Migrates the constructor binding to use runtime.Typed credentials, following the established pattern from:

Updates the following interfaces from map[string]stringruntime.Typed:

  • ResourceInputMethod.ProcessResource
  • SourceInputMethod.ProcessSource
  • ResourceDigestProcessor.ProcessResourceDigest
  • ResourceRepository.DownloadResource

Also migrates resolveCredentials to call ResolveTyped and bumps the credentials dependency from v0.0.10v0.0.11.

Which issue(s) this PR fixes

Contributes:

Part of the migration path: #2519

Dependencies

This PR depends on #2594 (oci) being merged first.

Testing

  • All existing constructor binding tests pass (go test ./...)
  • Breaking change — callers must update mock implementations to accept runtime.Typed

@jakobmoellerdev jakobmoellerdev requested a review from a team as a code owner May 21, 2026 13:59
@netlify

netlify Bot commented May 21, 2026

Copy link
Copy Markdown

👷 Deploy Preview for ocm-website processing.

Name Link
🔨 Latest commit a913649
🔍 Latest deploy log https://app.netlify.com/projects/ocm-website/deploys/6a0f23adbffa44000823aec7

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e995a8be-84e6-4b72-ac52-dc4f47e6e14a

📥 Commits

Reviewing files that changed from the base of the PR and between 1ed0d01 and a913649.

📒 Files selected for processing (1)
  • docs/adr/0021_typed_credentials.md

📝 Walkthrough

Walkthrough

This PR migrates credential handling in the Go constructor bindings from untyped map[string]string to strongly typed ocmruntime.Typed, updating four public interfaces, the credential resolution helper to use ResolveTyped, all constructor call sites, test mocks, module dependency, and ADR documentation.

Changes

Typed Credentials Migration

Layer / File(s) Summary
Public interface credential type contracts
bindings/go/constructor/interface.go
Four public methods in constructor interfaces update their credentials parameter type from map[string]string to runtime.Typed: ResourceInputMethod.ProcessResource, SourceInputMethod.ProcessSource, ResourceDigestProcessor.ProcessResourceDigest, and ResourceRepository.DownloadResource.
Credential resolution and constructor call sites
bindings/go/constructor/construct.go
The resolveCredentials helper returns ocmruntime.Typed and calls provider.ResolveTyped() instead of the deprecated provider.Resolve(). Four constructor code paths (digest processor, by-value downloads, source input, resource input) update their local creds variables and pass typed credentials to their corresponding interfaces.
Test mock implementations
bindings/go/constructor/construct_resource_test.go, bindings/go/constructor/construct_source_test.go, bindings/go/constructor/input_method_registry_test.go
All mock implementations update their method signatures to accept runtime.Typed credentials: three mocks in resource tests, one in source tests, two in registry tests. The credential provider mock is adjusted to pass identity directly to Resolve.
Module dependency and ADR
bindings/go/constructor/go.mod, docs/adr/0021_typed_credentials.md
The credentials module dependency is updated from v0.0.10 to v0.0.11. The ADR gains a Phase 4 entry documenting the constructor binding migration to runtime.Typed and ResolveTyped.

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • frewilhelm
  • piotrjanik
  • morri-son

Poem

🐰 I hopped through code, made credentials neat,
From scattered maps to a typed heartbeat,
ResolveTyped I carried with a grin,
Tests and interfaces now lined up thin,
A tiny rabbit's patch — tidy and sweet.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: migrating the constructor binding to use runtime.Typed credentials, which is the central focus of all file modifications.
Description check ✅ Passed The description is directly related to the changeset, providing context about the migration, affected interfaces, dependency updates, and testing status.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added !BREAKING-CHANGE! Breaking change in API or ocm-cli or spec kind/feature new feature, enhancement, improvement, extension size/s Small labels May 21, 2026
Updates all credential-passing interfaces in the constructor binding from
map[string]string to runtime.Typed, following the same pattern established
by the OCI (open-component-model#2594), blob, rsa, and signing (open-component-model#2580) migrations.

- ProcessResource, ProcessSource, ProcessResourceDigest, DownloadResource
  now accept runtime.Typed instead of map[string]string
- resolveCredentials now calls ResolveTyped and returns runtime.Typed
- Bumps credentials dependency from v0.0.10 to v0.0.11

Contributes to: open-component-model/ocm-project#1055

On-behalf-of: @SAP <jakob.moeller@sap.com>
Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
On-behalf-of: @SAP <jakob.moeller@sap.com>
@jakobmoellerdev jakobmoellerdev force-pushed the feat/migrate-constructor-to-typed-credentials branch from 649f004 to 1ed0d01 Compare May 21, 2026 14:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bindings/go/constructor/interface.go`:
- Line 50: The method comment for ProcessResource (and any other related
comments in this file that still reference a “credentials map”) is stale after
the signature migration; update those doc comments to refer to the typed
credentials parameter runtime.Typed and briefly describe its role/shape instead
of a map. Specifically, revise the comment above ProcessResource (and other
occurrences that mention credentials) to mention the runtime.Typed typed
credentials argument passed to the handler, and ensure related symbols like
constructor.Resource and ResourceInputMethodResult are described consistently
with the new signature.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5d259cda-9423-4d19-8386-bb5b0928c11e

📥 Commits

Reviewing files that changed from the base of the PR and between f914013 and 1ed0d01.

⛔ Files ignored due to path filters (1)
  • bindings/go/constructor/go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • bindings/go/constructor/construct.go
  • bindings/go/constructor/construct_resource_test.go
  • bindings/go/constructor/construct_source_test.go
  • bindings/go/constructor/go.mod
  • bindings/go/constructor/input_method_registry_test.go
  • bindings/go/constructor/interface.go

Comment thread bindings/go/constructor/interface.go
Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
On-behalf-of: @SAP <jakob.moeller@sap.com>
@jakobmoellerdev jakobmoellerdev enabled auto-merge (squash) May 21, 2026 15:24
@jakobmoellerdev jakobmoellerdev merged commit 2f5bcd0 into open-component-model:main May 21, 2026
22 of 23 checks passed
jakobmoellerdev added a commit that referenced this pull request May 21, 2026
…als v0.0.12 compat) (#2603)

## Summary

- `credentials v0.0.12` unified the `Resolver` interface to a single
`Resolve(ctx, identity) (runtime.Typed, error)` method, removing the
separate `ResolveTyped` method that existed in v0.0.11
- `constructor v0.0.8` (released as part of gate 4, PR #2598) still
calls `provider.ResolveTyped` and depends on `credentials v0.0.11`
- This causes a build failure when any module depends on both
`constructor v0.0.8` and `credentials v0.0.12`

This fix updates `construct.go` to call `provider.Resolve` and bumps the
credentials dependency to `v0.0.12`.

## Dependency on
Must be released as `constructor/v0.0.9` before PR #2602 (gate 5 plugin
migration) can drop its `replace` directive.

Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
jakobmoellerdev added a commit that referenced this pull request May 22, 2026
…credentials (gate 5) (#2602)

## Summary

Gate 5 of the typed credentials migration (#1047). Migrates `plugin`,
`constructor`, and `input/*` modules from `map[string]string` to
`runtime.Typed` credentials.

This continues the series started in gates 1-4 (blob, signing, rsa,
repository, sigstore, oci, constructor published as PR #2598).

### Modules changed

| Module | Change |
|--------|--------|
| `bindings/go/constructor` | `Resolver.Resolve` return type
`map[string]string` → `runtime.Typed`; bump credentials v0.0.11→v0.0.12
|
| `bindings/go/input/dir` | `ProcessResource`/`ProcessSource`
credentials param `map[string]string` → `runtime.Typed` |
| `bindings/go/input/file` | same |
| `bindings/go/input/utf8` | same |
| `bindings/go/plugin` | All contract interfaces, registry
implementations, handlers, converters, test plugins |

### Key design decisions

- **Client side** (`toCredentials`): `nil` credentials → sends `"{}"`
JSON to preserve valid Authorization header format
- **Server side** (handlers): deserialize Authorization header into
`&runtime.Raw{}` since concrete type is unknown at HTTP boundary
- **`plugin/go.mod`**: uses `replace` directive pointing to local
`../constructor` (gate 5 constructor not yet released as module tag)

### Related issues
- Part of #1047 (typed credentials migration)
- Supersedes draft PR #2599

## Test plan

- [x] `go build ./...` passes in all 5 affected modules  
- [x] `go test ./...` passes in `constructor`, `input/dir`,
`input/file`, `input/utf8`
- [x] `go test ./...` passes in `plugin` (96 files changed, all
registry/handler/flow tests pass)
- [ ] Integration tests with downstream modules (gates 6-8 not yet
migrated)

---------

Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
jakobmoellerdev added a commit that referenced this pull request May 22, 2026
)

## Summary

Gate 6 of the phased [ADR 0018 / issue
#1047](open-component-model/ocm-project#1047)
credentials migration. Builds on gates 1–5 (PRs #2580, #2586, #2594,
#2598, #2602).

> **Note:** this branch also contains #2613 (plugin
`CredentialsFromHeader` refactor). Once that merges, this PR will show
only the helm changes.

### helm binding changes

- `cmd/main.go`, `input/method.go`: `ProcessResource`/`ProcessSource` →
`runtime.Typed`
- `digest/digest.go`: `ProcessResourceDigest` → `runtime.Typed`; single
`ConvertCredentials` call replaces two separate conversions
- `repository/resource/resource_repository.go`:
`DownloadResource`/`UploadResource` → `runtime.Typed`; `var _
repository.ResourceRepository` assertion restored
- `transformation/get_helm_chart.go`: use upstream typed
`ResourceRepository` interface; delete `transformation/credentials.go`
- `spec/credentials/v1/convert.go`: new
`ConvertCredentials(runtime.Typed) (*HelmHTTPCredentials,
*OCICredentials, error)` — single scheme-based conversion returning both
types
- `spec/credentials/scheme.go`: package-level `Scheme` for helm
credentials
- `spec/credentials/v1/helm_credentials.go`: remove deprecated exported
constants and `FromDirectCredentials` (now private)
- `go.mod`: `plugin` → v0.0.16, `blob` → v0.0.13, `repository` → v0.0.9;
no replace directives

## Test plan

- [ ] `cd bindings/go/helm && go build ./... && go test ./...` (cmd/*
requires `task build` for plugin binary)
- [ ] `grep -rn "map\[string\]string" bindings/go/helm/` returns no
credential parameter usages

Refs: #1047

Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
jakobmoellerdev added a commit that referenced this pull request May 26, 2026
…entials (gate 7) (#2616)

#### What this PR does / why we need it

Gate 7 of the typed credentials migration (ocm-project#1047).

Migrates `bindings/go/transfer` and `kubernetes/controller` to use
`runtime.Typed` credentials instead of `map[string]string`.

**bindings/go/transfer:**
- Bump `blob→v0.0.13`, `credentials→v0.0.12`, `oci→v0.0.43`,
`repository→v0.0.9`
- Update OCI identity import path: `oci/spec/credentials/identity/v1` →
`oci/spec/identity/v1`

**kubernetes/controller:**
- `resolveResourceCredentials` and `VerifyResource` return
`runtime.Typed` instead of `map[string]string`
- Replace `map[string]string` RSA credential literals with
`rsacredentialsv1.RSACredentials` structs
- Update import aliases for `oci/spec/credentials` and
`oci/spec/identity/v1`
- `GetComponentVersionRepository` call sites updated to pass
`runtime.Typed` credentials

#### Which issue(s) this PR fixes

Contributes:
- open-component-model/ocm-project#1047
- open-component-model/ocm-project#1055
- open-component-model/ocm-project#1056
- open-component-model/ocm-project#1057

#### Binding release order

| Gate | PRs | Modules | Status |
|------|-----|---------|--------|
| 1 | ✅ #2580 | blob, signing, rsa | merged |
| 2 | ✅ #2586 | repository, sigstore | merged |
| 3 | ✅ #2594 | oci | merged |
| 4 | ✅ #2598 | constructor | merged |
| 5 | ✅ #2602 | plugin, input/dir, input/file, input/utf8 | merged |
| 6 | ✅ #2612 | helm | merged |
| 7 | **this PR** | transfer, controller | 👈 |
| 8 | PR 8 | cli | — |

---------

Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
Co-authored-by: Matthias Bruns <git@matthiasbruns.com>
@matthiasbruns matthiasbruns mentioned this pull request May 26, 2026
5 tasks
matthiasbruns added a commit that referenced this pull request May 26, 2026
On-behalf-of: SAP <matthias.bruns@sap.com>

<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it
Final PR of the breaking change chain for the credential migration.
This PR updated the CLI.

#### Which issue(s) this PR fixes
Fixed: open-component-model/ocm-project#1056

| Gate | PRs | Modules | Status |
|------|-----|---------|--------|
| 1 | ✅ #2580 | blob, signing, rsa | merged |
| 2 | ✅ #2586 | repository, sigstore | merged |
| 3 | ✅ #2594 | oci | merged |
| 4 | ✅ #2598 | constructor | merged |
| 5 | ✅ #2602 | plugin, input/dir, input/file, input/utf8 | merged |
| 6 | ✅ #2612 | helm | merged |
| 7 | ✅  #2616 | transfer, controller | merged |
| 8 | **this PR** | cli | 👈 |

#### Testing

##### How to test the changes

##### Verification

- [ ] I have added/updated tests for my changes (see [Test
Requirements](../CONTRIBUTING.md#test-requirements))
- [x] Tests pass locally (`task test` and `task test/integration` if
applicable)
- [ ] If touching multiple modules, `go work` is enabled (see `go.work`)
- [x] My changes do not decrease test coverage
- [ ] I have tested the changes locally by running `ocm`

---------

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Documentation related !BREAKING-CHANGE! Breaking change in API or ocm-cli or spec kind/feature new feature, enhancement, improvement, extension size/s Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants