mysql

package
v0.0.0-...-98a7958 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBOption

type DBOption func(o *dbOptions) error

DBOption is used to pass optional arguments to a database connection

func LimitAttempts

func LimitAttempts(attempts int) DBOption

LimitAttempts sets a the number of attempts to try establishing a connection to the database backend the default value is 15 attempts

func Logger

func Logger(l log.Logger) DBOption

Logger adds a logger to the datastore

type Datastore

type Datastore struct {
	// contains filtered or unexported fields
}

Datastore is an implementation of kolide.Datastore interface backed by MySQL

func New

func New(config config.MysqlConfig, c clock.Clock, opts ...DBOption) (*Datastore, error)

New creates an MySQL datastore.

func (*Datastore) AddHostToPack

func (d *Datastore) AddHostToPack(hid, pid uint) error

AddHostToPack associates a kolide.Host with a kolide.Pack

func (*Datastore) AddLabelToPack

func (d *Datastore) AddLabelToPack(lid uint, pid uint, opts ...kolide.OptionalArg) error

AddLabelToPack associates a kolide.Label with a kolide.Pack

func (*Datastore) AppConfig

func (d *Datastore) AppConfig() (*kolide.AppConfig, error)

func (*Datastore) ApplyEnrollSecretSpec

func (d *Datastore) ApplyEnrollSecretSpec(spec *kolide.EnrollSecretSpec) error

func (*Datastore) ApplyLabelSpecs

func (d *Datastore) ApplyLabelSpecs(specs []*kolide.LabelSpec) (err error)

func (*Datastore) ApplyOptions

func (d *Datastore) ApplyOptions(spec *kolide.OptionsSpec) (err error)

func (*Datastore) ApplyPackSpecs

func (d *Datastore) ApplyPackSpecs(specs []*kolide.PackSpec) (err error)

func (*Datastore) ApplyQueries

func (d *Datastore) ApplyQueries(authorID uint, queries []*kolide.Query) (err error)

func (*Datastore) AuthenticateHost

func (d *Datastore) AuthenticateHost(nodeKey string) (*kolide.Host, error)

func (*Datastore) Begin

func (d *Datastore) Begin() (kolide.Transaction, error)

func (*Datastore) CleanupDistributedQueryCampaigns

func (d *Datastore) CleanupDistributedQueryCampaigns(now time.Time) (expired uint, err error)

func (*Datastore) CleanupIncomingHosts

func (d *Datastore) CleanupIncomingHosts(now time.Time) error

func (*Datastore) Close

func (d *Datastore) Close() error

Close frees resources associated with underlying mysql connection

func (*Datastore) ConfirmPendingEmailChange

func (ds *Datastore) ConfirmPendingEmailChange(id uint, token string) (newEmail string, err error)

ConfirmPendingEmailChange finds email change record, updates user with new email, then deletes change record if everything succeeds.

func (*Datastore) CountHostsInTargets

func (d *Datastore) CountHostsInTargets(hostIDs []uint, labelIDs []uint, now time.Time) (kolide.TargetMetrics, error)

func (*Datastore) DeleteHost

func (d *Datastore) DeleteHost(hid uint) error

func (*Datastore) DeleteInvite

func (d *Datastore) DeleteInvite(id uint) error

func (*Datastore) DeleteLabel

func (d *Datastore) DeleteLabel(name string) error

DeleteLabel deletes a kolide.Label

func (*Datastore) DeletePack

func (d *Datastore) DeletePack(name string) error

DeletePack deletes a kolide.Pack so that it won't show up in results.

func (*Datastore) DeletePasswordResetRequest

func (d *Datastore) DeletePasswordResetRequest(req *kolide.PasswordResetRequest) error

func (*Datastore) DeletePasswordResetRequestsForUser

func (d *Datastore) DeletePasswordResetRequestsForUser(userID uint) error

func (*Datastore) DeleteQueries

func (d *Datastore) DeleteQueries(ids []uint) (uint, error)

DeleteQueries deletes the existing query objects with the provided IDs. The number of deleted queries is returned along with any error.

func (*Datastore) DeleteQuery

func (d *Datastore) DeleteQuery(name string) error

DeleteQuery deletes Query identified by Query.ID.

func (*Datastore) DeleteScheduledQuery

func (d *Datastore) DeleteScheduledQuery(id uint) error

func (*Datastore) DestroyAllSessionsForUser

func (d *Datastore) DestroyAllSessionsForUser(id uint) error

func (*Datastore) DestroySession

func (d *Datastore) DestroySession(session *kolide.Session) error

func (*Datastore) DistributedQueryCampaign

func (d *Datastore) DistributedQueryCampaign(id uint) (*kolide.DistributedQueryCampaign, error)

func (*Datastore) DistributedQueryCampaignTargetIDs

func (d *Datastore) DistributedQueryCampaignTargetIDs(id uint) (hostIDs []uint, labelIDs []uint, err error)

func (*Datastore) Drop

func (d *Datastore) Drop() error

Drop removes database

func (*Datastore) EnrollHost

func (d *Datastore) EnrollHost(osqueryHostID, nodeKey, secretName string) (*kolide.Host, error)

EnrollHost enrolls a host

func (*Datastore) FindPassswordResetByID

func (d *Datastore) FindPassswordResetByID(id uint) (*kolide.PasswordResetRequest, error)

func (*Datastore) FindPassswordResetByToken

func (d *Datastore) FindPassswordResetByToken(token string) (*kolide.PasswordResetRequest, error)

func (*Datastore) FindPassswordResetByTokenAndUserID

func (d *Datastore) FindPassswordResetByTokenAndUserID(token string, id uint) (*kolide.PasswordResetRequest, error)

func (*Datastore) FindPassswordResetsByUserID

func (d *Datastore) FindPassswordResetsByUserID(id uint) ([]*kolide.PasswordResetRequest, error)

func (*Datastore) GenerateHostStatusStatistics

func (d *Datastore) GenerateHostStatusStatistics(now time.Time) (online, offline, mia, new uint, e error)

func (*Datastore) GetEnrollSecretSpec

func (d *Datastore) GetEnrollSecretSpec() (*kolide.EnrollSecretSpec, error)

func (*Datastore) GetLabelSpec

func (d *Datastore) GetLabelSpec(name string) (*kolide.LabelSpec, error)

func (*Datastore) GetLabelSpecs

func (d *Datastore) GetLabelSpecs() ([]*kolide.LabelSpec, error)

func (*Datastore) GetOptions

func (d *Datastore) GetOptions() (*kolide.OptionsSpec, error)

func (*Datastore) GetPackSpec

func (d *Datastore) GetPackSpec(name string) (spec *kolide.PackSpec, err error)

func (*Datastore) GetPackSpecs

func (d *Datastore) GetPackSpecs() (specs []*kolide.PackSpec, err error)

func (*Datastore) HealthCheck

func (d *Datastore) HealthCheck() error

HealthCheck returns an error if the MySQL backend is not healthy.

func (*Datastore) Host

func (d *Datastore) Host(id uint) (*kolide.Host, error)

func (*Datastore) HostByIdentifier

func (d *Datastore) HostByIdentifier(identifier string) (*kolide.Host, error)

func (*Datastore) HostIDsByName

func (d *Datastore) HostIDsByName(hostnames []string) ([]uint, error)

func (*Datastore) HostIDsInTargets

func (d *Datastore) HostIDsInTargets(hostIDs []uint, labelIDs []uint) ([]uint, error)

func (*Datastore) Invite

func (d *Datastore) Invite(id uint) (*kolide.Invite, error)

Invite returns Invite identified by id.

func (*Datastore) InviteByEmail

func (d *Datastore) InviteByEmail(email string) (*kolide.Invite, error)

InviteByEmail finds an Invite with a particular email, if one exists.

func (*Datastore) InviteByToken

func (d *Datastore) InviteByToken(token string) (*kolide.Invite, error)

InviteByToken finds an Invite with a particular token, if one exists.

func (*Datastore) Label

func (d *Datastore) Label(lid uint) (*kolide.Label, error)

Label returns a kolide.Label identified by lid if one exists.

func (*Datastore) LabelIDsByName

func (d *Datastore) LabelIDsByName(labels []string) ([]uint, error)

func (*Datastore) LabelQueriesForHost

func (d *Datastore) LabelQueriesForHost(host *kolide.Host, cutoff time.Time) (map[string]string, error)

func (*Datastore) ListExplicitHostsInPack

func (d *Datastore) ListExplicitHostsInPack(pid uint, opt kolide.ListOptions) ([]uint, error)

func (*Datastore) ListHosts

func (d *Datastore) ListHosts(opt kolide.HostListOptions) ([]*kolide.Host, error)

func (*Datastore) ListHostsInLabel

func (d *Datastore) ListHostsInLabel(lid uint, opt kolide.ListOptions) ([]kolide.Host, error)

ListHostsInLabel returns a list of kolide.Host that are associated with kolide.Label referened by Label ID

func (*Datastore) ListHostsInPack

func (d *Datastore) ListHostsInPack(pid uint, opt kolide.ListOptions) ([]uint, error)

func (*Datastore) ListInvites

