killbill-kpm 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +33 -0
- data/.travis.yml +41 -0
- data/Gemfile +5 -0
- data/Gemfile.head +5 -0
- data/Gemfile.lock +109 -0
- data/Jarfile +12 -0
- data/Jarfile.lock +64 -0
- data/LICENSE +201 -0
- data/README.md +58 -15
- data/Rakefile +19 -34
- data/VERSION +1 -0
- data/config.ru +4 -0
- data/killbill-kpm.gemspec +31 -0
- data/killbill.properties +3 -0
- data/lib/kpm/application.rb +92 -0
- data/lib/kpm/listener.rb +95 -0
- data/lib/kpm/plugins_installer.rb +112 -0
- data/lib/kpm_plugin.rb +13 -0
- data/pom.xml +44 -0
- data/release.sh +61 -0
- data/spec/kpm/base_plugin_spec.rb +25 -0
- data/spec/spec_helper.rb +14 -0
- metadata +66 -190
- data/MIT-LICENSE +0 -20
- data/app/assets/javascripts/application.js +0 -18
- data/app/assets/javascripts/kpm/kpm.js +0 -7
- data/app/assets/stylesheets/application.css +0 -19
- data/app/assets/stylesheets/bootstrap_and_overrides.css +0 -13
- data/app/assets/stylesheets/kpm/kpm.css +0 -6
- data/app/controllers/kpm/engine_controller.rb +0 -29
- data/app/controllers/kpm/nodes_info_controller.rb +0 -109
- data/app/controllers/kpm/plugins_controller.rb +0 -19
- data/app/helpers/kpm/application_helper.rb +0 -4
- data/app/views/kpm/layouts/kpm_application.html.erb +0 -31
- data/app/views/kpm/nodes_info/_logs_table.html.erb +0 -43
- data/app/views/kpm/nodes_info/_nodes_table.html.erb +0 -68
- data/app/views/kpm/nodes_info/index.html.erb +0 -68
- data/app/views/kpm/nodes_info/index.js.erb +0 -4
- data/app/views/kpm/plugins/_form.html.erb +0 -37
- data/app/views/kpm/plugins/_plugins_table.html.erb +0 -48
- data/app/views/kpm/plugins/index.html.erb +0 -18
- data/config/routes.rb +0 -17
- data/lib/kpm/client.rb +0 -31
- data/lib/kpm/engine.rb +0 -21
- data/lib/kpm/version.rb +0 -3
- data/lib/kpm.rb +0 -24
- data/lib/tasks/kpm_tasks.rake +0 -4
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -38
- data/test/dummy/bin/update +0 -29
- data/test/dummy/bin/yarn +0 -11
- data/test/dummy/config/application.rb +0 -26
- data/test/dummy/config/boot.rb +0 -3
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -54
- data/test/dummy/config/environments/production.rb +0 -91
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
- data/test/dummy/config/initializers/assets.rb +0 -14
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/killbill_client.rb +0 -3
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -33
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/config/secrets.yml +0 -32
- data/test/dummy/config.ru +0 -4
- data/test/integration/navigation_test.rb +0 -17
- data/test/kpm_test.rb +0 -8
- data/test/test_helper.rb +0 -19
data/README.md
CHANGED
@@ -1,31 +1,74 @@
|
|
1
|
-
|
2
|
-
========
|
1
|
+
# killbill-kpm-plugin
|
3
2
|
|
4
|
-
|
3
|
+
Plugin to enable plugin management at runtime.
|
5
4
|
|
6
|
-
|
5
|
+
Release builds are available on [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.kill-bill.billing.plugin.ruby%22%20AND%20a%3A%22kpm-plugin%22) with coordinates `org.kill-bill.billing.plugin.ruby:kpm-plugin`.
|
7
6
|
|
8
7
|
Kill Bill compatibility
|
9
8
|
-----------------------
|
10
9
|
|
11
|
-
|
|
12
|
-
| -------------: |
|
13
|
-
| 0.
|
14
|
-
|
|
15
|
-
|
|
10
|
+
| Plugin version | Kill Bill version |
|
11
|
+
| -------------: | -----------------: |
|
12
|
+
| 0.0.y | 0.16.z |
|
13
|
+
| -------------: | -----------------: |
|
14
|
+
| 1.x.y | 0.18.x (and 0.17.x)|
|
16
15
|
|
17
|
-
|
18
|
-
|
16
|
+
Usage
|
17
|
+
-----
|
19
18
|
|
20
|
-
|
19
|
+
* The plugin is indirectly integrated with [Kill Bill APIs](https://github.com/killbill/killbill-docs/blob/v3/userguide/tutorials/plugin_management.adoc)
|
20
|
+
* [killbill-kpm-ui](https://github.com/killbill/killbill-kpm-ui) offers a front-end for Kaui
|
21
|
+
|
22
|
+
The plugin also offers private APIs:
|
23
|
+
|
24
|
+
### Lookup plugins
|
25
|
+
|
26
|
+
All plugins:
|
21
27
|
|
22
28
|
```
|
23
|
-
|
29
|
+
curl -v \
|
30
|
+
-u admin:password \
|
31
|
+
http://127.0.0.1:8080/plugins/killbill-kpm/plugins
|
24
32
|
```
|
25
33
|
|
34
|
+
Specific plugin:
|
35
|
+
|
36
|
+
```
|
37
|
+
curl -v \
|
38
|
+
-u admin:password \
|
39
|
+
http://127.0.0.1:8080/plugins/killbill-kpm/plugins?name=stripe
|
40
|
+
```
|
41
|
+
|
42
|
+
### Plugin Management
|
43
|
+
|
44
|
+
Note that in a multi-nodes deployment, these commands would have to be run on each node. We also provide [Kill Bill apis to manage plugins](http://docs.killbill.io/0.16/plugin_management.html) that work across multi-nodes installation, but they do not allow uploading a plugin binary (e.g: jarfile), so those commands are still very useful in the context of doing plugin development.
|
45
|
+
|
46
|
+
|
47
|
+
Upload a plugin:
|
48
|
+
|
49
|
+
```
|
50
|
+
curl -v \
|
51
|
+
-X POST \
|
52
|
+
-u admin:password \
|
53
|
+
-H 'Content-Type: application/json' \
|
54
|
+
-d @/path/to/myplugin.jar \
|
55
|
+
'http://127.0.0.1:8080/plugins/killbill-kpm/plugins?filename=myplugin.jar&key=myplugin&version=0.2.5'
|
56
|
+
```
|
57
|
+
|
58
|
+
### Uninstall a plugin
|
59
|
+
|
60
|
+
```
|
61
|
+
curl -v \
|
62
|
+
-X DELETE \
|
63
|
+
-u admin:password \
|
64
|
+
'http://127.0.0.1:8080/plugins/killbill-kpm/plugins?key=myplugin&version=0.2.5'
|
65
|
+
```
|
26
66
|
|
27
|
-
|
67
|
+
### Restart a plugin
|
28
68
|
|
29
69
|
```
|
30
|
-
|
70
|
+
curl -v \
|
71
|
+
-X PUT \
|
72
|
+
-u admin:password \
|
73
|
+
'http://127.0.0.1:8080/plugins/killbill-kpm/plugins?key=myplugin&version=0.2.5'
|
31
74
|
```
|
data/Rakefile
CHANGED
@@ -1,37 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
# Install tasks to build and release the plugin
|
4
|
+
require 'bundler/setup'
|
5
|
+
Bundler::GemHelper.install_tasks
|
6
|
+
|
7
|
+
# Install test tasks
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
namespace :test do
|
10
|
+
desc 'Run RSpec tests'
|
11
|
+
RSpec::Core::RakeTask.new do |task|
|
12
|
+
task.name = 'spec'
|
13
|
+
task.pattern = './spec/*/*_spec.rb'
|
14
|
+
end
|
5
15
|
end
|
6
16
|
|
7
|
-
|
17
|
+
# Install tasks to package the plugin for Killbill
|
18
|
+
require 'killbill/rake_task'
|
19
|
+
Killbill::PluginHelper.install_tasks
|
8
20
|
|
9
|
-
|
10
|
-
|
11
|
-
rdoc.title = 'KPM'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
-
load 'rails/tasks/engine.rake'
|
19
|
-
|
20
|
-
|
21
|
-
load 'rails/tasks/statistics.rake'
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
require 'bundler/gem_tasks'
|
26
|
-
|
27
|
-
require 'rake/testtask'
|
28
|
-
|
29
|
-
Rake::TestTask.new(:test) do |t|
|
30
|
-
t.libs << 'lib'
|
31
|
-
t.libs << 'test'
|
32
|
-
t.pattern = 'test/**/*_test.rb'
|
33
|
-
t.verbose = false
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
task default: :test
|
21
|
+
# Run tests by default
|
22
|
+
task :default => 'test:spec'
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/config.ru
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'killbill-kpm'
|
5
|
+
s.version = version
|
6
|
+
s.summary = 'Kill Bill KPM plugin'
|
7
|
+
s.description = 'Plugin to manage installed plugins'
|
8
|
+
|
9
|
+
s.required_ruby_version = '>= 1.9.3'
|
10
|
+
|
11
|
+
s.license = 'Apache License (2.0)'
|
12
|
+
|
13
|
+
s.author = 'Killbill core team'
|
14
|
+
s.email = 'killbilling-users@googlegroups.com'
|
15
|
+
s.homepage = 'http://killbill.io'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.bindir = 'bin'
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ['lib']
|
22
|
+
|
23
|
+
s.rdoc_options << '--exclude' << '.'
|
24
|
+
|
25
|
+
s.add_dependency 'killbill', '~> 8.0.1'
|
26
|
+
s.add_dependency 'kpm', '~> 0.1.4'
|
27
|
+
|
28
|
+
s.add_development_dependency 'jbundler', '~> 0.9.2'
|
29
|
+
s.add_development_dependency 'rake', '>= 10.0.0'
|
30
|
+
s.add_development_dependency 'rspec', '~> 2.12.0'
|
31
|
+
end
|
data/killbill.properties
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
configure do
|
2
|
+
# Usage: bundle exec rackup -Ilib -E test
|
3
|
+
if development? or test?
|
4
|
+
require 'logger'
|
5
|
+
::KPM::PluginsInstaller.instance.initialize!('/var/tmp/bundles/plugins/ruby/kpm/0.0.1',
|
6
|
+
File.expand_path(File.dirname(__FILE__) + '../../../'),
|
7
|
+
nil,
|
8
|
+
Logger.new(STDOUT))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Lookup plugins
|
13
|
+
get '/plugins/killbill-kpm/plugins', :provides => 'json' do
|
14
|
+
artifact_id = params[:artifact_id] || params[:name]
|
15
|
+
latest = params[:latest] == 'false' ? false : true
|
16
|
+
|
17
|
+
if artifact_id.nil?
|
18
|
+
::KPM::PluginsInstaller.instance.all(latest).to_json
|
19
|
+
else
|
20
|
+
group_id, artifact_id, packaging, classifier, version, type = ::KPM::PluginsInstaller.instance.lookup artifact_id, latest
|
21
|
+
|
22
|
+
if artifact_id.nil?
|
23
|
+
status 404
|
24
|
+
else
|
25
|
+
{
|
26
|
+
:group_id => group_id,
|
27
|
+
:artifact_id => artifact_id,
|
28
|
+
:packaging => packaging,
|
29
|
+
:classifier => classifier,
|
30
|
+
:version => version,
|
31
|
+
:type => type
|
32
|
+
}.to_json
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Install a plugin
|
38
|
+
post '/plugins/killbill-kpm/plugins', :provides => 'json' do
|
39
|
+
if !request.body.nil?
|
40
|
+
type = (params[:type] || 'java').downcase
|
41
|
+
|
42
|
+
info = Dir.mktmpdir do |dir|
|
43
|
+
plugin_path = File.join(dir, params[:filename] || "#{params[:name]}.#{type == 'java' ? 'jar' : 'tar.gz'}")
|
44
|
+
File.open(plugin_path, 'w') do |file|
|
45
|
+
file.write(request.body.read)
|
46
|
+
end
|
47
|
+
::KPM::PluginsInstaller.instance.install_from_fs params[:key],
|
48
|
+
plugin_path,
|
49
|
+
params[:version],
|
50
|
+
type
|
51
|
+
end
|
52
|
+
else
|
53
|
+
info = ::KPM::PluginsInstaller.instance.install params[:key],
|
54
|
+
params[:artifact_id],
|
55
|
+
params[:version],
|
56
|
+
params[:group_id],
|
57
|
+
params[:packaging],
|
58
|
+
params[:classifier],
|
59
|
+
params[:type],
|
60
|
+
params[:force_download]
|
61
|
+
end
|
62
|
+
|
63
|
+
if info.nil?
|
64
|
+
status 400
|
65
|
+
else
|
66
|
+
info.to_json
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Uninstall a plugin
|
71
|
+
delete '/plugins/killbill-kpm/plugins', :provides => 'json' do
|
72
|
+
modified = ::KPM::PluginsInstaller.instance.uninstall params[:key],
|
73
|
+
params[:version]
|
74
|
+
|
75
|
+
if modified.empty?
|
76
|
+
status 404
|
77
|
+
else
|
78
|
+
modified.to_json
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Restart a plugin
|
83
|
+
put '/plugins/killbill-kpm/plugins', :provides => 'json' do
|
84
|
+
modified = ::KPM::PluginsInstaller.instance.restart params[:key],
|
85
|
+
params[:version]
|
86
|
+
|
87
|
+
if modified.empty?
|
88
|
+
status 404
|
89
|
+
else
|
90
|
+
modified.to_json
|
91
|
+
end
|
92
|
+
end
|
data/lib/kpm/listener.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'nexus_cli'
|
2
|
+
|
3
|
+
module KPM
|
4
|
+
class Listener < Killbill::Plugin::Notification
|
5
|
+
|
6
|
+
|
7
|
+
def start_plugin
|
8
|
+
super
|
9
|
+
::KPM::PluginsInstaller.instance.initialize!(@root, @conf_dir, @kb_apis, @logger)
|
10
|
+
# We don't know yet
|
11
|
+
@kb_version = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_event(event)
|
15
|
+
|
16
|
+
return unless [:BROADCAST_SERVICE].include?(event.event_type)
|
17
|
+
|
18
|
+
unless ::KPM::PluginsInstaller.instance.initialized?
|
19
|
+
@logger.warn "KPM plugin wasn't started properly - check logs"
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
broadcast_metadata = event.meta_data.nil? ? {} : JSON.parse(event.meta_data)
|
24
|
+
command = broadcast_metadata['commandType']
|
25
|
+
return if command != 'INSTALL_PLUGIN' && command != 'UNINSTALL_PLUGIN'
|
26
|
+
|
27
|
+
service = broadcast_metadata['service']
|
28
|
+
event_json = broadcast_metadata['eventJson'].nil? ? {} : JSON.parse(broadcast_metadata['eventJson'])
|
29
|
+
|
30
|
+
properties = properties_to_hash(event_json['properties'])
|
31
|
+
|
32
|
+
@logger.info "Received #{event.event_type} event: service=#{service} command=#{command} event=#{event_json}"
|
33
|
+
|
34
|
+
# pluginKey is the only mandatory property
|
35
|
+
if event_json['pluginKey'].nil?
|
36
|
+
@logger.info("Cannot run #{command}: missing pluginKey property")
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
|
40
|
+
handle_event(command,
|
41
|
+
event_json['pluginKey'],
|
42
|
+
properties['pluginArtifactId'],
|
43
|
+
event_json['pluginVersion'],
|
44
|
+
properties['pluginGroupId'],
|
45
|
+
properties['pluginPackaging'],
|
46
|
+
properties['pluginClassifier'],
|
47
|
+
properties['pluginType'],
|
48
|
+
properties['forceDownload'] == 'true')
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def get_kb_version
|
54
|
+
return @kb_version if @kb_version
|
55
|
+
|
56
|
+
nodes_info = @kb_apis.killbill_nodes_api.get_nodes_info
|
57
|
+
if nodes_info.nil? || nodes_info.empty?
|
58
|
+
@logger.warn("Unable to retrieve node info")
|
59
|
+
return nil
|
60
|
+
end
|
61
|
+
|
62
|
+
# This is incorrect, we need to find the entry for our node, but we don't seem to know who we are -:(
|
63
|
+
# (The will break in rolling upgrade scenario)
|
64
|
+
@kb_version = nodes_info[0].killbill_version
|
65
|
+
|
66
|
+
@logger.info("KPM plugin extracted killbill version #{@kb_version}")
|
67
|
+
|
68
|
+
@kb_version
|
69
|
+
end
|
70
|
+
|
71
|
+
def handle_event(command, plugin_key, artifact_id, version=nil, group_id=nil, packaging=nil, classifier=nil, type=nil, force_download=false)
|
72
|
+
@logger.info "handle_event command=#{command}, plugin_key=#{plugin_key}, artifact_id=#{artifact_id}, version=#{version}, group_id=#{group_id}, packaging=#{packaging}, classifier=#{classifier}, type=#{type}, force_download=#{force_download}"
|
73
|
+
|
74
|
+
if command == 'INSTALL_PLUGIN'
|
75
|
+
::KPM::PluginsInstaller.instance.install(plugin_key, get_kb_version, artifact_id, version, group_id, packaging, classifier, type, force_download)
|
76
|
+
elsif command == 'UNINSTALL_PLUGIN'
|
77
|
+
::KPM::PluginsInstaller.instance.uninstall(plugin_key, version)
|
78
|
+
else
|
79
|
+
@logger.warn("Ignoring unsupported command #{command}")
|
80
|
+
end
|
81
|
+
rescue NexusCli::ArtifactNotFoundException
|
82
|
+
@logger.warn("Unable to #{command} for plugin_key=#{plugin_key}: artifact was not found in Nexus")
|
83
|
+
end
|
84
|
+
|
85
|
+
def properties_to_hash(properties)
|
86
|
+
return {} if properties.nil?
|
87
|
+
|
88
|
+
h = {}
|
89
|
+
properties.each do |prop|
|
90
|
+
h[prop['key']] = prop['value']
|
91
|
+
end
|
92
|
+
h
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module KPM
|
2
|
+
class PluginsInstaller
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
attr_reader :initialized
|
6
|
+
alias_method :initialized?, :initialized
|
7
|
+
|
8
|
+
def initialize!(root_dir, conf_dir, kb_apis, logger)
|
9
|
+
@kb_apis = kb_apis
|
10
|
+
@logger = logger
|
11
|
+
|
12
|
+
configure!(Pathname.new(conf_dir).expand_path.join('kpm.yml'))
|
13
|
+
|
14
|
+
@bundles_dir = Pathname.new(root_dir).join('..').join('..').join('..').join('..').expand_path
|
15
|
+
plugins_dir = @bundles_dir.join('plugins')
|
16
|
+
|
17
|
+
@installer = ::KPM::BaseInstaller.new(@logger, @glob_config[:kpm][:nexus], @glob_config[:kpm][:ssl_verify])
|
18
|
+
@manager = ::KPM::PluginsManager.new(plugins_dir, @logger)
|
19
|
+
|
20
|
+
@initialized = true
|
21
|
+
end
|
22
|
+
|
23
|
+
# If an earlier version of the plugin is installed, Kill Bill will only start the latest one (see org.killbill.billing.osgi.FileInstall)
|
24
|
+
def install(plugin_key, kb_version, specified_artifact_id, specified_version=nil, specified_group_id=nil, specified_packaging=nil, specified_classifier=nil, specified_type=nil, force_download=false)
|
25
|
+
@logger.info("Instructed to install plugin_key=#{plugin_key} artifact_id=#{specified_artifact_id} version=#{specified_version} group_id=#{specified_group_id} packaging=#{specified_packaging} classifier=#{specified_classifier} type=#{specified_type} force_download=#{force_download}")
|
26
|
+
info = @installer.install_plugin(plugin_key, kb_version, specified_group_id, specified_artifact_id, specified_packaging, specified_classifier, specified_version, @bundles_dir, specified_type, force_download, @glob_config[:kpm][:verify_sha1])
|
27
|
+
if info.nil?
|
28
|
+
@logger.warn("Error during installation of plugin #{specified_artifact_id}")
|
29
|
+
else
|
30
|
+
path = info[:bundle_dir]
|
31
|
+
notify_fs_change(plugin_key, path, :NEW_VERSION)
|
32
|
+
end
|
33
|
+
info
|
34
|
+
end
|
35
|
+
|
36
|
+
def install_from_fs(plugin_key, file_path, version, type)
|
37
|
+
@logger.info("Instructed to install file_path=#{file_path} plugin_key=#{plugin_key} version=#{version} type=#{type}")
|
38
|
+
info = @installer.install_plugin_from_fs(plugin_key, file_path, plugin_key, version, @bundles_dir, type)
|
39
|
+
if info.nil?
|
40
|
+
@logger.warn("Error during installation of plugin #{plugin_key}")
|
41
|
+
else
|
42
|
+
path = info[:bundle_dir] || info[:dir_name]
|
43
|
+
notify_fs_change(plugin_key, path, :NEW_VERSION)
|
44
|
+
end
|
45
|
+
info
|
46
|
+
end
|
47
|
+
|
48
|
+
def uninstall(plugin_key, version=nil)
|
49
|
+
modified = @installer.uninstall_plugin(plugin_key, version || :all, @bundles_dir)
|
50
|
+
modified.each do |path|
|
51
|
+
notify_fs_change(plugin_key, path, :DISABLED)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def restart(plugin_name, version=nil)
|
56
|
+
@manager.restart(plugin_name, version || :all)
|
57
|
+
end
|
58
|
+
|
59
|
+
def lookup(artifact_id, latest=true)
|
60
|
+
KPM::PluginsDirectory.lookup(artifact_id, latest)
|
61
|
+
end
|
62
|
+
|
63
|
+
def all(latest=true)
|
64
|
+
KPM::PluginsDirectory.all(latest)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def notify_fs_change(plugin_key, path, state)
|
70
|
+
return if path.nil?
|
71
|
+
|
72
|
+
@logger.info("notify_fs_change: plugin_key = #{plugin_key}, path=#{path}, state=#{state}")
|
73
|
+
|
74
|
+
# Plugin name should be the directory name (path is something like /var/tmp/bundles/plugins/ruby/killbill-stripe/2.0.0 or /var/tmp/bundles/plugins/ruby)
|
75
|
+
fs_info = path.to_s.split('/')
|
76
|
+
plugin_type = fs_info[-3].upcase
|
77
|
+
plugin_name = fs_info[-2]
|
78
|
+
plugin_version = fs_info[-1]
|
79
|
+
|
80
|
+
|
81
|
+
if @kb_apis.nil?
|
82
|
+
@logger.warn("APIs not configured: Kill Bill won't be notified of new state #{state}")
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
@logger.info("Notifying Kill Bill: state=#{state} plugin_key=#{plugin_key} plugin_name=#{plugin_name} plugin_version=#{plugin_version} plugin_type=#{plugin_type}")
|
87
|
+
@kb_apis.plugins_info_api.notify_of_state_changed(state, plugin_key, plugin_name, plugin_version, plugin_type)
|
88
|
+
end
|
89
|
+
|
90
|
+
def configure!(config_file)
|
91
|
+
@glob_config = {}
|
92
|
+
|
93
|
+
# Look for global config
|
94
|
+
if !config_file.blank? && Pathname.new(config_file).file?
|
95
|
+
@glob_config = ::Killbill::Plugin::ActiveMerchant::Properties.new(config_file)
|
96
|
+
@glob_config.parse!
|
97
|
+
@glob_config = @glob_config.to_hash
|
98
|
+
end
|
99
|
+
|
100
|
+
@glob_config[:kpm] ||= {}
|
101
|
+
|
102
|
+
@glob_config[:kpm][:nexus] ||= {}
|
103
|
+
@glob_config[:kpm][:nexus][:url] ||= 'https://oss.sonatype.org'
|
104
|
+
@glob_config[:kpm][:nexus][:repository] ||= 'releases'
|
105
|
+
|
106
|
+
@glob_config[:kpm][:ssl_verify] = true if @glob_config[:kpm][:ssl_verify].nil?
|
107
|
+
@glob_config[:kpm][:verify_sha1] = true if @glob_config[:kpm][:verify_sha1].nil?
|
108
|
+
|
109
|
+
@logger.level = Logger::DEBUG if (@glob_config[:logger] || {})[:debug]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|