Skip to content

Commit

Permalink
Add action_response field into .fleet-actions-results (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksmaus authored Oct 21, 2021
1 parent 5c1d81f commit 730835d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
15 changes: 8 additions & 7 deletions cmd/fleet/handleAck.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ func (ack *AckT) handleAckEvents(ctx context.Context, agent *model.Agent, events
}

acr := model.ActionResult{
ActionId: ev.ActionId,
AgentId: agent.Id,
StartedAt: ev.StartedAt,
CompletedAt: ev.CompletedAt,
ActionData: ev.ActionData,
Data: ev.Data,
Error: ev.Error,
ActionId: ev.ActionId,
AgentId: agent.Id,
StartedAt: ev.StartedAt,
CompletedAt: ev.CompletedAt,
ActionData: ev.ActionData,
ActionResponse: ev.ActionResponse,
Data: ev.Data,
Error: ev.Error,
}
if _, err := dl.CreateActionResult(ctx, ack.bulk, acr); err != nil {
return errors.Wrap(err, "create action result")
Expand Down
29 changes: 15 additions & 14 deletions cmd/fleet/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,21 @@ type ActionResp struct {
}

type Event struct {
Type string `json:"type"`
SubType string `json:"subtype"`
AgentId string `json:"agent_id"`
ActionId string `json:"action_id"`
PolicyId string `json:"policy_id"`
StreamId string `json:"stream_id"`
Timestamp string `json:"timestamp"`
Message string `json:"message"`
Payload json.RawMessage `json:"payload,omitempty"`
StartedAt string `json:"started_at"`
CompletedAt string `json:"completed_at"`
ActionData json.RawMessage `json:"action_data,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Type string `json:"type"`
SubType string `json:"subtype"`
AgentId string `json:"agent_id"`
ActionId string `json:"action_id"`
PolicyId string `json:"policy_id"`
StreamId string `json:"stream_id"`
Timestamp string `json:"timestamp"`
Message string `json:"message"`
Payload json.RawMessage `json:"payload,omitempty"`
StartedAt string `json:"started_at"`
CompletedAt string `json:"completed_at"`
ActionData json.RawMessage `json:"action_data,omitempty"`
ActionResponse json.RawMessage `json:"action_response,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}

type StatusResponse struct {
Expand Down
11 changes: 11 additions & 0 deletions internal/pkg/es/mapping.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions internal/pkg/model/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions model/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
"type": "object",
"format": "raw"
},
"action_response": {
"description": "The custom action response payload.",
"type": "object",
"format": "raw"
},
"error": {
"description": "The action error message.",
"type": "string"
Expand Down

0 comments on commit 730835d

Please sign in to comment.