func (d *Datastore) ListInvites(opt kolide.ListOptions) ([]*kolide.Invite, error)

ListInvites lists all invites in the Fleet database. Supply query options using the opt parameter. See kolide.ListOptions

func (*Datastore) ListLabels

func (d *Datastore) ListLabels(opt kolide.ListOptions) ([]*kolide.Label, error)

ListLabels returns all labels limited or sorted by kolide.ListOptions.

func (*Datastore) ListLabelsForHost

func (d *Datastore) ListLabelsForHost(hid uint) ([]kolide.Label, error)

ListLabelsForHost returns a list of kolide.Label for a given host id.

func (*Datastore) ListLabelsForPack

func (d *Datastore) ListLabelsForPack(pid uint) ([]*kolide.Label, error)

ListLabelsForPack will return a list of kolide.Label records associated with kolide.Pack

func (*Datastore) ListPacks

func (d *Datastore) ListPacks(opt kolide.ListOptions) ([]*kolide.Pack, error)

ListPacks returns all kolide.Pack records limited and sorted by kolide.ListOptions

func (*Datastore) ListPacksForHost

func (d *Datastore) ListPacksForHost(hid uint) ([]*kolide.Pack, error)

func (*Datastore) ListQueries

func (d *Datastore) ListQueries(opt kolide.ListOptions) ([]*kolide.Query, error)

ListQueries returns a list of queries with sort order and results limit determined by passed in kolide.ListOptions

func (*Datastore) ListScheduledQueriesInPack

func (d *Datastore) ListScheduledQueriesInPack(id uint, opts kolide.ListOptions) ([]*kolide.ScheduledQuery, error)

func (*Datastore) ListSessionsForUser

func (d *Datastore) ListSessionsForUser(id uint) ([]*kolide.Session, error)

func (*Datastore) ListUniqueHostsInLabels

func (d *Datastore) ListUniqueHostsInLabels(labels []uint) ([]kolide.Host, error)

func (*Datastore) ListUsers

func (d *Datastore) ListUsers(opt kolide.ListOptions) ([]*kolide.User, error)

ListUsers lists all users with limit, sort and offset passed in with kolide.ListOptions

func (*Datastore) ManageHostExpiryEvent

func (d *Datastore) ManageHostExpiryEvent(hostExpiryEnabled bool, hostExpiryWindow int) error

func (*Datastore) MarkHostSeen

func (d *Datastore) MarkHostSeen(host *kolide.Host, t time.Time) error

func (*Datastore) MarkSessionAccessed

func (d *Datastore) MarkSessionAccessed(session *kolide.Session) error

func (*Datastore) MigrateData

func (d *Datastore) MigrateData() error

func (*Datastore) MigrateTables

func (d *Datastore) MigrateTables() error

func (*Datastore) MigrationStatus

func (d *Datastore) MigrationStatus() (kolide.MigrationStatus, error)

func (*Datastore) Name

func (d *Datastore) Name() string

func (*Datastore) NewAppConfig

func (d *Datastore) NewAppConfig(info *kolide.AppConfig) (*kolide.AppConfig, error)

func (*Datastore) NewDistributedQueryCampaign

func (d *Datastore) NewDistributedQueryCampaign(camp *kolide.DistributedQueryCampaign) (*kolide.DistributedQueryCampaign, error)

func (*Datastore) NewDistributedQueryCampaignTarget

func (d *Datastore) NewDistributedQueryCampaignTarget(target *kolide.DistributedQueryCampaignTarget) (*kolide.DistributedQueryCampaignTarget, error)

func (*Datastore) NewHost

func (d *Datastore) NewHost(host *kolide.Host) (*kolide.Host, error)

func (*Datastore) NewInvite

func (d *Datastore) NewInvite(i *kolide.Invite) (*kolide.Invite, error)

NewInvite generates a new invitation.

func (*Datastore) NewLabel

func (d *Datastore) NewLabel(label *kolide.Label, opts ...kolide.OptionalArg) (*kolide.Label, error)

NewLabel creates a new kolide.Label

func (*Datastore) NewPack

func (d *Datastore) NewPack(pack *kolide.Pack, opts ...kolide.OptionalArg) (*kolide.Pack, error)

NewPack creates a new Pack

func (*Datastore) NewPasswordResetRequest

func (d *Datastore) NewPasswordResetRequest(req *kolide.PasswordResetRequest) (*kolide.PasswordResetRequest, error)

func (*Datastore) NewQuery

func (d *Datastore) NewQuery(query *kolide.Query, opts ...kolide.OptionalArg) (*kolide.Query, error)

NewQuery creates a New Query.

func (*Datastore) NewScheduledQuery

func (d *Datastore) NewScheduledQuery(sq *kolide.ScheduledQuery, opts ...kolide.OptionalArg) (*kolide.ScheduledQuery, error)

func (*Datastore) NewSession

func (d *Datastore) NewSession(session *kolide.Session) (*kolide.Session, error)

func (*Datastore) NewUser

func (d *Datastore) NewUser(user *kolide.User) (*kolide.User, error)

NewUser creates a new user

func (*Datastore) OptionsForPlatform

func (d *Datastore) OptionsForPlatform(platform string) (json.RawMessage, error)

func (*Datastore) Pack

func (d *Datastore) Pack(pid uint) (*kolide.Pack, error)

Pack fetch kolide.Pack with matching ID

func (*Datastore) PackByName

func (d *Datastore) PackByName(name string, opts ...kolide.OptionalArg) (*kolide.Pack, bool, error)

func (*Datastore) PendingEmailChange

func (ds *Datastore) PendingEmailChange(uid uint, newEmail, token string) error

func (*Datastore) Query

func (d *Datastore) Query(id uint) (*kolide.Query, error)

Query returns a single Query identified by id, if such exists.

func (*Datastore) QueryByName

func (d *Datastore) QueryByName(name string, opts ...kolide.OptionalArg) (*kolide.Query, error)

func (*Datastore) RecordLabelQueryExecutions

func (d *Datastore) RecordLabelQueryExecutions(host *kolide.Host, results map[uint]bool, updated time.Time) error

func (*Datastore) RemoveHostFromPack

func (d *Datastore) RemoveHostFromPack(hid, pid uint) error

RemoveHostFromPack will remove the association between a kolide.Host and a kolide.Pack

func (*Datastore) RemoveLabelFromPack

func (d *Datastore) RemoveLabelFromPack(lid, pid uint) error

RemoreLabelFromPack will remove the association between a kolide.Label and a kolide.Pack

func (*Datastore) SaveAppConfig

func (d *Datastore) SaveAppConfig(info *kolide.AppConfig) error

func (*Datastore) SaveDistributedQueryCampaign

func (d *Datastore) SaveDistributedQueryCampaign(camp *kolide.DistributedQueryCampaign) error

func (*Datastore) SaveHost

func (d *Datastore) SaveHost(host *kolide.Host) error

TODO needs test

func (*Datastore) SaveInvite

func (d *Datastore) SaveInvite(i *kolide.Invite) error

SaveInvite modifies existing Invite

func (*Datastore) SaveLabel

func (d *Datastore) SaveLabel(label *kolide.Label) (*kolide.Label, error)

func (*Datastore) SavePack

func (d *Datastore) SavePack(pack *kolide.Pack) error

SavePack stores changes to pack

func (*Datastore) SavePasswordResetRequest

func (d *Datastore) SavePasswordResetRequest(req *kolide.PasswordResetRequest) error

func (*Datastore) SaveQuery

func (d *Datastore) SaveQuery(q *kolide.Query) error

SaveQuery saves changes to a Query.

func (*Datastore) SaveScheduledQuery

func (d *Datastore) SaveScheduledQuery(sq *kolide.ScheduledQuery) (*kolide.ScheduledQuery, error)

func (*Datastore) SaveUser

func (d *Datastore) SaveUser(user *kolide.User) error

func (*Datastore) ScheduledQuery

func (d *Datastore) ScheduledQuery(id uint) (*kolide.ScheduledQuery, error)

func (*Datastore) SearchHosts

func (d *Datastore) SearchHosts(query string, omit ...uint) ([]*kolide.Host, error)

SearchHosts find hosts by query containing an IP address, a host name or UUID. Optionally pass a list of IDs to omit from the search

func (*Datastore) SearchLabels

func (d *Datastore) SearchLabels(query string, omit ...uint) ([]kolide.Label, error)

SearchLabels performs wildcard searches on kolide.Label name

func (*Datastore) SessionByID

func (d *Datastore) SessionByID(id uint) (*kolide.Session, error)

func (*Datastore) SessionByKey

func (d *Datastore) SessionByKey(key string) (*kolide.Session, error)

func (*Datastore) User

func (d *Datastore) User(username string) (*kolide.User, error)

User retrieves a user by name

func (*Datastore) UserByEmail

func (d *Datastore) UserByEmail(email string) (*kolide.User, error)

func (*Datastore) UserByID

func (d *Datastore) UserByID(id uint) (*kolide.User, error)

func (*Datastore) VerifyEnrollSecret

func (d *Datastore) VerifyEnrollSecret(secret string) (string, error)

Directories

Path Synopsis
migrations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL