kpm 0.1.7 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad4a3f0861e0df1db63bfb5647ed60ebd1a7c4d3
4
- data.tar.gz: d8b938a6b66539fec064abb4a67bc94f81f64bab
3
+ metadata.gz: af4823a1ad26ca690e372df3596841ae7fa54ee9
4
+ data.tar.gz: ade7725741e69b929bfa0fd9d47d6fa6326f4695
5
5
  SHA512:
6
- metadata.gz: 2a6a89efadce6b7fa7610a0927f0d15a38b83886b1aa29071995bb723532dd0777b5941ee9aadc4b7513fad446eae5b02fb3f00ede6a62bffa76568201062eba
7
- data.tar.gz: e33e8482b67584e8328c7f26f17626e7ef98a8dbadb42e8e4daca404205fc8229af19c8bd41aaf02b82771bc5aeaf1baf762a52335427c42526414b5537406eb
6
+ metadata.gz: 92361d67b9abc0bd2da406fc460481aa8b74176cddf5d4b5b11381428750fe1b417ac0b5bb2796512e52e65963427793cd293dfbf56d53f02672f82b6b0430d2
7
+ data.tar.gz: b9f1727cdd593dfb48fb4b5c6ef16e2caf272141253100b8566ee7a808b9c74577e652f5742863deb3804bfacb13ff793a37927f151b4bccbbaa895d0ca9f1b1
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.add_dependency 'highline', '~> 1.6.21'
43
43
  s.add_dependency 'nexus_cli', '~> 4.1.0'
44
44
  s.add_dependency 'thor', '~> 0.19.1'
45
+ s.add_dependency 'rubyzip', '~>1.2.0'
45
46
 
46
47
  s.add_development_dependency 'rake', '>= 10.0.0', '< 11.0.0'
47
48
  s.add_development_dependency 'rspec', '~> 2.12.0'
@@ -37,7 +37,7 @@ module KPM
37
37
  class << self
38
38
  def pull(logger, group_id, artifact_id, packaging='jar', classifier=nil, version='LATEST', destination_path=nil, sha1_file=nil, force_download=false, verify_sha1=true, overrides={}, ssl_verify=true)
39
39
  coordinate_map = {:group_id => group_id, :artifact_id => artifact_id, :packaging => packaging, :classifier => classifier, :version => version}
40
- pull_and_put_in_place(logger, coordinate_map, destination_path, is_ruby_plugin_and_should_skip_top_dir(group_id, artifact_id), sha1_file, force_download, verify_sha1, overrides, ssl_verify)
40
+ pull_and_put_in_place(logger, coordinate_map, nil, destination_path, false, sha1_file, force_download, verify_sha1, overrides, ssl_verify)
41
41
  end
42
42
 
43
43
  def pull_from_fs(logger, file_path, destination_path=nil)
@@ -57,9 +57,10 @@ module KPM
57
57
 
58
58
  protected
59
59
 
60
- def pull_and_put_in_place(logger, coordinate_map, destination_path=nil, skip_top_dir=true, sha1_file=nil, force_download=false, verify_sha1=true, overrides={}, ssl_verify=true)
60
+ def pull_and_put_in_place(logger, coordinate_map, plugin_name, destination_path=nil, skip_top_dir=true, sha1_file=nil, force_download=false, verify_sha1=true, overrides={}, ssl_verify=true)
61
61
  # Build artifact info
62
62
  artifact_info = artifact_info(logger, coordinate_map, overrides, ssl_verify)
63
+ artifact_info[:plugin_name] = plugin_name
63
64
  populate_fs_info(artifact_info, destination_path)
64
65
 
65
66
  # Update with resolved version in case 'LATEST' was passed
@@ -73,9 +74,12 @@ module KPM
73
74
  # We need to do a bit of magic to make sure that artifact_info[:bundle_dir] is correctly populated when we bail early
74
75
  if artifact_info[:is_tgz] && coordinate_map[:artifact_id] != 'killbill-platform-osgi-bundles-defaultbundles'
75
76
  plugin_dir = File.split(artifact_info[:dir_name])[0]
76
- plugins_manager = PluginsManager.new(plugin_dir, logger)
77
- artifact_id = coordinates.split(':')[1]
78
- plugin_name = plugins_manager.guess_plugin_name(artifact_id)
77
+ plugin_name = artifact_info[:plugin_name]
78
+ unless plugin_name
79
+ plugins_manager = PluginsManager.new(plugin_dir, logger)
80
+ artifact_id = coordinates.split(':')[1]
81
+ plugin_name = plugins_manager.guess_plugin_name(artifact_id)
82
+ end
79
83
  if plugin_name.nil?
80
84
  logger.warn("Failed to guess plugin_name for #{coordinates}: artifact_info[:bundle_dir] will not be populated correctly")
81
85
  else
@@ -139,6 +143,19 @@ module KPM
139
143
  # Unclear if this is even possible
140
144
  return false if artifact_info[:sha1].nil?
141
145
 
146
+ # If tgz artifact, check if expected exploded folder exists
147
+ if artifact_info[:is_tgz]
148
+ artifact_path = Pathname.new(artifact_info[:file_path])
149
+ if artifact_info[:plugin_name]
150
+ artifact_path = artifact_path.join(artifact_info[:plugin_name]).join(artifact_info[:version])
151
+ end
152
+ return false if !artifact_path.exist?
153
+ # Else, exit early if file_path does not exist or is a directory
154
+ elsif !File.exists?(artifact_info[:file_path]) ||
155
+ File.directory?(artifact_info[:file_path])
156
+ return false
157
+ end
158
+
142
159
  # Check entry in sha1_file if exists
143
160
  if sha1_file && File.exists?(sha1_file)
144
161
  sha1_checker = Sha1Checker.from_file(sha1_file)
@@ -146,15 +163,14 @@ module KPM
146
163
  return true if local_sha1 == artifact_info[:sha1]
147
164
  end
148
165
 
149
- # If not using sha1_file mechanism, exit early if file_path does not exist or is a directory
150
- if !File.exists?(artifact_info[:file_path]) ||
151
- File.directory?(artifact_info[:file_path])
152
- return false
166
+ if artifact_info[:is_tgz]
167
+ # tgz artifact seems to be installed, but is not in the sha1 file, so do not skip it
168
+ false
169
+ else
170
+ # Finally check if remote_sha1 matches what we have locally
171
+ local_sha1 = Digest::SHA1.file(artifact_info[:file_path]).hexdigest
172
+ local_sha1 == artifact_info[:sha1]
153
173
  end
154
-
155
- # Finally check if remote_sha1 matches what we have locally
156
- local_sha1 = Digest::SHA1.file(artifact_info[:file_path]).hexdigest
157
- local_sha1 == artifact_info[:sha1]
158
174
  end
159
175
 
160
176
  def artifact_info(logger, coordinate_map, overrides={}, ssl_verify=true)
@@ -264,11 +280,6 @@ module KPM
264
280
 
265
281
  # Magic methods...
266
282
 
267
- def is_ruby_plugin_and_should_skip_top_dir(group_id, artifact_id)
268
- # The second check is for custom ruby plugins
269
- group_id == KILLBILL_RUBY_PLUGIN_GROUP_ID || artifact_id.include?('plugin')
270
- end
271
-
272
283
  def path_looks_like_a_directory(path)
273
284
  # It already is!
274
285
  return true if File.directory?(path)
@@ -1,4 +1,5 @@
1
1
  require 'pathname'
2
+ require 'zip'
2
3
 
3
4
  module KPM
4
5
  class BaseInstaller
@@ -7,10 +8,7 @@ module KPM
7
8
  SHA1_FILENAME = 'sha1.yml'
8
9
  DEFAULT_BUNDLES_DIR = Pathname.new('/var').join('tmp').join('bundles').to_s
9
10
 
10
-
11
-
12
-
13
- def initialize(logger, nexus_config, nexus_ssl_verify)
11
+ def initialize(logger, nexus_config = nil, nexus_ssl_verify = nil)
14
12
  @logger = logger
15
13
  @nexus_config = nexus_config
16
14
  @nexus_ssl_verify = nexus_ssl_verify
@@ -61,17 +59,14 @@ module KPM
61
59
  @nexus_ssl_verify)
62
60
  end
63
61
 
64
-
65
-
66
- def install_plugin(plugin_key, raw_kb_version=nil, specified_group_id=nil, specified_artifact_id=nil, specified_packaging=nil, specified_classifier=nil, specified_version=nil, bundles_dir=nil, specified_type=nil, force_download=false, verify_sha1=true)
62
+ def install_plugin(plugin_key, raw_kb_version=nil, specified_group_id=nil, specified_artifact_id=nil, specified_packaging=nil, specified_classifier=nil, specified_version=nil, bundles_dir=nil, specified_type=nil, force_download=false, verify_sha1=true, verify_jruby_jar=false)
67
63
 
68
64
  # plugin_key needs to exist
69
65
  if plugin_key.nil?
70
- @logger.warn("Aborting installation: User needs to specify a pluginKey")
66
+ @logger.warn('Aborting installation: User needs to specify a pluginKey')
71
67
  return nil
72
68
  end
73
69
 
74
-
75
70
  # Lookup artifact and perform validation against input
76
71
  looked_up_group_id, looked_up_artifact_id, looked_up_packaging, looked_up_classifier, looked_up_version, looked_up_type = KPM::PluginsDirectory.lookup(plugin_key, true, raw_kb_version)
77
72
  return if !validate_installation_arg(plugin_key, 'group_id', specified_group_id, looked_up_group_id)
@@ -109,6 +104,9 @@ module KPM
109
104
  version = specified_version || looked_up_version || LATEST_VERSION
110
105
  destination = plugins_dir.join('java').join(artifact_id).join(version)
111
106
  else
107
+
108
+ warn_if_jruby_jar_missing(bundles_dir) if verify_jruby_jar
109
+
112
110
  group_id = specified_group_id || looked_up_group_id || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID
113
111
  packaging = specified_packaging || looked_up_packaging || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING
114
112
  classifier = specified_classifier || looked_up_classifier || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER
@@ -116,7 +114,8 @@ module KPM
116
114
  destination = plugins_dir.join('ruby')
117
115
  end
118
116
  sha1_file = "#{bundles_dir}/#{SHA1_FILENAME}"
119
-
117
+ plugins_manager = PluginsManager.new(plugins_dir, @logger)
118
+ _, plugin_name = plugins_manager.get_plugin_key_and_name(plugin_key)
120
119
 
121
120
  # Before we do the install we verify that the entry we have in the plugin_identifiers.json matches our current request
122
121
  coordinate_map = {:group_id => group_id, :artifact_id => artifact_id, :packaging => packaging, :classifier => classifier}
@@ -130,6 +129,7 @@ module KPM
130
129
  packaging,
131
130
  classifier,
132
131
  version,
132
+ plugin_name,
133
133
  destination,
134
134
  sha1_file,
135
135
  force_download,
@@ -168,20 +168,19 @@ module KPM
168
168
  artifact_info
169
169
  end
170
170
 
171
- def uninstall_plugin(plugin_key, plugin_version=nil, bundles_dir=nil)
172
-
171
+ def uninstall_plugin(plugin_name_or_key, plugin_version=nil, bundles_dir=nil)
173
172
  bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path
174
173
  plugins_dir = bundles_dir.join('plugins')
175
174
 
176
175
  plugins_manager = PluginsManager.new(plugins_dir, @logger)
177
176
 
178
- plugin_name = plugins_manager.get_plugin_name_from_key(plugin_key)
177
+ plugin_key, plugin_name = plugins_manager.get_plugin_key_and_name(plugin_name_or_key)
179
178
  if plugin_name.nil?
180
- @logger.warn("Cannot uninstall plugin: Unknown plugin_key = #{plugin_key}");
179
+ @logger.warn("Cannot uninstall plugin: Unknown plugin name or plugin key = #{plugin_name_or_key}");
181
180
  return
182
181
  end
183
182
 
184
- modified = plugins_manager.uninstall(plugin_name, plugin_version)
183
+ modified = plugins_manager.uninstall(plugin_name, plugin_version || :all)
185
184
  plugins_manager.remove_plugin_identifier_key(plugin_key)
186
185
  modified
187
186
  end
@@ -262,5 +261,36 @@ module KPM
262
261
  plugins_manager = PluginsManager.new(plugins_dir, @logger)
263
262
  plugins_manager.set_active(artifact_info[:bundle_dir])
264
263
  end
264
+
265
+ def warn_if_jruby_jar_missing(bundles_dir)
266
+ platform_dir = bundles_dir.join('platform')
267
+ jruby_jar = platform_dir.join('jruby.jar')
268
+ if !File.exists?(jruby_jar)
269
+ @logger.warn(" Missing installation for jruby.jar under #{platform_dir}. This is required for ruby plugin installation");
270
+ else
271
+ version = extract_jruby_jar_version(jruby_jar)
272
+ if version
273
+ @logger.info(" Detected jruby.jar version #{version}")
274
+ else
275
+ @logger.warn(" Failed to detect jruby.jar version for #{jruby_jar}");
276
+ end
277
+ end
278
+ end
279
+
280
+ def extract_jruby_jar_version(jruby_jar)
281
+ selected_entries = Zip::File.open(jruby_jar) do |zip_file|
282
+ zip_file.select do |entry|
283
+ entry.name == 'META-INF/maven/org.kill-bill.billing/killbill-platform-osgi-bundles-jruby/pom.properties'
284
+ end
285
+ end
286
+
287
+ if selected_entries && selected_entries.size == 1
288
+ zip_entry = selected_entries[0]
289
+ content = zip_entry.get_input_stream.read
290
+ return content.split("\n").select { |e| e.start_with?("version")}[0].split("=")[1]
291
+ end
292
+ nil
293
+ end
294
+
265
295
  end
266
296
  end
@@ -81,7 +81,7 @@ module KPM
81
81
 
82
82
  infos = []
83
83
  @config['plugins']['java'].each do |plugin|
84
- infos << install_plugin(plugin['name'], nil, plugin['group_id'], plugin['artifact_id'], plugin['packaging'], plugin['classifier'], plugin['version'], @config['plugins_dir'], 'java', force_download, verify_sha1)
84
+ infos << install_plugin(plugin['name'], nil, plugin['group_id'], plugin['artifact_id'], plugin['packaging'], plugin['classifier'], plugin['version'], @config['plugins_dir'], 'java', force_download, verify_sha1, false)
85
85
  end
86
86
 
87
87
  infos
@@ -90,9 +90,11 @@ module KPM
90
90
  def install_ruby_plugins(force_download, verify_sha1)
91
91
  return if @config['plugins'].nil? or @config['plugins']['ruby'].nil?
92
92
 
93
+ verify_jruby_jar=true
93
94
  infos = []
94
95
  @config['plugins']['ruby'].each do |plugin|
95
- infos << install_plugin(plugin['name'], nil, plugin['group_id'], plugin['artifact_id'], plugin['packaging'], plugin['classifier'], plugin['version'], @config['plugins_dir'], 'ruby', force_download, verify_sha1)
96
+ infos << install_plugin(plugin['name'], nil, plugin['group_id'], plugin['artifact_id'], plugin['packaging'], plugin['classifier'], plugin['version'], @config['plugins_dir'], 'ruby', force_download, verify_sha1, verify_jruby_jar)
97
+ verify_jruby_jar=false
96
98
  end
97
99
 
98
100
  infos
@@ -4,6 +4,11 @@ require 'set'
4
4
  module KPM
5
5
  class KillbillPluginArtifact < BaseArtifact
6
6
  class << self
7
+ def pull(logger, group_id, artifact_id, packaging='jar', classifier=nil, version='LATEST', plugin_name=nil, destination_path=nil, sha1_file=nil, force_download=false, verify_sha1=true, overrides={}, ssl_verify=true)
8
+ coordinate_map = {:group_id => group_id, :artifact_id => artifact_id, :packaging => packaging, :classifier => classifier, :version => version}
9
+ pull_and_put_in_place(logger, coordinate_map, plugin_name, destination_path, is_ruby_plugin_and_should_skip_top_dir(group_id, artifact_id), sha1_file, force_download, verify_sha1, overrides, ssl_verify)
10
+ end
11
+
7
12
  def versions(overrides={}, ssl_verify=true)
8
13
  plugins = {:java => {}, :ruby => {}}
9
14
 
@@ -20,6 +25,14 @@ module KPM
20
25
 
21
26
  plugins
22
27
  end
28
+
29
+ protected
30
+ # Magic methods...
31
+
32
+ def is_ruby_plugin_and_should_skip_top_dir(group_id, artifact_id)
33
+ # The second check is for custom ruby plugins
34
+ group_id == KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID || artifact_id.include?('plugin')
35
+ end
23
36
  end
24
37
  end
25
38
  end
@@ -14,6 +14,11 @@ module KPM
14
14
  end
15
15
  end
16
16
 
17
+
18
+ def self.list_plugins(latest=false, kb_version)
19
+ all(latest).inject({}) { |out, (key, val)| out[key]=val[:versions][kb_version.to_sym] if val[:versions].key?(kb_version.to_sym) ; out}
20
+ end
21
+
17
22
  # Note: this API is used in Docker images (see kpm_generator.rb, careful when changing it!)
18
23
  def self.lookup(raw_plugin_key, latest=false, raw_kb_version=nil)
19
24
  plugin_key = raw_plugin_key.to_s.downcase
@@ -89,7 +89,6 @@ module KPM
89
89
  end
90
90
 
91
91
  def remove_plugin_identifier_key(plugin_key)
92
-
93
92
  identifiers = read_plugin_identifiers
94
93
  # If key does not already exists we update it, if not nothing to do.
95
94
  if identifiers.has_key?(plugin_key)
@@ -100,14 +99,18 @@ module KPM
100
99
  identifiers
101
100
  end
102
101
 
103
-
104
- def get_plugin_name_from_key(plugin_key)
102
+ def get_plugin_key_and_name(plugin_name_or_key)
105
103
  identifiers = read_plugin_identifiers
106
- return nil if identifiers.nil? || !identifiers.has_key?(plugin_key)
107
- identifiers[plugin_key]['plugin_name']
104
+ if identifiers.has_key?(plugin_name_or_key)
105
+ # It's a plugin key
106
+ [plugin_name_or_key, identifiers[plugin_name_or_key]['plugin_name']]
107
+ else
108
+ # Check it's already a plugin name
109
+ identifiers.each { |plugin_key, entry| return [plugin_key, plugin_name_or_key] if entry['plugin_name'] == plugin_name_or_key }
110
+ nil
111
+ end
108
112
  end
109
113
 
110
-
111
114
  def guess_plugin_name(artifact_id)
112
115
  return nil if artifact_id.nil?
113
116
  captures = artifact_id.scan(/(.*)-plugin/)
@@ -44,7 +44,7 @@ module KPM
44
44
  :type => :boolean,
45
45
  :default => true,
46
46
  :desc => 'Validate sha1 sum'
47
- desc 'pull_kb_server_war version', 'Pulls Kill Bill server war from Sonatype and places it on your machine.'
47
+ desc 'pull_kb_server_war <version>', 'Pulls Kill Bill server war from Sonatype and places it on your machine. If version was not specified it uses the latest released version.'
48
48
  def pull_kb_server_war(version='LATEST')
49
49
  response = KillbillServerArtifact.pull(logger,
50
50
  KillbillServerArtifact::KILLBILL_GROUP_ID,
@@ -82,7 +82,7 @@ module KPM
82
82
  :type => :boolean,
83
83
  :default => true,
84
84
  :desc => 'Validates sha1 sum'
85
- desc 'pull_kp_server_war version', 'Pulls Kill Pay server war from Sonatype and places it on your machine.'
85
+ desc 'pull_kp_server_war <version>', 'Pulls Kill Pay server war from Sonatype and places it on your machine. If version was not specified it uses the latest released version.'
86
86
  def pull_kp_server_war(version='LATEST')
87
87
  response = KillbillServerArtifact.pull(logger,
88
88
  KillbillServerArtifact::KILLBILL_GROUP_ID,
@@ -108,6 +108,26 @@ module KPM
108
108
  options[:ssl_verify]).to_a.join(', ')}", :green
109
109
  end
110
110
 
