Move getcertificate to tls
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you can request access to GitLab Duo.
Refactor: Improve TLS Certificate Management
Overview
This pull request introduces a more flexible and testable approach to retrieving TLS certificates. The changes focus on:
- Decoupling certificate retrieval logic
- Simplifying domain source interfaces
- Improving performance and maintainability
- Reducing complexity in TLS configuration
Motivation
The current TLS certificate retrieval process was overly complex and difficult to test. This refactoring aims to:
- Simplify the certificate retrieval mechanism
- Improve code readability
- Enhance testability of TLS-related components
Changes
- Created
DomainSource
andDomain
interfaces ininternal/tls/
- Implemented
GetCertificate
function with dependency injection - Updated
app.go
to use the new certificate retrieval mechanism - Added comprehensive tests for the new implementation
TLS Package Refactoring
- Removed
DomainSource
andDomain
interfaces - Simplified
GetCertificate
function - Reduced indirection in certificate handling
- Improved type compatibility in TLS-related functions
Key Modifications
- Streamlined certificate retrieval process
- Removed unnecessary caching mechanisms
- Centralized TLS configuration logic
- Improved separation of concerns
Implementation Details
- Updated
internal/tls/certificate.go
- Modified
internal/tls/tls.go
- Refined test cases in
internal/tls/tls_test.go
- Improved error handling and type conversions
Testing
- Maintained existing test coverage
- Added more precise type checking
- Ensured compatibility with existing configurations
Checklist
-
Updated implementation -
Added/updated tests -
Maintained existing functionality -
Followed project coding standards
Additional Notes
- Requires careful review of TLS configuration logic
- May need additional testing in complex domain scenarios
Linked Issues
- Fixes #708
Edited by Mohammed Firdous