mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
e59714242e
- Refactor configuration for logging to use separate plugins - Move existing filesystem logging to filesystem plugin - Create new AWS firehose plugin - Update documentation around logging
73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
// Package service holds the implementation of the kolide service interface and the HTTP endpoints
|
|
// for the API
|
|
package service
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/WatchBeam/clock"
|
|
kitlog "github.com/go-kit/kit/log"
|
|
"github.com/kolide/fleet/server/config"
|
|
"github.com/kolide/fleet/server/kolide"
|
|
"github.com/kolide/fleet/server/logging"
|
|
"github.com/kolide/fleet/server/sso"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// NewService creates a new service from the config struct
|
|
func NewService(ds kolide.Datastore, resultStore kolide.QueryResultStore,
|
|
logger kitlog.Logger, config config.KolideConfig, mailService kolide.MailService,
|
|
c clock.Clock, sso sso.SessionStore) (kolide.Service, error) {
|
|
var svc kolide.Service
|
|
|
|
osqueryLogger, err := logging.New(config, logger)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "initializing osquery logging")
|
|
}
|
|
|
|
svc = service{
|
|
ds: ds,
|
|
resultStore: resultStore,
|
|
logger: logger,
|
|
config: config,
|
|
clock: c,
|
|
osqueryLogWriter: osqueryLogger,
|
|
mailService: mailService,
|
|
ssoSessionStore: sso,
|
|
metaDataClient: &http.Client{
|
|
Timeout: 5 * time.Second,
|
|
},
|
|
}
|
|
svc = validationMiddleware{svc, ds, sso}
|
|
return svc, nil
|
|
}
|
|
|
|
type service struct {
|
|
ds kolide.Datastore
|
|
resultStore kolide.QueryResultStore
|
|
logger kitlog.Logger
|
|
config config.KolideConfig
|
|
clock clock.Clock
|
|
|
|
osqueryLogWriter *logging.OsqueryLogger
|
|
|
|
mailService kolide.MailService
|
|
ssoSessionStore sso.SessionStore
|
|
metaDataClient *http.Client
|
|
}
|
|
|
|
func (s service) SendEmail(mail kolide.Email) error {
|
|
return s.mailService.SendEmail(mail)
|
|
}
|
|
|
|
func (s service) Clock() clock.Clock {
|
|
return s.clock
|
|
}
|
|
|
|
type validationMiddleware struct {
|
|
kolide.Service
|
|
ds kolide.Datastore
|
|
ssoSessionStore sso.SessionStore
|
|
}
|