Apply consistent naming conventions across server files (#310)

This commit is contained in:
Zachary Wasserman 2016-10-14 08:59:27 -07:00 committed by GitHub
parent 106eae4515
commit 4b88ae6e2c
41 changed files with 94 additions and 94 deletions

View file

@ -27,7 +27,7 @@ func testLabels(t *testing.T, db kolide.Datastore) {
assert.Empty(t, queries)
// No labels should match
labels, err := db.LabelsForHost(host.ID)
labels, err := db.ListLabelsForHost(host.ID)
assert.Nil(t, err)
assert.Empty(t, labels)
@ -113,7 +113,7 @@ func testLabels(t *testing.T, db kolide.Datastore) {
assert.Equal(t, expectQueries, queries)
// No labels should match with no results yet
labels, err = db.LabelsForHost(host.ID)
labels, err = db.ListLabelsForHost(host.ID)
assert.Nil(t, err)
assert.Empty(t, labels)
@ -146,7 +146,7 @@ func testLabels(t *testing.T, db kolide.Datastore) {
assert.Equal(t, expectQueries, queries)
// Now the two matching labels should be returned
labels, err = db.LabelsForHost(host.ID)
labels, err = db.ListLabelsForHost(host.ID)
assert.Nil(t, err)
if assert.Len(t, labels, 2) {
labelNames := []string{labels[0].Name, labels[1].Name}
@ -164,7 +164,7 @@ func testLabels(t *testing.T, db kolide.Datastore) {
// There should still be no labels returned for a host that never
// executed any label queries
labels, err = db.LabelsForHost(hosts[0].ID)
labels, err = db.ListLabelsForHost(hosts[0].ID)
assert.Nil(t, err)
assert.Empty(t, labels)
}
@ -200,7 +200,7 @@ func testManagingLabelsOnPacks(t *testing.T, ds kolide.Datastore) {
err = ds.AddLabelToPack(mysqlLabel.ID, monitoringPack.ID)
assert.Nil(t, err)
labels, err := ds.GetLabelsForPack(monitoringPack)
labels, err := ds.ListLabelsForPack(monitoringPack)
assert.Nil(t, err)
assert.Len(t, labels, 1)
assert.Equal(t, "MySQL Monitoring", labels[0].Name)
@ -215,7 +215,7 @@ func testManagingLabelsOnPacks(t *testing.T, ds kolide.Datastore) {
err = ds.AddLabelToPack(osqueryLabel.ID, monitoringPack.ID)
assert.Nil(t, err)
labels, err = ds.GetLabelsForPack(monitoringPack)
labels, err = ds.ListLabelsForPack(monitoringPack)
assert.Nil(t, err)
assert.Len(t, labels, 2)
}

View file

@ -52,14 +52,14 @@ func testAddAndRemoveQueryFromPack(t *testing.T, ds kolide.Datastore) {
err = ds.AddQueryToPack(q2.ID, pack.ID)
assert.Nil(t, err)
queries, err := ds.GetQueriesInPack(pack)
queries, err := ds.ListQueriesInPack(pack)
assert.Nil(t, err)
assert.Len(t, queries, 2)
err = ds.RemoveQueryFromPack(q1, pack)
assert.Nil(t, err)
queries, err = ds.GetQueriesInPack(pack)
queries, err = ds.ListQueriesInPack(pack)
assert.Nil(t, err)
assert.Len(t, queries, 1)
}

View file

@ -100,7 +100,7 @@ func (orm gormDB) Host(id uint) (*kolide.Host, error) {
return host, nil
}
func (orm gormDB) Hosts(opt kolide.ListOptions) ([]*kolide.Host, error) {
func (orm gormDB) ListHosts(opt kolide.ListOptions) ([]*kolide.Host, error) {
var hosts []*kolide.Host
err := orm.applyListOptions(opt).Find(&hosts).Error
if err != nil {

View file

@ -21,7 +21,7 @@ func (orm gormDB) InviteByEmail(email string) (*kolide.Invite, error) {
return invite, nil
}
func (orm gormDB) Invites(opt kolide.ListOptions) ([]*kolide.Invite, error) {
func (orm gormDB) ListInvites(opt kolide.ListOptions) ([]*kolide.Invite, error) {
var invites []*kolide.Invite
err := orm.applyListOptions(opt).Find(&invites).Error
if err != nil {

View file

@ -54,7 +54,7 @@ func (orm gormDB) Label(lid uint) (*kolide.Label, error) {
return label, nil
}
func (orm gormDB) Labels(opt kolide.ListOptions) ([]*kolide.Label, error) {
func (orm gormDB) ListLabels(opt kolide.ListOptions) ([]*kolide.Label, error) {
var labels []*kolide.Label
err := orm.applyListOptions(opt).Find(&labels).Error
return labels, err
@ -149,7 +149,7 @@ matches = VALUES(matches)
return nil
}
func (orm gormDB) LabelsForHost(hid uint) ([]kolide.Label, error) {
func (orm gormDB) ListLabelsForHost(hid uint) ([]kolide.Label, error) {
results := []kolide.Label{}
err := orm.DB.Raw(`
SELECT labels.* from labels, label_query_executions lqe

View file

@ -50,7 +50,7 @@ func (orm gormDB) Pack(pid uint) (*kolide.Pack, error) {
return pack, nil
}
func (orm gormDB) Packs(opt kolide.ListOptions) ([]*kolide.Pack, error) {
func (orm gormDB) ListPacks(opt kolide.ListOptions) ([]*kolide.Pack, error) {
var packs []*kolide.Pack
err := orm.applyListOptions(opt).Find(&packs).Error
return packs, err
@ -64,7 +64,7 @@ func (orm gormDB) AddQueryToPack(qid uint, pid uint) error {
return orm.DB.Create(pq).Error
}
func (orm gormDB) GetQueriesInPack(pack *kolide.Pack) ([]*kolide.Query, error) {
func (orm gormDB) ListQueriesInPack(pack *kolide.Pack) ([]*kolide.Query, error) {
var queries []*kolide.Query
if pack == nil {
return nil, errors.New(
@ -146,18 +146,18 @@ func (orm gormDB) AddLabelToPack(lid uint, pid uint) error {
return orm.DB.Create(pt).Error
}
func (orm gormDB) ActivePacksForHost(hid uint) ([]*kolide.Pack, error) {
func (orm gormDB) ListPacksForHost(hid uint) ([]*kolide.Pack, error) {
packs := []*kolide.Pack{}
// we will need to give some subset of packs to this host based on the
// labels which this host is known to belong to
allPacks, err := orm.Packs(kolide.ListOptions{})
allPacks, err := orm.ListPacks(kolide.ListOptions{})
if err != nil {
return nil, err
}
// pull the labels that this host belongs to
labels, err := orm.LabelsForHost(hid)
labels, err := orm.ListLabelsForHost(hid)
if err != nil {
return nil, err
}
@ -172,7 +172,7 @@ func (orm gormDB) ActivePacksForHost(hid uint) ([]*kolide.Pack, error) {
for _, pack := range allPacks {
// for each pack, we must know what labels have been assigned to that
// pack
labelsForPack, err := orm.GetLabelsForPack(pack)
labelsForPack, err := orm.ListLabelsForPack(pack)
if err != nil {
return nil, err
}
@ -190,7 +190,7 @@ func (orm gormDB) ActivePacksForHost(hid uint) ([]*kolide.Pack, error) {
return packs, nil
}
func (orm gormDB) GetLabelsForPack(pack *kolide.Pack) ([]*kolide.Label, error) {
func (orm gormDB) ListLabelsForPack(pack *kolide.Pack) ([]*kolide.Label, error) {
if pack == nil {
return nil, errors.New(
"error getting labels for pack",

View file

@ -50,7 +50,7 @@ func (orm gormDB) Query(id uint) (*kolide.Query, error) {
return query, nil
}
func (orm gormDB) Queries(opt kolide.ListOptions) ([]*kolide.Query, error) {
func (orm gormDB) ListQueries(opt kolide.ListOptions) ([]*kolide.Query, error) {
var queries []*kolide.Query
err := orm.applyListOptions(opt).Find(&queries).Error
return queries, err

View file

@ -7,7 +7,7 @@ import (
"github.com/kolide/kolide-ose/server/kolide"
)
func (orm gormDB) FindSessionByID(id uint) (*kolide.Session, error) {
func (orm gormDB) SessionByID(id uint) (*kolide.Session, error) {
session := &kolide.Session{
ID: id,
}
@ -26,7 +26,7 @@ func (orm gormDB) FindSessionByID(id uint) (*kolide.Session, error) {
}
func (orm gormDB) FindSessionByKey(key string) (*kolide.Session, error) {
func (orm gormDB) SessionByKey(key string) (*kolide.Session, error) {
session := &kolide.Session{
Key: key,
}
@ -44,7 +44,7 @@ func (orm gormDB) FindSessionByKey(key string) (*kolide.Session, error) {
return session, nil
}
func (orm gormDB) FindAllSessionsForUser(id uint) ([]*kolide.Session, error) {
func (orm gormDB) ListSessionsForUser(id uint) ([]*kolide.Session, error) {
var sessions []*kolide.Session
err := orm.DB.Where("user_id = ?", id).Find(&sessions).Error
return sessions, err

View file

@ -23,7 +23,7 @@ func (orm gormDB) User(username string) (*kolide.User, error) {
return user, nil
}
func (orm gormDB) Users(opt kolide.ListOptions) ([]*kolide.User, error) {
func (orm gormDB) ListUsers(opt kolide.ListOptions) ([]*kolide.User, error) {
var users []*kolide.User
err := orm.applyListOptions(opt).Find(&users).Error
if err != nil {

View file

@ -60,7 +60,7 @@ func (orm *inmem) Host(id uint) (*kolide.Host, error) {
return host, nil
}
func (orm *inmem) Hosts(opt kolide.ListOptions) ([]*kolide.Host, error) {
func (orm *inmem) ListHosts(opt kolide.ListOptions) ([]*kolide.Host, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()

View file

@ -23,7 +23,7 @@ func (orm *inmem) NewInvite(invite *kolide.Invite) (*kolide.Invite, error) {
}
// Invites lists all invites in the datastore.
func (orm *inmem) Invites(opt kolide.ListOptions) ([]*kolide.Invite, error) {
func (orm *inmem) ListInvites(opt kolide.ListOptions) ([]*kolide.Invite, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()

View file

@ -26,7 +26,7 @@ func (orm *inmem) NewLabel(label *kolide.Label) (*kolide.Label, error) {
return &newLabel, nil
}
func (orm *inmem) LabelsForHost(hid uint) ([]kolide.Label, error) {
func (orm *inmem) ListLabelsForHost(hid uint) ([]kolide.Label, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()

View file

@ -60,7 +60,7 @@ func (orm *inmem) Pack(id uint) (*kolide.Pack, error) {
return pack, nil
}
func (orm *inmem) Packs(opt kolide.ListOptions) ([]*kolide.Pack, error) {
func (orm *inmem) ListPacks(opt kolide.ListOptions) ([]*kolide.Pack, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()

View file

@ -60,7 +60,7 @@ func (orm *inmem) Query(id uint) (*kolide.Query, error) {
return query, nil
}
func (orm *inmem) Queries(opt kolide.ListOptions) ([]*kolide.Query, error) {
func (orm *inmem) ListQueries(opt kolide.ListOptions) ([]*kolide.Query, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()

View file

@ -6,7 +6,7 @@ import (
"github.com/kolide/kolide-ose/server/kolide"
)
func (orm *inmem) FindSessionByKey(key string) (*kolide.Session, error) {
func (orm *inmem) SessionByKey(key string) (*kolide.Session, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()
@ -18,7 +18,7 @@ func (orm *inmem) FindSessionByKey(key string) (*kolide.Session, error) {
return nil, ErrNotFound
}
func (orm *inmem) FindSessionByID(id uint) (*kolide.Session, error) {
func (orm *inmem) SessionByID(id uint) (*kolide.Session, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()
@ -28,7 +28,7 @@ func (orm *inmem) FindSessionByID(id uint) (*kolide.Session, error) {
return nil, ErrNotFound
}
func (orm *inmem) FindAllSessionsForUser(id uint) ([]*kolide.Session, error) {
func (orm *inmem) ListSessionsForUser(id uint) ([]*kolide.Session, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()

View file

@ -35,7 +35,7 @@ func (orm *inmem) User(username string) (*kolide.User, error) {
return nil, ErrNotFound
}
func (orm *inmem) Users(opt kolide.ListOptions) ([]*kolide.User, error) {
func (orm *inmem) ListUsers(opt kolide.ListOptions) ([]*kolide.User, error) {
orm.mtx.Lock()
defer orm.mtx.Unlock()

View file

@ -11,7 +11,7 @@ type HostStore interface {
SaveHost(host *Host) error
DeleteHost(host *Host) error
Host(id uint) (*Host, error)
Hosts(opt ListOptions) ([]*Host, error)
ListHosts(opt ListOptions) ([]*Host, error)
EnrollHost(uuid, hostname, ip, platform string, nodeKeySize int) (*Host, error)
AuthenticateHost(nodeKey string) (*Host, error)
MarkHostSeen(host *Host, t time.Time) error

View file

@ -15,7 +15,7 @@ type InviteStore interface {
NewInvite(i *Invite) (*Invite, error)
// Invites lists all invites in the datastore.
Invites(opt ListOptions) ([]*Invite, error)
ListInvites(opt ListOptions) ([]*Invite, error)
// Invite retrieves an invite by it's ID.
Invite(id uint) (*Invite, error)

View file

@ -12,7 +12,7 @@ type LabelStore interface {
SaveLabel(Label *Label) error
DeleteLabel(lid uint) error
Label(lid uint) (*Label, error)
Labels(opt ListOptions) ([]*Label, error)
ListLabels(opt ListOptions) ([]*Label, error)
// LabelQueriesForHost returns the label queries that should be executed
// for the given host. The cutoff is the minimum timestamp a query
@ -28,7 +28,7 @@ type LabelStore interface {
RecordLabelQueryExecutions(host *Host, results map[string]bool, t time.Time) error
// LabelsForHost returns the labels that the given host is in.
LabelsForHost(hid uint) ([]Label, error)
ListLabelsForHost(hid uint) ([]Label, error)
}
type LabelService interface {

View file

@ -12,20 +12,20 @@ type PackStore interface {
SavePack(pack *Pack) error
DeletePack(pid uint) error
Pack(pid uint) (*Pack, error)
Packs(opt ListOptions) ([]*Pack, error)
ListPacks(opt ListOptions) ([]*Pack, error)
// Modifying the queries in packs
AddQueryToPack(qid uint, pid uint) error
GetQueriesInPack(pack *Pack) ([]*Query, error)
ListQueriesInPack(pack *Pack) ([]*Query, error)
RemoveQueryFromPack(query *Query, pack *Pack) error
// Modifying the labels for packs
AddLabelToPack(lid uint, pid uint) error
GetLabelsForPack(pack *Pack) ([]*Label, error)
ListLabelsForPack(pack *Pack) ([]*Label, error)
RemoveLabelFromPack(label *Label, pack *Pack) error
// Packs from the host's perspective
ActivePacksForHost(hid uint) ([]*Pack, error)
ListPacksForHost(hid uint) ([]*Pack, error)
}
type PackService interface {
@ -36,11 +36,11 @@ type PackService interface {
DeletePack(ctx context.Context, id uint) error
AddQueryToPack(ctx context.Context, qid, pid uint) error
GetQueriesInPack(ctx context.Context, id uint) ([]*Query, error)
ListQueriesInPack(ctx context.Context, id uint) ([]*Query, error)
RemoveQueryFromPack(ctx context.Context, qid, pid uint) error
AddLabelToPack(ctx context.Context, lid, pid uint) error
GetLabelsForPack(ctx context.Context, pid uint) ([]*Label, error)
ListLabelsForPack(ctx context.Context, pid uint) ([]*Label, error)
RemoveLabelFromPack(ctx context.Context, lid, pid uint) error
}

View file

@ -12,7 +12,7 @@ type QueryStore interface {
SaveQuery(query *Query) error
DeleteQuery(query *Query) error
Query(id uint) (*Query, error)
Queries(opt ListOptions) ([]*Query, error)
ListQueries(opt ListOptions) ([]*Query, error)
}
type QueryService interface {

View file

@ -33,14 +33,14 @@ var (
type SessionStore interface {
// Given a session key, find and return a session object or an error if one
// could not be found for the given key
FindSessionByKey(key string) (*Session, error)
SessionByKey(key string) (*Session, error)
// Given a session id, find and return a session object or an error if one
// could not be found for the given id
FindSessionByID(id uint) (*Session, error)
SessionByID(id uint) (*Session, error)
// Find all of the active sessions for a given user
FindAllSessionsForUser(id uint) ([]*Session, error)
ListSessionsForUser(id uint) ([]*Session, error)
// Store a new session struct
NewSession(session *Session) (*Session, error)

View file

@ -14,7 +14,7 @@ import (
type UserStore interface {
NewUser(user *User) (*User, error)
User(username string) (*User, error)
Users(opt ListOptions) ([]*User, error)
ListUsers(opt ListOptions) ([]*User, error)
UserByEmail(email string) (*User, error)
UserByID(id uint) (*User, error)
SaveUser(user *User) error

View file

@ -185,7 +185,7 @@ func (r getQueriesInPackResponse) error() error { return r.Err }
func makeGetQueriesInPackEndpoint(svc kolide.Service) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(getQueriesInPackRequest)
queries, err := svc.GetQueriesInPack(ctx, req.ID)
queries, err := svc.ListQueriesInPack(ctx, req.ID)
if err != nil {
return getQueriesInPackResponse{Err: err}, nil
}
@ -268,7 +268,7 @@ func (r getLabelsForPackResponse) error() error { return r.Err }
func makeGetLabelsForPackEndpoint(svc kolide.Service) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(getLabelsForPackRequest)
labels, err := svc.GetLabelsForPack(ctx, req.PackID)
labels, err := svc.ListLabelsForPack(ctx, req.PackID)
if err != nil {
return getLabelsForPackResponse{Err: err}, nil
}

View file

@ -112,7 +112,7 @@ func TestLogin(t *testing.T) {
assert.Equal(t, tt.username, jsn.User.Username)
// ensure that a session was created for our test user and stored
sessions, err := ds.FindAllSessionsForUser(testUser.ID)
sessions, err := ds.ListSessionsForUser(testUser.ID)
assert.Nil(t, err)
assert.Len(t, sessions, 1)
@ -131,7 +131,7 @@ func TestLogin(t *testing.T) {
assert.Nil(t, err)
// ensure that our user's session was deleted from the store
sessions, err = ds.FindAllSessionsForUser(testUser.ID)
sessions, err = ds.ListSessionsForUser(testUser.ID)
assert.Len(t, sessions, 0)
}
}

View file

@ -51,7 +51,7 @@ func (mw loggingMiddleware) DeleteInvite(ctx context.Context, id uint) error {
return err
}
func (mw loggingMiddleware) Invites(ctx context.Context) ([]*kolide.Invite, error) {
func (mw loggingMiddleware) ListInvites(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Invite, error) {
var (
invites []*kolide.Invite
err error
@ -68,7 +68,7 @@ func (mw loggingMiddleware) Invites(ctx context.Context) ([]*kolide.Invite, erro
"took", time.Since(begin),
)
}(time.Now())
invites, err = mw.Service.ListInvites(ctx, kolide.ListOptions{})
invites, err = mw.Service.ListInvites(ctx, opt)
return invites, err
}

View file

@ -8,7 +8,7 @@ import (
)
func (svc service) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) {
return svc.ds.Hosts(opt)
return svc.ds.ListHosts(opt)
}
func (svc service) GetHost(ctx context.Context, id uint) (*kolide.Host, error) {

View file

@ -71,7 +71,7 @@ func TestDeleteHost(t *testing.T) {
err = svc.DeleteHost(ctx, host.ID)
assert.Nil(t, err)
hosts, err := ds.Hosts(kolide.ListOptions{})
hosts, err := ds.ListHosts(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, hosts, 0)

View file

@ -62,7 +62,7 @@ func (svc service) InviteNewUser(ctx context.Context, payload kolide.InvitePaylo
}
func (svc service) ListInvites(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Invite, error) {
return svc.ds.Invites(opt)
return svc.ds.ListInvites(opt)
}
func (svc service) VerifyInvite(ctx context.Context, email, token string) error {

View file

@ -6,7 +6,7 @@ import (
)
func (svc service) ListLabels(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Label, error) {
return svc.ds.Labels(opt)
return svc.ds.ListLabels(opt)
}
func (svc service) GetLabel(ctx context.Context, id uint) (*kolide.Label, error) {

View file

@ -75,7 +75,7 @@ func TestNewLabel(t *testing.T) {
assert.Nil(t, err)
labels, err := ds.Labels(kolide.ListOptions{})
labels, err := ds.ListLabels(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, labels, 1)
assert.Equal(t, "foo", labels[0].Name)
@ -127,7 +127,7 @@ func TestDeleteLabel(t *testing.T) {
err = svc.DeleteLabel(ctx, label.ID)
assert.Nil(t, err)
labels, err := ds.Labels(kolide.ListOptions{})
labels, err := ds.ListLabels(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, labels, 0)
}

View file

@ -71,14 +71,14 @@ func (svc service) GetClientConfig(ctx context.Context) (*kolide.OsqueryConfig,
Packs: kolide.Packs{},
}
packs, err := svc.ds.ActivePacksForHost(host.ID)
packs, err := svc.ds.ListPacksForHost(host.ID)
if err != nil {
return nil, osqueryError{message: "database error: " + err.Error()}
}
for _, pack := range packs {
// first, we must figure out what queries are in this pack
queries, err := svc.ds.GetQueriesInPack(pack)
queries, err := svc.ds.ListQueriesInPack(pack)
if err != nil {
return nil, osqueryError{message: "database error: " + err.Error()}
}

View file

@ -26,7 +26,7 @@ func TestEnrollAgent(t *testing.T) {
ctx := context.Background()
hosts, err := ds.Hosts(kolide.ListOptions{})
hosts, err := ds.ListHosts(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, hosts, 0)
@ -34,7 +34,7 @@ func TestEnrollAgent(t *testing.T) {
assert.Nil(t, err)
assert.NotEmpty(t, nodeKey)
hosts, err = ds.Hosts(kolide.ListOptions{})
hosts, err = ds.ListHosts(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, hosts, 1)
}
@ -48,7 +48,7 @@ func TestEnrollAgentIncorrectEnrollSecret(t *testing.T) {
ctx := context.Background()
hosts, err := ds.Hosts(kolide.ListOptions{})
hosts, err := ds.ListHosts(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, hosts, 0)
@ -56,7 +56,7 @@ func TestEnrollAgentIncorrectEnrollSecret(t *testing.T) {
assert.NotNil(t, err)
assert.Empty(t, nodeKey)
hosts, err = ds.Hosts(kolide.ListOptions{})
hosts, err = ds.ListHosts(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, hosts, 0)
}
@ -75,7 +75,7 @@ func TestSubmitStatusLogs(t *testing.T) {
_, err = svc.EnrollAgent(ctx, "", "host123")
assert.Nil(t, err)
hosts, err := ds.Hosts(kolide.ListOptions{})
hosts, err := ds.ListHosts(kolide.ListOptions{})
require.Nil(t, err)
require.Len(t, hosts, 1)
host := hosts[0]
@ -147,7 +147,7 @@ func TestSubmitResultLogs(t *testing.T) {
_, err = svc.EnrollAgent(ctx, "", "host123")
assert.Nil(t, err)
hosts, err := ds.Hosts(kolide.ListOptions{})
hosts, err := ds.ListHosts(kolide.ListOptions{})
require.Nil(t, err)
require.Len(t, hosts, 1)
host := hosts[0]
@ -248,7 +248,7 @@ func TestLabelQueries(t *testing.T) {
_, err = svc.EnrollAgent(ctx, "", "host123")
assert.Nil(t, err)
hosts, err := ds.Hosts(kolide.ListOptions{})
hosts, err := ds.ListHosts(kolide.ListOptions{})
require.Nil(t, err)
require.Len(t, hosts, 1)
host := hosts[0]
@ -348,7 +348,7 @@ func TestLabelQueries(t *testing.T) {
assert.Nil(t, err)
// Verify that labels are set appropriately
hostLabels, err := ds.LabelsForHost(host.ID)
hostLabels, err := ds.ListLabelsForHost(host.ID)
assert.Len(t, hostLabels, 1)
assert.Equal(t, "label1", hostLabels[0].Name)
@ -390,7 +390,7 @@ func TestLabelQueries(t *testing.T) {
assert.Equal(t, expectQueries, queries)
// Verify that labels are set appropriately
hostLabels, err = ds.LabelsForHost(host.ID)
hostLabels, err = ds.ListLabelsForHost(host.ID)
assert.Len(t, hostLabels, 2)
expectLabelNames := map[string]bool{"label1": true, "label2": true}
for _, label := range hostLabels {
@ -410,14 +410,14 @@ func TestGetClientConfig(t *testing.T) {
ctx := context.Background()
hosts, err := ds.Hosts(kolide.ListOptions{})
hosts, err := ds.ListHosts(kolide.ListOptions{})
require.Nil(t, err)
require.Len(t, hosts, 0)
_, err = svc.EnrollAgent(ctx, "", "user.local")
assert.Nil(t, err)
hosts, err = ds.Hosts(kolide.ListOptions{})
hosts, err = ds.ListHosts(kolide.ListOptions{})
require.Nil(t, err)
require.Len(t, hosts, 1)
host := hosts[0]

View file

@ -6,7 +6,7 @@ import (
)
func (svc service) ListPacks(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Pack, error) {
return svc.ds.Packs(opt)
return svc.ds.ListPacks(opt)
}
func (svc service) GetPack(ctx context.Context, id uint) (*kolide.Pack, error) {
@ -61,13 +61,13 @@ func (svc service) AddQueryToPack(ctx context.Context, qid, pid uint) error {
return svc.ds.AddQueryToPack(qid, pid)
}
func (svc service) GetQueriesInPack(ctx context.Context, id uint) ([]*kolide.Query, error) {
func (svc service) ListQueriesInPack(ctx context.Context, id uint) ([]*kolide.Query, error) {
pack, err := svc.ds.Pack(id)
if err != nil {
return nil, err
}
queries, err := svc.ds.GetQueriesInPack(pack)
queries, err := svc.ds.ListQueriesInPack(pack)
if err != nil {
return nil, err
}
@ -97,13 +97,13 @@ func (svc service) AddLabelToPack(ctx context.Context, lid, pid uint) error {
return svc.ds.AddLabelToPack(lid, pid)
}
func (svc service) GetLabelsForPack(ctx context.Context, pid uint) ([]*kolide.Label, error) {
func (svc service) ListLabelsForPack(ctx context.Context, pid uint) ([]*kolide.Label, error) {
pack, err := svc.ds.Pack(pid)
if err != nil {
return nil, err
}
labels, err := svc.ds.GetLabelsForPack(pack)
labels, err := svc.ds.ListLabelsForPack(pack)
if err != nil {
return nil, err
}

View file

@ -70,7 +70,7 @@ func TestNewPack(t *testing.T) {
assert.Nil(t, err)
queries, err := ds.Packs(kolide.ListOptions{})
queries, err := ds.ListPacks(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, queries, 1)
}
@ -120,7 +120,7 @@ func TestDeletePack(t *testing.T) {
err = svc.DeletePack(ctx, pack.ID)
assert.Nil(t, err)
queries, err := ds.Packs(kolide.ListOptions{})
queries, err := ds.ListPacks(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, queries, 0)
@ -150,14 +150,14 @@ func TestAddQueryToPack(t *testing.T) {
assert.Nil(t, err)
assert.NotZero(t, query.ID)
queries, err := ds.GetQueriesInPack(pack)
queries, err := ds.ListQueriesInPack(pack)
assert.Nil(t, err)
assert.Len(t, queries, 0)
err = svc.AddQueryToPack(ctx, query.ID, pack.ID)
assert.Nil(t, err)
queries, err = ds.GetQueriesInPack(pack)
queries, err = ds.ListQueriesInPack(pack)
assert.Nil(t, err)
assert.Len(t, queries, 1)
}
@ -189,7 +189,7 @@ func TestGetQueriesInPack(t *testing.T) {
err = ds.AddQueryToPack(query.ID, pack.ID)
assert.Nil(t, err)
queries, err := svc.GetQueriesInPack(ctx, pack.ID)
queries, err := svc.ListQueriesInPack(ctx, pack.ID)
assert.Nil(t, err)
assert.Len(t, queries, 1)
}
@ -221,14 +221,14 @@ func TestRemoveQueryFromPack(t *testing.T) {
err = ds.AddQueryToPack(query.ID, pack.ID)
assert.Nil(t, err)
queries, err := ds.GetQueriesInPack(pack)
queries, err := ds.ListQueriesInPack(pack)
assert.Nil(t, err)
assert.Len(t, queries, 1)
err = svc.RemoveQueryFromPack(ctx, query.ID, pack.ID)
assert.Nil(t, err)
queries, err = ds.GetQueriesInPack(pack)
queries, err = ds.ListQueriesInPack(pack)
assert.Nil(t, err)
assert.Len(t, queries, 0)
}

View file

@ -6,7 +6,7 @@ import (
)
func (svc service) ListQueries(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Query, error) {
return svc.ds.Queries(opt)
return svc.ds.ListQueries(opt)
}
func (svc service) GetQuery(ctx context.Context, id uint) (*kolide.Query, error) {

View file

@ -74,7 +74,7 @@ func TestNewQuery(t *testing.T) {
assert.Nil(t, err)
queries, err := ds.Queries(kolide.ListOptions{})
queries, err := ds.ListQueries(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, queries, 1)
}
@ -126,7 +126,7 @@ func TestDeleteQuery(t *testing.T) {
err = svc.DeleteQuery(ctx, query.ID)
assert.Nil(t, err)
queries, err := ds.Queries(kolide.ListOptions{})
queries, err := ds.ListQueries(kolide.ListOptions{})
assert.Nil(t, err)
assert.Len(t, queries, 0)

View file

@ -81,7 +81,7 @@ func (svc service) DestroySession(ctx context.Context) error {
return errNoContext
}
session, err := svc.ds.FindSessionByID(vc.SessionID())
session, err := svc.ds.SessionByID(vc.SessionID())
if err != nil {
return err
}
@ -92,7 +92,7 @@ func (svc service) DestroySession(ctx context.Context) error {
func (svc service) GetInfoAboutSessionsForUser(ctx context.Context, id uint) ([]*kolide.Session, error) {
var validatedSessions []*kolide.Session
sessions, err := svc.ds.FindAllSessionsForUser(id)
sessions, err := svc.ds.ListSessionsForUser(id)
if err != nil {
return validatedSessions, err
}
@ -111,7 +111,7 @@ func (svc service) DeleteSessionsForUser(ctx context.Context, id uint) error {
}
func (svc service) GetInfoAboutSession(ctx context.Context, id uint) (*kolide.Session, error) {
session, err := svc.ds.FindSessionByID(id)
session, err := svc.ds.SessionByID(id)
if err != nil {
return nil, err
}
@ -125,7 +125,7 @@ func (svc service) GetInfoAboutSession(ctx context.Context, id uint) (*kolide.Se
}
func (svc service) GetSessionByKey(ctx context.Context, key string) (*kolide.Session, error) {
session, err := svc.ds.FindSessionByKey(key)
session, err := svc.ds.SessionByKey(key)
if err != nil {
return nil, err
}
@ -139,7 +139,7 @@ func (svc service) GetSessionByKey(ctx context.Context, key string) (*kolide.Ses
}
func (svc service) DeleteSession(ctx context.Context, id uint) error {
session, err := svc.ds.FindSessionByID(id)
session, err := svc.ds.SessionByID(id)
if err != nil {
return err
}

View file

@ -116,7 +116,7 @@ func (svc service) AuthenticatedUser(ctx context.Context) (*kolide.User, error)
}
func (svc service) ListUsers(ctx context.Context, opt kolide.ListOptions) ([]*kolide.User, error) {
return svc.ds.Users(opt)
return svc.ds.ListUsers(opt)
}
func (svc service) ResetPassword(ctx context.Context, token, password string) error {