mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 00:45:19 +00:00
19ad7cc637
* Set interface for response types * Fix TestEndpointer test
33 lines
654 B
Go
33 lines
654 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
)
|
|
|
|
type triggerRequest struct {
|
|
Name string `query:"name,optional"`
|
|
}
|
|
|
|
type triggerResponse struct {
|
|
Err error `json:"error,omitempty"`
|
|
}
|
|
|
|
func (r triggerResponse) error() error { return r.Err }
|
|
|
|
func triggerEndpoint(ctx context.Context, request interface{}, svc fleet.Service) (errorer, error) {
|
|
_, err := svc.AuthenticatedUser(ctx)
|
|
if err != nil {
|
|
return triggerResponse{Err: err}, nil
|
|
}
|
|
req := request.(*triggerRequest)
|
|
|
|
err = svc.TriggerCronSchedule(ctx, req.Name)
|
|
if err != nil {
|
|
return triggerResponse{Err: err}, nil
|
|
}
|
|
|
|
return triggerResponse{}, nil
|
|
}
|