111
+ method_option :group_id,
112
+ :type => :string,
113
+ :default => KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID,
114
+ :desc => 'The plugin artifact group-id'
115
+ method_option :artifact_id,
116
+ :type => :string,
117
+ :default => nil,
118
+ :desc => 'The plugin artifact id'
119
+ method_option :version,
120
+ :type => :string,
121
+ :default => nil,
122
+ :desc => 'The plugin artifact version'
123
+ method_option :packaging,
124
+ :type => :string,
125
+ :default => KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING,
126
+ :desc => 'The plugin artifact packaging'
127
+ method_option :classifier,
128
+ :type => :string,
129
+ :default => KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER,
130
+ :desc => 'The plugin artifact classifier'
111
131
  method_option :destination,
112
132
  :type => :string,
113
133
  :default => nil,
@@ -124,23 +144,49 @@ module KPM
124
144
  :type => :boolean,
125
145
  :default => true,
126
146
  :desc => 'Validates sha1 sum'
127
- desc 'pull_java_plugin artifact_id', 'Pulls a java plugin from Sonatype and places it on your machine.'
128
- def pull_java_plugin(artifact_id, version='LATEST')
129
- response = KillbillPluginArtifact.pull(logger,
130
- KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID,
131
- artifact_id,
132
- KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING,
133
- KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER,
134
- version,
135
- options[:destination],
136
- options[:sha1_file],
137
- options[:force_download],
138
- options[:verify_sha1],
139
- options[:overrides],
140
- options[:ssl_verify])
147
+ desc 'pull_java_plugin plugin-key <kb-version>', 'Pulls a java plugin from Sonatype and installs it under the specified destination. If the kb-version has been specified, it is used to download the matching plugin artifact version; if not, it uses the specified plugin version or if null, the LATEST one.'
148
+ def pull_java_plugin(plugin_key, kb_version='LATEST')
149
+
150
+ response = BaseInstaller.new(logger,
151
+ options[:overrides],
152
+ options[:ssl_verify]).install_plugin(plugin_key,
153
+ kb_version,
154
+ options[:group_id],
155
+ options[:artifact_id],
156
+ options[:packaging],
157
+ options[:classifier],
158
+ options[:version],
159
+ options[:destination],
160
+ 'java',
161
+ options[:force_download],
162
+ options[:verify_sha1],
163
+ false)
141
164
  say "Artifact has been retrieved and can be found at path: #{response[:file_path]}", :green
142
165
  end
143
166
 
167
+
168
+
169
+
170
+ method_option :group_id,
171
+ :type => :string,
172
+ :default => KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID,
173
+ :desc => 'The plugin artifact group-id'
174
+ method_option :artifact_id,
175
+ :type => :string,
176
+ :default => nil,
177
+ :desc => 'The plugin artifact id'
178
+ method_option :version,
179
+ :type => :string,
180
+ :default => nil,
181
+ :desc => 'The plugin artifact version'
182
+ method_option :packaging,
183
+ :type => :string,
184
+ :default => KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING,
185
+ :desc => 'The plugin artifact packaging'
186
+ method_option :classifier,
187
+ :type => :string,
188
+ :default => KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER,
189
+ :desc => 'The plugin artifact classifier'
144
190
  method_option :destination,
145
191
  :type => :string,
146
192
  :default => nil,
@@ -157,21 +203,24 @@ module KPM
157
203
  :type => :boolean,
158
204
  :default => true,
159
205
  :desc => 'Validates sha1 sum'
160
- desc 'pull_ruby_plugin artifact_id', 'Pulls a ruby plugin from Sonatype and places it on your machine.'
161
- def pull_ruby_plugin(artifact_id, version='LATEST')
162
- response = KillbillPluginArtifact.pull(logger,
163
- KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID,
164
- artifact_id,
165
- KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING,
166
- KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER,
167
- version,
168
- options[:destination],
169
- options[:sha1_file],
170
- options[:force_download],
171
- options[:verify_sha1],
172
- options[:overrides],
173
- options[:ssl_verify])
206
+ desc 'pull_ruby_plugin plugin-key <kb-version>', 'Pulls a ruby plugin from Sonatype and installs it under the specified destination. If the kb-version has been specified, it is used to download the matching plugin artifact version; if not, it uses the specified plugin version or if null, the LATEST one.'
207
+ def pull_ruby_plugin(plugin_key, kb_version='LATEST')
208
+ response = BaseInstaller.new(logger,
209
+ options[:overrides],
210
+ options[:ssl_verify]).install_plugin(plugin_key,
211
+ kb_version,
212
+ options[:group_id],
213
+ options[:artifact_id],
214
+ options[:packaging],
215
+ options[:classifier],
216
+ options[:version],
217
+ options[:destination],
218
+ 'ruby',
219
+ options[:force_download],
220
+ options[:verify_sha1],
221
+ true)
174
222
  say "Artifact has been retrieved and can be found at path: #{response[:file_path]}", :green
223
+
175
224
  end
176
225
 
177
226
  method_option :destination,
@@ -186,7 +235,7 @@ module KPM
186
235
  :type => :boolean,
187
236
  :default => true,
188
237
  :desc => 'Validates sha1 sum'
189
- desc 'pull_defaultbundles', 'Pulls the default OSGI bundles from Sonatype and places it on your machine.'
238
+ desc 'pull_defaultbundles <kb-version>', 'Pulls the default OSGI bundles from Sonatype and places it on your machine. If the kb-version has been specified, it is used to download the matching platform artifact; if not, it uses the latest released version.'
190
239
  def pull_defaultbundles(kb_version='LATEST')
191
240
  response = BaseInstaller.new(logger,
192
241
  options[:overrides],
@@ -230,7 +279,7 @@ module KPM
230
279
  :type => :boolean,
231
280
  :default => true,
232
281
  :desc => 'Validates sha1 sum'
233
- desc 'pull_kaui_war version', 'Pulls Kaui war from Sonatype and places it on your machine.'
282
+ desc 'pull_kaui_war <version>', 'Pulls Kaui war from Sonatype and places it on your machine. If version was not specified it uses the latest released version.'
234
283
  def pull_kaui_war(version='LATEST')
235
284
  response = KauiArtifact.pull(logger,
236
285
  KauiArtifact::KAUI_GROUP_ID,
@@ -258,11 +307,21 @@ module KPM
258
307
  :desc => 'Kill Bill version'
259
308
  desc 'info', 'Describe information about a Kill Bill version'
260
309
  def info
261
- info = KillbillServerArtifact.info(options[:version],
310
+
311
+ say "Fetching info for version #{options[:version]}...\n"
312
+
313
+ versions_info = KillbillServerArtifact.info(options[:version],
262
314
  options[:overrides],
263
315
  options[:ssl_verify])
316
+ say "Dependencies for version #{options[:version]}\n " + (versions_info.map {|k,v| "#{k} #{v}"}).join("\n "), :green
317
+ say "\n\n"
318
+
319
+ resolved_kb_version = versions_info['killbill']
320
+ kb_version = resolved_kb_version.split('.').slice(0,2).join(".")
321
+
322
+ plugins_info = KPM::PluginsDirectory.list_plugins(true, kb_version)
264
323
 
265
- say "Dependencies for version #{options[:version]}\n " + (info.map {|k,v| "#{k} #{v}"}).join("\n "), :green
324
+ say "Known plugin for KB version #{options[:version]}\n " + (plugins_info.map {|k,v| "#{k} #{v}"}).join("\n "), :green
266
325
  end
267
326
 
268
327
  private
@@ -1,3 +1,3 @@
1
1
  module KPM
2
- VERSION = '0.1.7'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -25,29 +25,6 @@ describe KPM::BaseArtifact do
25
25
  end
26
26
  end
27
27
 
28
- # This test makes sure the top level directory is correctly verify_is_skipped
29
- it 'should be able to download and verify .tar.gz ruby artifacts' do
30
- # Use the payment-test-plugin as a test, as it is fairly small (2.5M)
31
- group_id = 'org.kill-bill.billing.plugin.ruby'
32
- artifact_id = 'payment-test-plugin'
33
- packaging = 'tar.gz'
34
- classifier = nil
35
- version = '1.8.7'
36
-
37
- Dir.mktmpdir do |dir|
38
- info = KPM::BaseArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, dir)
39
- info[:file_name].should be_nil
40
-
41
- files_in_dir = Dir[info[:file_path] + '/*']
42
- files_in_dir.size.should == 1
43
- files_in_dir[0].should == info[:file_path] + '/killbill-payment-test'
44
-
45
- File.read(info[:file_path] + '/killbill-payment-test/1.8.7/killbill.properties').should == "mainClass=PaymentTest::PaymentPlugin\nrequire=payment_test\npluginType=PAYMENT\n"
46
-
47
- info[:bundle_dir].should == info[:file_path] + '/killbill-payment-test/1.8.7'
48
- end
49
- end
50
-
51
28
  it 'should be able to download and verify generic .tar.gz artifacts' do
52
29
  # The artifact is not small unfortunately (23.7M)
53
30
  group_id = 'org.kill-bill.billing'
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe KPM::BaseInstaller do
5
+
6
+ before(:all) do
7
+ @logger = Logger.new(STDOUT)
8
+ @logger.level = Logger::INFO
9
+ end
10
+
11
+ it 'should be able to uninstall via plugin key' do
12
+ Dir.mktmpdir do |dir|
13
+ bundles_dir = dir + '/bundles'
14
+ installer = KPM::BaseInstaller.new(@logger)
15
+
16
+ info = installer.install_plugin('analytics', nil, nil, nil, nil, nil, '0.7.1', bundles_dir)
17
+
18
+ check_installation(bundles_dir)
19
+
20
+ installer.uninstall_plugin('analytics', nil, bundles_dir)
21
+
22
+ check_uninstallation(bundles_dir)
23
+ end
24
+ end
25
+
26
+ # See https://github.com/killbill/killbill-cloud/issues/14
27
+ it 'should be able to uninstall via plugin name' do
28
+ Dir.mktmpdir do |dir|
29
+ bundles_dir = dir + '/bundles'
30
+ installer = KPM::BaseInstaller.new(@logger)
31
+
32
+ installer.install_plugin('analytics', nil, nil, nil, nil, nil, '0.7.1', bundles_dir)
33
+
34
+ check_installation(bundles_dir)
35
+
36
+ installer.uninstall_plugin('analytics-plugin', nil, bundles_dir)
37
+
38
+ check_uninstallation(bundles_dir)
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def check_installation(plugins_dir)
45
+ common_checks(plugins_dir)
46
+
47
+ plugin_identifiers = read_plugin_identifiers(plugins_dir)
48
+
49
+ plugin_identifiers.size.should == 1
50
+
51
+ plugin_identifiers['analytics']['plugin_name'].should == 'analytics-plugin'
52
+ plugin_identifiers['analytics']['group_id'].should == 'org.kill-bill.billing.plugin.java'
53
+ plugin_identifiers['analytics']['artifact_id'].should == 'analytics-plugin'
54
+ plugin_identifiers['analytics']['packaging'].should == 'jar'
55
+ plugin_identifiers['analytics']['version'].should == '0.7.1'
56
+ plugin_identifiers['analytics']['language'].should == 'java'
57
+
58
+ File.file?(plugins_dir + '/plugins/java/analytics-plugin/0.7.1/tmp/disabled.txt').should be_false
59
+ end
60
+
61
+ def check_uninstallation(plugins_dir)
62
+ common_checks(plugins_dir)
63
+
64
+ plugin_identifiers = read_plugin_identifiers(plugins_dir)
65
+
66
+ plugin_identifiers.size.should == 0
67
+
68
+ File.file?(plugins_dir + '/plugins/java/analytics-plugin/0.7.1/tmp/disabled.txt').should be_true
69
+ end
70
+
71
+ def common_checks(plugins_dir)
72
+ [
73
+ plugins_dir,
74
+ plugins_dir + '/plugins',
75
+ plugins_dir + '/plugins/java',
76
+ plugins_dir + '/plugins/java/analytics-plugin',
77
+ plugins_dir + '/plugins/java/analytics-plugin/0.7.1',
78
+ plugins_dir + '/plugins/java/analytics-plugin/0.7.1/tmp',
79
+ ].each do |dir|
80
+ File.directory?(dir).should be_true
81
+ end
82
+
83
+ [
84
+ plugins_dir + '/plugins/plugin_identifiers.json',
85
+ plugins_dir + '/plugins/java/analytics-plugin/0.7.1/analytics-plugin-0.7.1.jar'
86
+ ].each do |file|
87
+ File.file?(file).should be_true
88
+ end
89
+ end
90
+
91
+ def read_plugin_identifiers(plugins_dir)
92
+ File.open(plugins_dir + '/plugins/plugin_identifiers.json', 'r') do |f|
93
+ JSON.parse(f.read)
94
+ end
95
+ end
96
+ end
@@ -7,6 +7,30 @@ describe KPM::KillbillPluginArtifact do
7
7
  @logger.level = Logger::INFO
8
8
  end
9
9
 
10
+ # This test makes sure the top level directory is correctly verify_is_skipped
11
+ it 'should be able to download and verify .tar.gz ruby artifacts' do
12
+ # Use the payment-test-plugin as a test, as it is fairly small (2.5M)
13
+ group_id = 'org.kill-bill.billing.plugin.ruby'
14
+ artifact_id = 'payment-test-plugin'
15
+ packaging = 'tar.gz'
16
+ classifier = nil
17
+ version = '1.8.7'
18
+ plugin_name = 'killbill-payment-test'
19
+
20
+ Dir.mktmpdir do |dir|
21
+ info = KPM::KillbillPluginArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, plugin_name, dir)
22
+ info[:file_name].should be_nil
23
+
24
+ files_in_dir = Dir[info[:file_path] + '/*']
25
+ files_in_dir.size.should == 1
26
+ files_in_dir[0].should == info[:file_path] + '/killbill-payment-test'
27
+
28
+ File.read(info[:file_path] + '/killbill-payment-test/1.8.7/killbill.properties').should == "mainClass=PaymentTest::PaymentPlugin\nrequire=payment_test\npluginType=PAYMENT\n"
29
+
30
+ info[:bundle_dir].should == info[:file_path] + '/killbill-payment-test/1.8.7'
31
+ end
32
+ end
33
+
10
34
  it 'should be able to download and verify artifacts' do
11
35
  Dir.mktmpdir do |dir|
12
36
  sha1_file = dir + '/sha1.yml'
@@ -16,6 +40,7 @@ describe KPM::KillbillPluginArtifact do
16
40
  KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING,
17
41
  KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER,
18
42
  'LATEST',
43
+ 'killbill-analytics',
19
44
  dir,
20
45
  sha1_file)
21
46
  info[:file_name].should == "analytics-plugin-#{info[:version]}.jar"
@@ -32,6 +57,7 @@ describe KPM::KillbillPluginArtifact do
32
57
  KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING,
33
58
  KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER,
34
59
  'LATEST',
60
+ 'killbill-analytics',
35
61
  dir,
36
62
  sha1_file)
37
63
 
metadata CHANGED
@@ -1,91 +1,105 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-23 00:00:00.000000000 Z
11
+ date: 2016-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.6.21
20
- requirement: !ruby/object:Gem::Requirement
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
21
23
  requirements:
22
- - - ~>
24
+ - - "~>"
23
25
  - !ruby/object:Gem::Version
24
26
  version: 1.6.21
25
- prerelease: false
26
- type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nexus_cli
29
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 4.1.0
34
- requirement: !ruby/object:Gem::Requirement
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
35
37
  requirements:
36
- - - ~>
38
+ - - "~>"
37
39
  - !ruby/object:Gem::Version
38
40
  version: 4.1.0
39
- prerelease: false
40
- type: :runtime
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.19.1
48
+ type: :runtime
49
+ prerelease: false
43
50
  version_requirements: !ruby/object:Gem::Requirement
44
51
  requirements:
45
- - - ~>
52
+ - - "~>"
46
53
  - !ruby/object:Gem::Version
47
54
  version: 0.19.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubyzip
48
57
  requirement: !ruby/object:Gem::Requirement
49
58
  requirements:
50
- - - ~>
59
+ - - "~>"
51
60
  - !ruby/object:Gem::Version
52
- version: 0.19.1
53
- prerelease: false
61
+ version: 1.2.0
54
62
  type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
- version_requirements: !ruby/object:Gem::Requirement
71
+ requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: 10.0.0
62
- - - <
76
+ - - "<"
63
77
  - !ruby/object:Gem::Version
64
78
  version: 11.0.0
65
- requirement: !ruby/object:Gem::Requirement
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
66
82
  requirements:
67
- - - '>='
83
+ - - ">="
68
84
  - !ruby/object:Gem::Version
69
85
  version: 10.0.0
70
- - - <
86
+ - - "<"
71
87
  - !ruby/object:Gem::Version
72
88
  version: 11.0.0
73
- prerelease: false
74
- type: :development
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: rspec
77
- version_requirements: !ruby/object:Gem::Requirement
91
+ requirement: !ruby/object:Gem::Requirement
78
92
  requirements:
79
- - - ~>
93
+ - - "~>"
80
94
  - !ruby/object:Gem::Version
81
95
  version: 2.12.0
82
- requirement: !ruby/object:Gem::Requirement
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
83
99
  requirements:
84
- - - ~>
100
+ - - "~>"
85
101
  - !ruby/object:Gem::Version
86
102
  version: 2.12.0
87
- prerelease: false
88
- type: :development
89
103
  description: A package manager for Kill Bill.
90
104
  email: killbilling-users@googlegroups.com
91
105
  executables:
@@ -93,8 +107,8 @@ executables:
93
107
  extensions: []
94
108
  extra_rdoc_files: []
95
109
  files:
96
- - .gemrelease
97
- - .gitignore
110
+ - ".gemrelease"
111
+ - ".gitignore"
98
112
  - Gemfile
99
113
  - README.md
100
114
  - Rakefile
@@ -118,6 +132,7 @@ files:
118
132
  - lib/kpm/utils.rb
119
133
  - lib/kpm/version.rb
120
134
  - spec/kpm/remote/base_artifact_spec.rb
135
+ - spec/kpm/remote/base_installer_spec.rb
121
136
  - spec/kpm/remote/installer_spec.rb
122
137
  - spec/kpm/remote/kaui_artifact_spec.rb
123
138
  - spec/kpm/remote/killbill_plugin_artifact_spec.rb
@@ -133,26 +148,39 @@ homepage: http://kill-bill.org
133
148
  licenses:
134
149
  - Apache License (2.0)
135
150
  metadata: {}
136
- post_install_message:
151
+ post_install_message:
137
152
  rdoc_options:
138
- - --exclude
139
- - .
153
+ - "--exclude"
154
+ - "."
140
155
  require_paths:
141
156
  - lib
142
157
  required_ruby_version: !ruby/object:Gem::Requirement
143
158
  requirements:
144
- - - '>='
159
+ - - ">="
145
160
  - !ruby/object:Gem::Version
146
161
  version: 1.8.6
147
162
  required_rubygems_version: !ruby/object:Gem::Requirement
148
163
  requirements:
149
- - - '>='
164
+ - - ">="
150
165
  - !ruby/object:Gem::Version
151
166
  version: '0'
152
167
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.1.9
155
- signing_key:
168
+ rubyforge_project:
169
+ rubygems_version: 2.2.2
170
+ signing_key:
156
171
  specification_version: 4
157
172
  summary: Kill Bill package manager.
158
- test_files: []
173
+ test_files:
174
+ - spec/kpm/remote/base_artifact_spec.rb
175
+ - spec/kpm/remote/base_installer_spec.rb
176
+ - spec/kpm/remote/installer_spec.rb
177
+ - spec/kpm/remote/kaui_artifact_spec.rb
178
+ - spec/kpm/remote/killbill_plugin_artifact_spec.rb
179
+ - spec/kpm/remote/killbill_server_artifact_spec.rb
180
+ - spec/kpm/remote/tomcat_manager_spec.rb
181
+ - spec/kpm/unit/base_artifact_spec.rb
182
+ - spec/kpm/unit/plugins_directory_spec.rb
183
+ - spec/kpm/unit/plugins_manager_spec.rb
184
+ - spec/kpm/unit/sha1_checker_spec.rb
185
+ - spec/kpm/unit/sha1_test.yml
186
+ - spec/spec_helper.rb