Add required API calls to retrieve configuration from Fleet.#14871
Add required API calls to retrieve configuration from Fleet.#14871ph merged 4 commits intoelastic:fleetfrom ph:agent/fetch-configuration-from-fleet
Conversation
This PR implements the required structs and calls to retrieve the configuration from Fleet. This is step one before refactoring the Reporter to split the pushing event and fetching of configuration.
| } | ||
| } | ||
| ], | ||
| "success": true |
There was a problem hiding this comment.
@nchaulet Did we remove success from the fleet checkin response? I though all endpoints response was returning that field? But looking at your comments in elastic/kibana#51968 this doens't appear to be the case?
There was a problem hiding this comment.
No it's not removed it's here, I just did not put it in the examples.
|
@ph Currently every events need to have a Do you think it's better to keep it like this or to make subtype optional and have Also I am going to document that when we have a decision |
michalpristas
left a comment
There was a problem hiding this comment.
Looks good, thanks PH
| for _, response := range responses { | ||
| switch response.ActionType { | ||
| case "POLICY_CHANGE": | ||
| action = &PolicyChangeAction{ |
There was a problem hiding this comment.
i wonder if it's not possible keep it as []Action and make decisions based on ActionType. Lazy casting basically
There was a problem hiding this comment.
Yeah, I had mixed feeling went implementing this, I had two ideas:
- Make it generic, extract the minimal required fields for the action ( type / action ID) and puts everything else in a
json.RawMessagefield so it can be lazily extracted later one. - Implement a base type + concrete type on top of it.
I've gone with the second option because I wanted to keep the serialization in a single place and theses are just data object no logic should be added to them. If new behavior is required, we either:
- Create a new type / type cast to a new type.
- Create a function that accepts the struct.
Now, I diverge on that with the Event, as you may have noticed I've created a SerializableEvent interface that implements a minimum public interface and expect the user to correctly serialize the type to the JSON. I did this because, an event from Agent doesn't have at the moment a finite number of possibilities.
@nchaulet I can do the type/subtype thing, I was following your example in the PR description in elastic/kibana#51968 (comment) edit: the description was updated with the right return now. |
|
I've made the changes @nchaulet and @michalpristas:
|
nchaulet
left a comment
There was a problem hiding this comment.
Looks good to me, it should worked correctly with fleet API 👍
…#14871) * Implements the require "Checkin" calls This PR implements the required structs and calls to retrieve the configuration from Fleet. This is step one before refactoring the Reporter to split the pushing event and fetching of configuration.
Kibana implement is in elastic/kibana#51968
--
This PR implements the required structs and calls to retrieve the
configuration from Fleet. This is step one before refactoring the
Reporter to split the pushing event and fetching of configuration.