chore: extract CredentialsFromHeader helper in plugin registries#2613
Conversation
✅ Deploy Preview for ocm-website canceled.
|
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (28)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
61c9d7c to
f33a012
Compare
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>
f33a012 to
6ba476e
Compare
) ## 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>
Summary
Gate 5 (#2602) migrated all credential parameters to
runtime.Typedbut left the Authorization header →runtime.Rawparsing duplicated inline in every registry handler. This PR extracts that into a shared helper.plugins/credentials.go:CredentialsFromHeaderreads theAuthorizationheader, unmarshals it intoruntime.Typed, and writes HTTP 401 on malformed inputblobtransformer,componentlister,credentialrepository,digestprocessor,input,resourceplugins/call.go: skip headers with empty keyNo behaviour change — pure extraction of duplicated code.
Test plan
cd bindings/go/plugin && go build ./... && go test ./...