Encryption refactor fn injection - #2402
Conversation
…instead of clients Replace the deployer interface and secretClient/encryptionSecretSelector parameters with two injected functions, making the inputs explicit and decoupling the statemachine from specific client types. All five callers are updated with inline closures binding their existing clients. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Move the secret creation side effect out of checkAndCreateKeys into sync, making the function's output explicit. sync now handles Create, AlreadyExists validation, and event recording. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Refactor getCurrentModeReasonAndEncryptionConfig and the GetEncryptionConfigAndState call site to accept their client reads as explicit function parameters rather than using receiver fields directly. The three bound functions are stored on the struct and wired in the constructor, making all external dependencies of checkAndCreateKeys visible in its signature. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Refactor generateKeySecret to accept getKMSPluginSecret and getKMSPluginConfigMap as explicit function parameters instead of using the receiver's secretClient and configMapClient directly. Both functions are stored on the struct, wired in the constructor, and threaded through checkAndCreateKeys following the same pattern as the other resource fetchers. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…puts to checkAndCreateKeys Pass instanceName and unsupportedConfigPrefix as explicit parameters through checkAndCreateKeys into generateKeySecret and getCurrentModeReasonAndEncryptionConfig respectively, removing the last remaining receiver accesses from those helper methods. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…unctions Convert checkAndCreateKeys, getCurrentModeReasonAndEncryptionConfig and generateKeySecret from methods to package-level functions. The absence of a receiver proves all inputs are fully mapped out as explicit parameters. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…e functions Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
WalkthroughThis change replaces direct encryption client dependencies with injected callbacks across state retrieval, key generation, and controller synchronization. Key operations are extracted into standalone functions. New computer types provide side-effect-free key and encryption-config Secret computation. ChangesEncryption computation decoupling
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: p0lyn0mial The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…mputation Add a private computeKeySecret method on keyController that binds all stored functions and calls checkAndCreateKeys. sync now calls through this method. Add KeyComputer, a thin wrapper that accepts a keyController and exposes ComputeKey so future components can compute what key would be needed without creating it. Also fix double Fn suffix on struct field names introduced by the previous rename. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…applying it Move resourceapply.ApplySecret out of generateEncryptionConfigSecret into sync, following the same pattern as checkAndCreateKeys. The function now returns the secret to apply and pre-computed pending events; sync applies the secret and emits events only if ApplySecret reports a change. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…nConfigSecret Store deployedEncryptionConfigSecretFn and listKeySecretsFn on the stateController struct, wire them in the constructor, and pass them as explicit parameters to generateEncryptionConfigSecret, following the same pattern as the key controller. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…unction and add EncryptionComputer Inject instanceName as an explicit parameter into generateEncryptionConfigSecret and applyEncryptionConfigSecret, removing the last receiver accesses and promoting both to package-level functions. Add computeEncryptionConfigSecret as a private wrapper method on stateController (analogous to computeKeySecret on keyController). Add EncryptionComputer, a combined component that accepts both controllers and exposes read-only computation of both the key secret and the encryption config secret. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…roller Add computeEncryptionConfigSecretWithCustomListKeySecretFn on stateController to allow injecting a custom listKeySecretsFn into the encryption config computation. Add EncryptionComputer combining both controllers, exposing ComputeEncryptionConfigSecretWithNewKey which chains the key controller output into the state controller's computation by prepending the would-be key secret to the list of existing secrets. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Two table-driven scenarios with full YAML representations of both expected outputs — the newly computed KMS key secret and the resulting encryption config secret: 1. Fresh KMS setup (no existing keys): new key gets ID 1, encryption config places it as a read key in the first transitional pass. 2. Migrating from AESCBC to KMS (one fully-migrated AESCBC key exists): new KMS key gets ID 8, encryption config carries both keys as read keys alongside an identity write key until convergence. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary by CodeRabbit