2019-08-13 16:42:58 +00:00
|
|
|
package service
|
|
|
|
|
2020-01-14 00:53:04 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-08-10 02:30:17 +00:00
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
2020-01-14 00:53:04 +00:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
2019-08-13 16:42:58 +00:00
|
|
|
|
2021-06-01 00:07:51 +00:00
|
|
|
func (svc *Service) StatusResultStore(ctx context.Context) error {
|
2021-08-10 02:30:17 +00:00
|
|
|
if err := svc.authz.Authorize(ctx, &fleet.AppConfig{}, fleet.ActionRead); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-08-13 16:42:58 +00:00
|
|
|
return svc.resultStore.HealthCheck()
|
|
|
|
}
|
2020-01-14 00:53:04 +00:00
|
|
|
|
2021-06-01 00:07:51 +00:00
|
|
|
func (svc *Service) StatusLiveQuery(ctx context.Context) error {
|
2021-08-10 02:30:17 +00:00
|
|
|
if err := svc.authz.Authorize(ctx, &fleet.AppConfig{}, fleet.ActionRead); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg, err := svc.ds.AppConfig()
|
2020-01-14 00:53:04 +00:00
|
|
|
if err != nil {
|
2021-08-10 02:30:17 +00:00
|
|
|
return errors.Wrap(err, "retrieve app config")
|
2020-01-14 00:53:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.LiveQueryDisabled {
|
|
|
|
return errors.New("disabled by administrator")
|
|
|
|
}
|
|
|
|
|
|
|
|
return svc.StatusResultStore(ctx)
|
|
|
|
}
|