Skip to content

Refactor the Cleanup method#1028

Open
maraino wants to merge 4 commits into
masterfrom
mariano/cleanup-certificates
Open

Refactor the Cleanup method#1028
maraino wants to merge 4 commits into
masterfrom
mariano/cleanup-certificates

Conversation

@maraino
Copy link
Copy Markdown
Contributor

@maraino maraino commented May 13, 2026

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.

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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread kms/capi/capi.go
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)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nil request will panic other KMSs, ignoring this.

Comment thread kms/tpmkms/tpmkms.go Outdated
Comment thread kms/tpmkms/tpmkms.go Outdated
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{})
}},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 875d451

Copy link
Copy Markdown
Contributor

@darkfronza darkfronza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no other issues other than the copilot suggested items.

maraino and others added 3 commits May 13, 2026 13:54
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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants