Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the core/v3 API, minor improvements to core/v2 (#3808)
* Refactor core/v2 protos This commit refactors the import paths of the core/v2 protos so that they're easier to use from outside of the package. * Add core/v3 API This commit adds the beginnings of the core/v3 API. It includes the EntityConfig and EntityState resources. The core/v3 API expands on the ideas introduced in the core/v2 API, and refines the Resource concept. A new core/v3.Resource interface has been defined, and it's expected that all resources in the core/v3 package will conform to this interface. We've had a lot of experience developing the core/v2 API over the last couple of years, and as a result it's been possible to generalize that experience into code generation. Developers can now create core/v3.Resource implementations by doing nothing more than authoring a .proto file. The automatically generated code has automatically generated tests to go along with it, which should ensure that changes and updates to the code generation over time will not cause breakage. UnmarshalJSON has been automatically generated for all types, so that the common pitfall of nil labels and annotations can be avoided. All types that have ObjectMeta are therefore guaranteed to have non-nil labels and annotations after being unmarshalled from JSON. Most of the automatically generated methods that implement Resource can be overridden by writing a custom unexported method for the type in question. See the code documentation for more details. Validation works more cooperatively, with the automatically generated method only checking the metadata, and then optionally invoking the unexported validate() method, if it is present. Any core/v3.Resource can be converted to a core/v2.Resource with the V3ResourceToV2 function. This should allow for gradual code repair throughout the sensu-go codebase over time. The EntityConfig and EntityState types are a split of the original core/v2.Entity type. These types have been introduced because we want to start treating these data different from a storage perspective. Functions have been included to convert between core/v2.Entity, and core/v3.{EntityConfig, EntityState}. This will allow developers to gradually use EntityConfig and EntityState in the codebase without worrying too much about compatibility. Signed-off-by: Eric Chlebek <[email protected]>
- Loading branch information