fix: try to move GetCertificate to internal/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 receive complimentary access to GitLab Duo.
What does this MR do?
This MR moves the certificate retrieval logic from app.go to the internal/tls package to improve code organization and reduce coupling between packages. It also enhances robustness and maintainability through improved error handling, logging, and documentation.
Why was this MR needed?
- Improve code organization by placing TLS-related functionality in a dedicated package
- Reduce coupling between packages
- Enhance readability and maintainability
- Ensure better test coverage and error visibility
Implementation details
- Added
GetCertificateForDomainfunction to handle domain certificate retrieval - Extracted anonymous logic into a named method for improved clarity
- Added proper error handling with structured logging
- Updated
GetTLSConfigto use domain lookup function - Fixed import issues and type mismatches
- Added a specific test for
GetCertificateForDomain - Fixed previously failing acceptance tests
- Added comprehensive inline documentation
Testing
-
✅ Unit tests pass:go test ./internal/tls/... -
✅ Integration tests pass:go test ./test/... -
✅ All tests pass:make test -
✅ New tests added for core logic
Documentation
-
✅ Updated code comments with comprehensive explanations -
📄 No external documentation changes needed
Edited by Mohammed Firdous