Skip to content

chore: extract CredentialsFromHeader helper in plugin registries#2613

Merged
jakobmoellerdev merged 2 commits into
open-component-model:mainfrom
jakobmoellerdev:refactor/plugin-credentials-from-header
May 22, 2026
Merged

chore: extract CredentialsFromHeader helper in plugin registries#2613
jakobmoellerdev merged 2 commits into
open-component-model:mainfrom
jakobmoellerdev:refactor/plugin-credentials-from-header

Conversation

@jakobmoellerdev

Copy link
Copy Markdown
Member

Summary

Gate 5 (#2602) migrated all credential parameters to runtime.Typed but left the Authorization header → runtime.Raw parsing duplicated inline in every registry handler. This PR extracts that into a shared helper.

  • Add plugins/credentials.go: CredentialsFromHeader reads the Authorization header, unmarshals it into runtime.Typed, and writes HTTP 401 on malformed input
  • Update all registry handlers to use it: blobtransformer, componentlister, credentialrepository, digestprocessor, input, resource
  • plugins/call.go: skip headers with empty key

No behaviour change — pure extraction of duplicated code.

Test plan

  • cd bindings/go/plugin && go build ./... && go test ./...

@jakobmoellerdev jakobmoellerdev requested a review from a team as a code owner May 22, 2026 06:39
@netlify

netlify Bot commented May 22, 2026

Copy link
Copy Markdown

Deploy Preview for ocm-website canceled.

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

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@jakobmoellerdev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 58 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 289b876d-b37f-4b6b-8474-4e16481a926c

📥 Commits

Reviewing files that changed from the base of the PR and between 67a18b8 and c466906.

⛔ Files ignored due to path filters (1)
  • bindings/go/plugin/go.sum is excluded by !**/*.sum
📒 Files selected for processing (28)
  • bindings/go/plugin/go.mod
  • bindings/go/plugin/manager/registries/blobtransformer/handlers.go
  • bindings/go/plugin/manager/registries/blobtransformer/handlers_test.go
  • bindings/go/plugin/manager/registries/blobtransformer/implementations.go
  • bindings/go/plugin/manager/registries/blobtransformer/implementations_test.go
  • bindings/go/plugin/manager/registries/componentlister/handlers.go
  • bindings/go/plugin/manager/registries/componentlister/handlers_test.go
  • bindings/go/plugin/manager/registries/componentlister/implementations.go
  • bindings/go/plugin/manager/registries/credentialplugin/registry_test.go
  • bindings/go/plugin/manager/registries/credentialrepository/converter_test.go
  • bindings/go/plugin/manager/registries/credentialrepository/endpoints_function_test.go
  • bindings/go/plugin/manager/registries/credentialrepository/handlers.go
  • bindings/go/plugin/manager/registries/credentialrepository/handlers_test.go
  • bindings/go/plugin/manager/registries/credentialrepository/implementations.go
  • bindings/go/plugin/manager/registries/credentialrepository/implementations_test.go
  • bindings/go/plugin/manager/registries/digestprocessor/handlers.go
  • bindings/go/plugin/manager/registries/digestprocessor/handlers_test.go
  • bindings/go/plugin/manager/registries/digestprocessor/implementations.go
  • bindings/go/plugin/manager/registries/digestprocessor/implementations_test.go
  • bindings/go/plugin/manager/registries/input/handlers.go
  • bindings/go/plugin/manager/registries/input/handlers_test.go
  • bindings/go/plugin/manager/registries/input/implementations.go
  • bindings/go/plugin/manager/registries/plugins/call.go
  • bindings/go/plugin/manager/registries/plugins/credentials.go
  • bindings/go/plugin/manager/registries/resource/contract.go
  • bindings/go/plugin/manager/registries/resource/endpoints_function.go
  • bindings/go/plugin/manager/registries/resource/implementations.go
  • bindings/go/plugin/manager/registries/resource/registry_test.go
✨ 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 the size/m Medium label May 22, 2026
@jakobmoellerdev jakobmoellerdev force-pushed the refactor/plugin-credentials-from-header branch from 61c9d7c to f33a012 Compare May 22, 2026 06:41
@jakobmoellerdev jakobmoellerdev changed the title refactor: extract CredentialsFromHeader helper in plugin registries chore: extract CredentialsFromHeader helper in plugin registries May 22, 2026
@github-actions github-actions Bot added the kind/chore chore, maintenance, etc. label May 22, 2026
Gate 5 (open-component-model#2602) migrated credential parameters to runtime.Typed but left
inline JSON parsing in every registry handler. Extract the repeated
Authorization header → runtime.Raw parsing into a shared helper and
update all handlers to use it.

- Add plugins/credentials.go: CredentialsFromHeader reads the
  Authorization header and unmarshals it into runtime.Typed, writing
  an HTTP 401 on malformed input
- Update all registry handlers (blobtransformer, componentlister,
  credentialrepository, digestprocessor, input, resource) to use it
- plugins/call.go: skip headers with empty key

Refs: open-component-model#1047
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 refactor/plugin-credentials-from-header branch from f33a012 to 6ba476e Compare May 22, 2026 06:46
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 jakobmoellerdev enabled auto-merge (squash) May 22, 2026 12:49
@jakobmoellerdev jakobmoellerdev merged commit 4ea3428 into open-component-model:main May 22, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/chore chore, maintenance, etc. size/m Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants