Skip to content

fix(operator): standardize secret references to custom SecretKeyRef#4580

Open
mvanhorn wants to merge 1 commit intostacklok:mainfrom
mvanhorn:osc/4540-standardize-secretkeyref
Open

fix(operator): standardize secret references to custom SecretKeyRef#4580
mvanhorn wants to merge 1 commit intostacklok:mainfrom
mvanhorn:osc/4540-standardize-secretkeyref

Conversation

@mvanhorn
Copy link
Copy Markdown

@mvanhorn mvanhorn commented Apr 7, 2026

Summary

MCPRegistry was the only CRD using corev1.SecretKeySelector for secret references. The other 5 CRDs all use the custom SecretKeyRef type. This PR standardizes MCPRegistry to match, converting 5 fields before the API stabilizes.

Why this matters

The corev1.SecretKeySelector type carries an unused Optional *bool field that no controller code checks. The custom SecretKeyRef is simpler (just Name + Key, both required) and already used by 13+ fields across other CRDs. Standardizing now avoids a breaking change later.

Changes

  • mcpregistry_types.go: Convert 5 fields from corev1.SecretKeySelector to SecretKeyRef (preserving pointer semantics for optional fields)
  • secrets.go: Decouple GetValue from corev1 by accepting name and key as separate string parameters
  • pgpass.go, config.go, podtemplatespec.go: Update callers for the new signatures
  • Test files: Replace corev1.SecretKeySelector{LocalObjectReference: ...} constructors with simpler SecretKeyRef{Name: ..., Key: ...}

The JSON wire format is identical ({"name": "...", "key": "..."}) so existing manifests work without changes.

Testing

  • Updated all unit and integration test fixtures
  • Note: CRD manifests will need regeneration via task gen after merge (deepcopy and OpenAPI schema updates)

Fixes #4540

This contribution was developed with AI assistance (Codex).

Replace corev1.SecretKeySelector with the custom SecretKeyRef type
across all MCPRegistry CRD fields. This aligns MCPRegistry with the
5 other CRDs that already use SecretKeyRef, removing the inconsistent
corev1.SecretKeySelector usage before the API stabilizes.

Changes:
- Convert 5 fields in mcpregistry_types.go to SecretKeyRef
- Decouple secrets.GetValue from corev1 by accepting name/key strings
- Update all callers and test fixtures

The JSON wire format is identical for both types, so existing
manifests continue to work without changes.

Fixes stacklok#4540
@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Apr 7, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.92%. Comparing base (8c70343) to head (75c664b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4580      +/-   ##
==========================================
+ Coverage   68.87%   68.92%   +0.05%     
==========================================
  Files         505      505              
  Lines       52380    52389       +9     
==========================================
+ Hits        36076    36111      +35     
+ Misses      13516    13490      -26     
  Partials     2788     2788              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize secret references to use custom SecretKeyRef across all CRDs

1 participant