Refactor the Cleanup method#1028
Open
maraino wants to merge 4 commits into
Open
Conversation
This method refactors the cleanup method and renames it to CleanupCredentials, renaming also the interface to CredentialsCleaner. It also moves the capi-specific functionality to the capi KMS.
There was a problem hiding this comment.
Pull request overview
This PR renames the cleanup API to CleanupCredentials, introduces the CredentialsCleaner interface, and moves Windows CAPI-specific expired-certificate cleanup into the CAPI KMS implementation.
Changes:
- Renamed cleanup request/interface/method types in
apiv1, TPM KMS, and platform KMS. - Added CAPI-backed cleanup implementation for expired certificates.
- Added/updated platform tests for cleanup behavior across Windows, Darwin, and other platforms.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
kms/apiv1/options.go |
Renames optional cleanup interface to CredentialsCleaner. |
kms/apiv1/requests.go |
Renames cleanup request type to CleanupCredentialsRequest. |
kms/capi/capi.go |
Adds CAPI cleanup logic for expired certificates. |
kms/platform/kms.go |
Delegates cleanup to backends implementing CredentialsCleaner. |
kms/platform/kms_test.go |
Adds helper support for certificate template modification and cleanup tests. |
kms/platform/kms_windows_test.go |
Adds Windows CAPI cleanup test coverage. |
kms/platform/kms_darwin_test.go |
Adds Darwin cleanup not-implemented test coverage. |
kms/platform/kms_other_test.go |
Adds non-Darwin/non-Windows cleanup test coverage. |
kms/tpmkms/tpmkms.go |
Renames TPM cleanup method and delegates Windows-specific cleanup to CAPI. |
kms/tpmkms/tpmkms_simulator_test.go |
Updates test field type for the renamed CAPI certificate manager interface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1146
to
+1153
| func (k *CAPIKMS) CleanupCredentials(req *apiv1.CleanupCredentialsRequest) error { | ||
| certs, err := k.FindCertificatesByIssuer(&apiv1.LoadCertificateRequest{ | ||
| Name: uri.New("capi", url.Values{ | ||
| "issuer": []string{req.Issuer}, | ||
| "store-location": []string{req.StoreLocation}, | ||
| "store": []string{req.Store}, | ||
| }).String(), | ||
| }, req.RawSubject) |
Contributor
Author
There was a problem hiding this comment.
A nil request will panic other KMSs, ignoring this.
Comment on lines
+51
to
+55
| {"not implemented", platformKMS, args{&apiv1.CleanupCredentialsRequest{ | ||
| RawSubject: chain[0].RawSubject, | ||
| }}, func(tt assert.TestingT, err error, i ...interface{}) bool { | ||
| return assert.ErrorIs(tt, err, apiv1.NotImplementedError{}) | ||
| }}, |
darkfronza
requested changes
May 13, 2026
Contributor
darkfronza
left a comment
There was a problem hiding this comment.
I see no other issues other than the copilot suggested items.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
dopey
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This method refactors the cleanup method and renames it to CleanupCredentials, renaming also the interface to CredentialsCleaner. It also moves the capi-specific functionality to the capi KMS.