12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/kpm/listener.rb', line 12
def on_event(event)
return unless [:BROADCAST_SERVICE].include?(event.event_type)
unless ::KPM::PluginsInstaller.instance.initialized?
@logger.warn "KPM plugin wasn't started properly - check logs"
return
end
broadcast_metadata = event.meta_data.nil? ? {} : JSON.parse(event.meta_data)
command = broadcast_metadata['commandType']
return if command != 'INSTALL_PLUGIN' && command != 'UNINSTALL_PLUGIN'
service = broadcast_metadata['service']
event_json = broadcast_metadata['eventJson'].nil? ? {} : JSON.parse(broadcast_metadata['eventJson'])
properties = properties_to_hash(event_json['properties'])
@logger.info "Received #{event.event_type} event: service=#{service} command=#{command} event=#{event_json}"
if event_json['pluginKey'].nil?
@logger.info("Cannot run #{command}: missing pluginKey property")
return false
end
handle_event(command,
event_json['pluginKey'],
properties['pluginArtifactId'],
event_json['pluginVersion'],
properties['pluginGroupId'],
properties['pluginPackaging'],
properties['pluginClassifier'],
properties['pluginType'],
properties['forceDownload'] == 'true')
end
|