fix: defer keyring initialization to prevent build-time keychain errors#562
Conversation
Signed-off-by: Rui Chen <rui@chenrui.dev>
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes build-time keychain errors by deferring keyring initialization from package init time to first use through lazy initialization.
- Removed
init()function and replaced withensureKeyringProvider()usingsync.Oncefor thread-safe lazy initialization - Added calls to
ensureKeyringProvider()inGenerateEncryptionKey()andGetEncryptionKey()functions - Prevents keyring system from being accessed during build/package initialization
Comments suppressed due to low confidence (1)
pkg/utils/encryption.go:1
- The
ensureKeyringProvider()call inGetEncryptionKey()lacks test coverage to verify that the keyring provider is properly initialized on first use. Consider adding a test that validates lazy initialization behavior.
// Copyright Project Harbor Authors
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #562 +/- ##
=========================================
- Coverage 10.99% 6.74% -4.25%
=========================================
Files 173 258 +85
Lines 8671 15382 +6711
=========================================
+ Hits 953 1037 +84
- Misses 7612 14239 +6627
Partials 106 106 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
thoughts of merging this change? |
|
@qcserestipy thanks for the merge, can we cut a new release, this would help with shipping the project in homebrew-core, Homebrew/homebrew-core#250518. |
…rs (goharbor#562) Signed-off-by: Rui Chen <rui@chenrui.dev>
seeing some build issue with keychain, and patch to do lazy init