Skip to content

Commit 02c8ce9

Browse files
committed
implement "implements" for go
1 parent 957a919 commit 02c8ce9

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

internal/core/db/stores_bun.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ package db
66

77
import (
88
"fmt"
9+
"time"
10+
911
"github.com/toeirei/keymaster/internal/model"
1012
"github.com/uptrace/bun"
11-
"time"
1213
)
1314

1415
// BunStore is the consolidated bun-backed Store implementation used for all
@@ -22,6 +23,12 @@ type BunStore struct {
2223
func (s *BunStore) BunDB() *bun.DB { return s.bun }
2324

2425
func (s *BunStore) GetAllAccounts() ([]model.Account, error) { return GetAllAccountsBun(s.bun) }
26+
func (s *BunStore) GetAccounts() ([]model.Account, error) {
27+
return s.GetAllAccounts()
28+
}
29+
func (s *BunStore) GetAccount(id int) (*model.Account, error) {
30+
return GetAccountByIDBun(s.bun, id)
31+
}
2532
func (s *BunStore) AddAccount(username, hostname, label, tags string) (int, error) {
2633
id, err := AddAccountBun(s.bun, username, hostname, label, tags)
2734
if err == nil {
@@ -40,6 +47,13 @@ func (s *BunStore) DeleteAccount(id int) error {
4047
}
4148
return err
4249
}
50+
func (s *BunStore) AssignKeyToAccount(keyID, accountID int) error {
51+
err := AssignKeyToAccountBun(s.bun, keyID, accountID)
52+
if err == nil {
53+
_ = s.LogAction("ASSIGN_KEY", fmt.Sprintf("keyID: %d, accountID: %d", keyID, accountID))
54+
}
55+
return err
56+
}
4357
func (s *BunStore) UpdateAccountSerial(id, serial int) error {
4458
return UpdateAccountSerialBun(s.bun, id, serial)
4559
}

internal/deploy/adapters_core.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ import (
1313
"github.com/toeirei/keymaster/internal/model"
1414
)
1515

16+
// Compile-time interface checks
17+
var (
18+
_ core.KeyLister = (*coreKeyLister)(nil) // coreKeyLister implements core.KeyLister
19+
_ core.AccountSerialUpdater = (*accountSerialUpdater)(nil) // accountSerialUpdater implements core.AccountSerialUpdater
20+
_ core.KeyImporter = (*keyImporter)(nil) // keyImporter implements core.KeyImporter
21+
_ core.AccountManager = (*coreAccountManager)(nil) // coreAccountManager implements core.AccountManager
22+
_ core.AuditWriter = (*coreAuditWriter)(nil) // coreAuditWriter implements core.AuditWriter
23+
)
24+
1625
// Wire DB-backed adapters into core defaults for packages that import
1726
// internal/deploy (many programs/tests import deploy but may not import UI packages).
1827

internal/uiadapters/store.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ import (
1616
"github.com/toeirei/keymaster/internal/model"
1717
)
1818

19+
// Compile-time interface checks
20+
var (
21+
_ core.Store = (*storeAdapter)(nil) // storeAdapter implements core.Store
22+
_ core.Store = (*db.BunStore)(nil) // db.BunStore implements core.Store
23+
)
24+
1925
// Package uiadapters provides thin, canonical adapters that adapt package-level
2026
// `internal/db` helpers to `core` interfaces used by UI layers (TUI/CLI/UI).
2127
//

0 commit comments

Comments
 (0)