mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 00:49:03 +00:00
This PR reorganizes a bunch of the files in datastore such that all datastore implementations are consistently broken up into multiple files. Additionally, the datastore tests follow a similar pattern and can easily be applied to any complete datastore implementation.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package datastore
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/kolide/kolide-ose/server/kolide"
|
|
)
|
|
|
|
type inmem struct {
|
|
kolide.Datastore
|
|
Driver string
|
|
mtx sync.RWMutex
|
|
users map[uint]*kolide.User
|
|
sessions map[uint]*kolide.Session
|
|
passwordResets map[uint]*kolide.PasswordResetRequest
|
|
invites map[uint]*kolide.Invite
|
|
labels map[uint]*kolide.Label
|
|
labelQueryExecutions map[uint]*kolide.LabelQueryExecution
|
|
queries map[uint]*kolide.Query
|
|
packs map[uint]*kolide.Pack
|
|
hosts map[uint]*kolide.Host
|
|
orginfo *kolide.OrgInfo
|
|
}
|
|
|
|
func (orm *inmem) Name() string {
|
|
return "inmem"
|
|
}
|
|
|
|
func (orm *inmem) Migrate() error {
|
|
orm.mtx.Lock()
|
|
defer orm.mtx.Unlock()
|
|
orm.users = make(map[uint]*kolide.User)
|
|
orm.sessions = make(map[uint]*kolide.Session)
|
|
orm.passwordResets = make(map[uint]*kolide.PasswordResetRequest)
|
|
orm.invites = make(map[uint]*kolide.Invite)
|
|
orm.labels = make(map[uint]*kolide.Label)
|
|
orm.labelQueryExecutions = make(map[uint]*kolide.LabelQueryExecution)
|
|
orm.queries = make(map[uint]*kolide.Query)
|
|
orm.packs = make(map[uint]*kolide.Pack)
|
|
orm.hosts = make(map[uint]*kolide.Host)
|
|
return nil
|
|
}
|
|
|
|
func (orm *inmem) Drop() error {
|
|
return orm.Migrate()
|
|
}
|