Closed jspaleta closed 5 years ago
i need to clean things up for rubocop. I just wanted to get the PR out for people to look at asap
@jspaleta Could the 2to1 method be refactored and/or moved to its own gem so that it can be used for https://github.com/sensu/sensu-1.x-filter-wrapper ?
@cyphus
okay refactoring this now as a utility function. I'm sure it makes sense as a separate gem right now. It definitely feels like something in the scope of sensu-plugin which provides nice base classes for mutators,checks and handlers.
Could the 2to1 method be refactored and/or moved to its own gem
I agree with @jspaleta that this makes sense to be in the base plugin class as a util method, any GRPC service can depend on the base plugin class.
@cyphus I think have it set up now so that if you use this now so that you could for example create a mutator instance from sensu-plugin in the GRPC and call the method like this: event_1.x_json=mutator.event_2to1(event_2.x_json)
irb toy example: require 'sensu-mutator' mutator = Sensu::Mutator.new event = JSON.parse("{}") new_event=mutator.event_2to1(event)
Description
Added event_2to1 method to Utils and --enable-2.0-event option to base Handler class. New option makes it possible to use sensu-plugin based handlers with Sensu 2.0 events until handlers provide native 2.0 event support.
Motivation and Context
the event data model changed in Sensu 2.0, so to make it possible to continue to use the community managed handlers a quick mapping back into Sensu 1.4 event JSON representation can be performed.
How Has This Been Tested?
Spot checked with local rebuild of sensu-plugin-logs handler so far.
Types of changes
Checklist: