mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
0b7747bef0
Replaces (and appropriately refactors) a number of endpoints that were removed long ago when we decided to kill the UI with the fleetctl release. We turned out not to do this, and now need to restore these missing endpoints. This is not a straight up replacement of the existing code because of refactoring to the DB schemas that was also done in the migration. Most of the replaced code was removed in #1670 and #1686. Fixes #1811, fixes #1810
78 lines
1.5 KiB
Go
78 lines
1.5 KiB
Go
package kolide
|
|
|
|
// Datastore combines all the interfaces in the Kolide DAL
|
|
type Datastore interface {
|
|
UserStore
|
|
QueryStore
|
|
CampaignStore
|
|
PackStore
|
|
LabelStore
|
|
HostStore
|
|
TargetStore
|
|
PasswordResetStore
|
|
SessionStore
|
|
AppConfigStore
|
|
InviteStore
|
|
ScheduledQueryStore
|
|
OptionStore
|
|
FileIntegrityMonitoringStore
|
|
YARAStore
|
|
OsqueryOptionsStore
|
|
Name() string
|
|
Drop() error
|
|
// MigrateTables creates and migrates the table schemas
|
|
MigrateTables() error
|
|
// MigrateData populates built-in data
|
|
MigrateData() error
|
|
// MigrationStatus returns nil if migrations are complete, and an error
|
|
// if migrations need to be run.
|
|
MigrationStatus() (MigrationStatus, error)
|
|
Begin() (Transaction, error)
|
|
}
|
|
|
|
type MigrationStatus int
|
|
|
|
const (
|
|
NoMigrationsCompleted = iota
|
|
SomeMigrationsCompleted
|
|
AllMigrationsCompleted
|
|
)
|
|
|
|
// NotFoundError is returned when the datastore resource cannot be found.
|
|
type NotFoundError interface {
|
|
error
|
|
IsNotFound() bool
|
|
}
|
|
|
|
func IsNotFound(err error) bool {
|
|
e, ok := err.(NotFoundError)
|
|
if !ok {
|
|
return false
|
|
}
|
|
return e.IsNotFound()
|
|
}
|
|
|
|
// AlreadyExists is returned when creating a datastore resource that already
|
|
// exists.
|
|
type AlreadyExistsError interface {
|
|
error
|
|
IsExists() bool
|
|
}
|
|
|
|
// ForeignKeyError is returned when the operation fails due to foreign key
|
|
// constraints.
|
|
type ForeignKeyError interface {
|
|
error
|
|
IsForeignKey() bool
|
|
}
|
|
|
|
func IsForeignKey(err error) bool {
|
|
e, ok := err.(ForeignKeyError)
|
|
if !ok {
|
|
return false
|
|
}
|
|
return e.IsForeignKey()
|
|
}
|
|
|
|
type OptionalArg func() interface{}
|