Refactor genericList to accept string prefixes instead of byte slices
This commit is contained in:
parent
f01628c203
commit
c7f669d23c
|
|
@ -52,7 +52,7 @@ func genericGet[T any, PT interface {
|
|||
func genericList[T any, PT interface {
|
||||
SetVersion(uint64)
|
||||
*T
|
||||
}](txn *Transaction, prefix []byte) (_ []T, err error) {
|
||||
}](txn *Transaction, prefix string) (_ []T, err error) {
|
||||
defer func() {
|
||||
err = mapErr(err)
|
||||
}()
|
||||
|
|
@ -62,7 +62,7 @@ func genericList[T any, PT interface {
|
|||
result := []T{}
|
||||
|
||||
it := txn.badgerTxn.NewIterator(badger.IteratorOptions{
|
||||
Prefix: prefix,
|
||||
Prefix: []byte(prefix),
|
||||
})
|
||||
defer it.Close()
|
||||
|
||||
|
|
|
|||
|
|
@ -25,5 +25,5 @@ func (txn *Transaction) DeleteServiceAccount(name string) error {
|
|||
}
|
||||
|
||||
func (txn *Transaction) ListServiceAccounts() ([]v1.ServiceAccount, error) {
|
||||
return genericList[v1.ServiceAccount](txn, []byte(SpaceServiceAccounts))
|
||||
return genericList[v1.ServiceAccount](txn, SpaceServiceAccounts)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,5 @@ func (txn *Transaction) DeleteVM(name string) error {
|
|||
}
|
||||
|
||||
func (txn *Transaction) ListVMs() ([]v1.VM, error) {
|
||||
return genericList[v1.VM](txn, []byte(SpaceVMs))
|
||||
return genericList[v1.VM](txn, SpaceVMs)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,5 @@ func (txn *Transaction) DeleteWorker(name string) error {
|
|||
}
|
||||
|
||||
func (txn *Transaction) ListWorkers() ([]v1.Worker, error) {
|
||||
return genericList[v1.Worker](txn, []byte(SpaceWorkers))
|
||||
return genericList[v1.Worker](txn, SpaceWorkers)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue