mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
c5f0e5a6b4
- Osquery Options (to be renamed to Options after current Options removed) - Labels - Queries - Packs
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/go-kit/kit/endpoint"
|
|
"github.com/kolide/fleet/server/kolide"
|
|
)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Apply Options Spec
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
type applyOsqueryOptionsSpecRequest struct {
|
|
Spec *kolide.OptionsSpec `json:"spec"`
|
|
}
|
|
|
|
type applyOsqueryOptionsSpecResponse struct {
|
|
Err error `json:"error,omitempty"`
|
|
}
|
|
|
|
func (r applyOsqueryOptionsSpecResponse) error() error { return r.Err }
|
|
|
|
func makeApplyOsqueryOptionsSpecEndpoint(svc kolide.Service) endpoint.Endpoint {
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
req := request.(applyOsqueryOptionsSpecRequest)
|
|
err := svc.ApplyOptionsSpec(ctx, req.Spec)
|
|
if err != nil {
|
|
return applyOsqueryOptionsSpecResponse{Err: err}, nil
|
|
}
|
|
return applyOsqueryOptionsSpecResponse{}, nil
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Get Options Spec
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
type getOsqueryOptionsSpecResponse struct {
|
|
Spec *kolide.OptionsSpec `json:"spec"`
|
|
Err error `json:"error,omitempty"`
|
|
}
|
|
|
|
func (r getOsqueryOptionsSpecResponse) error() error { return r.Err }
|
|
|
|
func makeGetOsqueryOptionsSpecEndpoint(svc kolide.Service) endpoint.Endpoint {
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
spec, err := svc.GetOptionsSpec(ctx)
|
|
if err != nil {
|
|
return getOsqueryOptionsSpecResponse{Err: err}, nil
|
|
}
|
|
return getOsqueryOptionsSpecResponse{Spec: spec}, nil
|
|
}
|
|
}
|