feat: 引入 99designs/keyring 作为默认凭证存储后端#69
Merged
Conversation
added 2 commits
July 18, 2026 02:37
- 新增 keyring.go — keyring 后端封装,支持 mock 测试 - 修改 store.go — 新增 SaveKeys/LoadKeys 基于 provider 名的 API - 修改 store.go — LoadKeysFromStore 优先尝试 keyring - 修改 cmd/key.go — 使用 provider 名而非文件路径操作 - 新增 keyring_test.go — 11 个测试覆盖 SaveKeys/LoadKeys/迁移 - 修复 crypto_test.go — 补全 SetEncryptionKey 的 defer 清理 Closes #44
- 修复 keyAddCmd 和 keyListCmd 使用 LoadKeys/SaveKeys (keyring) - 新增 RemoveKeys 公共 API 用于测试清理 - 更新集成测试从文件验证改为 keyring 验证 - 修复 keyring 持久化导致的测试间污染
bigmanBass666
marked this pull request as ready for review
July 17, 2026 19:08
bigmanBass666
enabled auto-merge (squash)
July 17, 2026 19:08
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.
变更内容
将 API Key 的存储后端从明文 JSON 文件迁移到 OS 密码管理器(Keychain / WinCred / Secret Service),使用
99designs/keyringGo 库。核心改动
新增
internal/keypool/keyring.go— keyring 后端封装saveToKeyring()/loadFromKeyring()— 对 keyring 的读写操作setTestKeyring()/resetTestKeyring()— mock 支持,测试用akswitch:<provider>键下修改
internal/keypool/store.go— 新增 provider 级 APISaveKeys(provider, store)/LoadKeys(provider)— 基于 provider 名的读写LoadKeysFromStore优先尝试 keyring,再回退到文件.enc文件 → 读入 → 写入 keyring → 重命名为.bak修改
internal/cmd/key.go— 适配新 APIkey add/key list/key remove/disable/enable改为调用SaveKeys/LoadKeys新增
keyring_test.go— 11 个测试全覆盖SaveKeys/LoadKeys读写回环LoadKeysFromStorekeyring 优先修复
crypto_test.go— 补全两个测试的defer SetEncryptionKey(nil),消除全局状态泄漏测试
make test-all(unit → integration → e2e)— 等待 CI 确认设计决策
详见 ADR-003:
docs/internal/adr/adr-003-os-keyring-storage.md