kpm 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5c4a2af61cc4abb65b686a98e4cced0845bc310
4
- data.tar.gz: 376118a4f0b8110189a67314b827967bcf895b97
3
+ metadata.gz: 4006872829cb16464b5567e8ab5d1f58cdb62867
4
+ data.tar.gz: 5b1db83cc94abdf91430b0fcfe2882616b826d75
5
5
  SHA512:
6
- metadata.gz: ad9acead1e4809fe5d06765cbf3d0d85cc33954a61883ffc929b55fc979c331f441a6630505f0d70a1cdb859b9d3b7ec23f2742415c4e40fcb9282aff468f6c6
7
- data.tar.gz: a02faaf79cf0eb6ba9228f7683eaef41702085b5193d3eb32011959db29a2b26d8ef3efb8a7a526dbc46ccedfe4c4bde0e8c1739b86941ede714b72b50b3745f
6
+ metadata.gz: 541bedab598e86c0a1b09d0a6b64a166525acff629ddef683dac996810f9b1ebd26036ce4d3ea53e1fde85b36c39e1a0b02a2b95bc6583a404712dfbad67a89c
7
+ data.tar.gz: 9ae353b4d8de4a27444ec8116ba6ed1ae8de7da408b2a0249a86d3497a46455b85d4939713e8b109a84e9b01ce0e9b59a21bf82bc79de2322c23c9ea2f78c04a
@@ -171,6 +171,9 @@ module KPM
171
171
  nexus_info = nexus_remote(overrides, ssl_verify).get_artifact_info(coordinates)
172
172
  rescue NexusCli::ArtifactMalformedException => e
173
173
  raise NexusCli::NexusCliError.new("Invalid coordinates #{coordinate_map}")
174
+ rescue NexusCli::NexusCliError => e
175
+ logger.warn("Unable to retrieve coordinates #{coordinate_map}")
176
+ raise e
174
177
  end
175
178
 
176
179
  xml = REXML::Document.new(nexus_info)
@@ -68,17 +68,16 @@ module KPM
68
68
 
69
69
  # plugin_key needs to exist
70
70
  if plugin_key.nil?
71
- @logger.warn('Aborting installation: User needs to specify a pluginKey')
72
- return nil
71
+ raise ArgumentError.new 'Aborting installation: User needs to specify a pluginKey'
73
72
  end
74
73
 
75
74
  # Lookup artifact and perform validation against input
76
75
  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
- return if !validate_installation_arg(plugin_key, 'group_id', specified_group_id, looked_up_group_id)
78
- return if !validate_installation_arg(plugin_key, 'artifact_id', specified_artifact_id, looked_up_artifact_id)
79
- return if !validate_installation_arg(plugin_key, 'packaging', specified_packaging, looked_up_packaging)
80
- return if !validate_installation_arg(plugin_key, 'type', specified_type, looked_up_type)
81
- return if !validate_installation_arg(plugin_key, 'classifier', specified_classifier, looked_up_classifier)
76
+ validate_installation_arg!(plugin_key, 'group_id', specified_group_id, looked_up_group_id)
77
+ validate_installation_arg!(plugin_key, 'artifact_id', specified_artifact_id, looked_up_artifact_id)
78
+ validate_installation_arg!(plugin_key, 'packaging', specified_packaging, looked_up_packaging)
79
+ validate_installation_arg!(plugin_key, 'type', specified_type, looked_up_type)
80
+ validate_installation_arg!(plugin_key, 'classifier', specified_classifier, looked_up_classifier)
82
81
 
83
82
 
84
83
  # If there is no entry in plugins_directory.yml and the group_id is not the killbill default group_id, the key provided must be a user key and must have a namespace
@@ -86,16 +85,14 @@ module KPM
86
85
  specified_group_id != KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID &&
87
86
  specified_group_id != KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID &&
88
87
  plugin_key.split(':').size == 1
89
- @logger.warn("Aborting installation: pluginKey = #{plugin_key} does not exist in plugin_directory.yml so format of the key must have a user namespace (e.g namespace:key)")
90
- return nil
88
+ raise ArgumentError.new "Aborting installation: pluginKey = #{plugin_key} does not exist in plugin_directory.yml so format of the key must have a user namespace (e.g namespace:key)"
91
89
  end
92
90
 
93
91
 
94
92
  # Specified parameters have always precedence except for the artifact_id (to map stripe to stripe-plugin)
95
93
  artifact_id = looked_up_artifact_id || specified_artifact_id
96
94
  if artifact_id.nil?
97
- @logger.warn("Aborting installation: unable to lookup plugin #{specified_artifact_id}")
98
- return nil
95
+ raise ArgumentError.new "Aborting installation: unable to lookup plugin #{specified_artifact_id}"
99
96
  end
100
97
 
101
98
  bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path
@@ -124,7 +121,7 @@ module KPM
124
121
 
125
122
  # Before we do the install we verify that the entry we have in the plugin_identifiers.json matches our current request
126
123
  coordinate_map = {:group_id => group_id, :artifact_id => artifact_id, :packaging => packaging, :classifier => classifier}
127
- return if !validate_plugin_key(plugins_dir, plugin_key, coordinate_map)
124
+ validate_plugin_key!(plugins_dir, plugin_key, coordinate_map)
128
125
 
129
126
 
130
127
  @logger.debug("Installing plugin: group_id=#{group_id} artifact_id=#{artifact_id} packaging=#{packaging} classifier=#{classifier} version=#{version} destination=#{destination}")
@@ -182,8 +179,7 @@ module KPM
182
179
 
183
180
  plugin_key, plugin_name = plugins_manager.get_plugin_key_and_name(plugin_name_or_key)
184
181
  if plugin_name.nil?
185
- @logger.warn("Cannot uninstall plugin: Unknown plugin name or plugin key = #{plugin_name_or_key}");
186
- return
182
+ raise ArgumentError.new "Cannot uninstall plugin: Unknown plugin name or plugin key = #{plugin_name_or_key}"
187
183
  end
188
184
 
189
185
  modified = plugins_manager.uninstall(plugin_name, plugin_version || :all)
@@ -233,24 +229,22 @@ module KPM
233
229
 
234
230
  private
235
231
 
236
- def validate_installation_arg(plugin_key, arg_type, specified_arg, looked_up_arg)
232
+ def validate_installation_arg!(plugin_key, arg_type, specified_arg, looked_up_arg)
237
233
 
238
234
  # If nothing was specified, or if we don't find anything from the lookup, nothing to validate against
239
235
  if specified_arg.nil? || looked_up_arg.nil?
240
- return true
236
+ return
241
237
  end
242
238
 
243
239
  if specified_arg.to_s != looked_up_arg.to_s
244
- @logger.warn("Aborting installation for plugin_key #{plugin_key}: specified value #{specified_arg} for #{arg_type} does not match looked_up value #{looked_up_arg}")
245
- return false
240
+ raise ArgumentError.new "Aborting installation for plugin_key #{plugin_key}: specified value #{specified_arg} for #{arg_type} does not match looked_up value #{looked_up_arg}"
246
241
  end
247
-
248
- true
249
242
  end
250
243
 
251
- def validate_plugin_key(plugins_dir, plugin_key, coordinate_map)
244
+ def validate_plugin_key!(plugins_dir, plugin_key, coordinate_map)
252
245
  plugins_manager = PluginsManager.new(plugins_dir, @logger)
253
- return plugins_manager.validate_plugin_identifier_key(plugin_key, coordinate_map)
246
+ res = plugins_manager.validate_plugin_identifier_key(plugin_key, coordinate_map)
247
+ raise ArgumentError.new "Failed to validate plugin key #{plugin_key}" if !res
254
248
  end
255
249
 
256
250
  def update_plugin_identifier(plugins_dir, plugin_key, type, coordinate_map, artifact_info)
data/lib/kpm/installer.rb CHANGED
@@ -8,13 +8,34 @@ module KPM
8
8
  def self.from_file(config_path=nil, logger=nil)
9
9
  if config_path.nil?
10
10
  # Install Kill Bill, Kaui and the KPM plugin by default
11
- config = {'killbill' => {'version' => 'LATEST', 'plugins' => {'ruby' => [{'name' => 'kpm'}]}}, 'kaui' => {'version' => 'LATEST'}}
11
+ config = build_default_config
12
12
  else
13
13
  config = YAML::load_file(config_path)
14
14
  end
15
15
  Installer.new(config, logger)
16
16
  end
17
17
 
18
+ def self.build_default_config(all_kb_versions=nil)
19
+ all_kb_versions ||= KillbillServerArtifact.versions(KillbillServerArtifact::KILLBILL_ARTIFACT_ID,
20
+ KillbillServerArtifact::KILLBILL_PACKAGING,
21
+ KillbillServerArtifact::KILLBILL_CLASSIFIER,
22
+ nil,
23
+ true).to_a
24
+ latest_stable_version = Gem::Version.new('0.0.0')
25
+ all_kb_versions.each do |kb_version|
26
+ version = Gem::Version.new(kb_version) rescue nil
27
+ next if version.nil?
28
+
29
+ major, minor, patch, pre = version.segments
30
+ next if !pre.nil? || minor.nil? || minor.to_i.odd?
31
+
32
+ latest_stable_version = version if version > latest_stable_version
33
+ end
34
+
35
+ # Note: we assume no unstable version of Kaui is published today
36
+ {'killbill' => {'version' => latest_stable_version.to_s, 'plugins' => {'ruby' => [{'name' => 'kpm'}]}}, 'kaui' => {'version' => 'LATEST'}}
37
+ end
38
+
18
39
  def initialize(raw_config, logger=nil)
19
40
  @config = raw_config['killbill']
20
41
  @kaui_config = raw_config['kaui']
@@ -13,7 +13,7 @@
13
13
  :versions:
14
14
  :0.14: 0.1.0
15
15
  :0.15: 0.2.1
16
- :0.16: 0.3.0
16
+ :0.16: 0.3.2
17
17
  :require:
18
18
  - :org.killbill.billing.plugin.adyen.merchantAccount
19
19
  - :org.killbill.billing.plugin.adyen.username
@@ -57,7 +57,7 @@
57
57
  :versions:
58
58
  :0.14: 1.0.0
59
59
  :0.15: 3.3.0
60
- :0.16: 4.0.6
60
+ :0.16: 4.0.7
61
61
  :stable_version: 0.0.4
62
62
  :require:
63
63
  - :login
@@ -94,6 +94,7 @@
94
94
  :versions:
95
95
  :0.15: 0.0.2
96
96
  :0.16: 0.0.5
97
+ :0.17: 1.0.0
97
98
  :litle:
98
99
  :type: :ruby
99
100
  :versions:
@@ -119,7 +120,7 @@
119
120
  :versions:
120
121
  :0.14: 2.0.0
121
122
  :0.15: 3.0.0
122
- :0.16: 4.1.3
123
+ :0.16: 4.1.5
123
124
  :stable_version: 2.0.0
124
125
  :require:
125
126
  - :signature
@@ -148,6 +149,7 @@
148
149
  :0.14: 1.0.0
149
150
  :0.15: 2.0.0
150
151
  :0.16: 3.0.3
152
+ :0.17: 4.0.0
151
153
  :stable_version: 2.0.0
152
154
  :require:
153
155
  - :api_secret_key
data/lib/kpm/tasks.rb CHANGED
@@ -3,12 +3,20 @@ require 'logger'
3
3
  require 'thor'
4
4
  require 'pathname'
5
5
 
6
+ require 'kpm/version'
7
+
6
8
  module KPM
7
9
  module Tasks
8
10
  def self.included(base)
9
11
  base.send :include, ::Thor::Actions
10
12
  base.class_eval do
11
13
 
14
+
15
+ desc 'KPM version', 'Return current KPM version.'
16
+ def version
17
+ say "KPM version #{KPM::VERSION}"
18
+ end
19
+
12
20
  class_option :overrides,
13
21
  :type => :hash,
14
22
  :default => nil,
data/lib/kpm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KPM
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -39,6 +39,20 @@ describe KPM::BaseInstaller do
39
39
  end
40
40
  end
41
41
 
42
+ it 'should raise an exception when plugin does not exist' do
43
+ Dir.mktmpdir do |dir|
44
+ bundles_dir = dir + '/bundles'
45
+ installer = KPM::BaseInstaller.new(@logger)
46
+
47
+ begin
48
+ installer.install_plugin('invalid', nil, nil, nil, nil, nil, '1.2.3', bundles_dir)
49
+ fail "Should not succeed to install invalid plugin"
50
+ rescue ArgumentError => e
51
+ end
52
+ end
53
+ end
54
+
55
+
42
56
  private
43
57
 
44
58
  def check_installation(plugins_dir)
@@ -18,7 +18,7 @@ describe KPM::Migrations do
18
18
 
19
19
  context 'killbill' do
20
20
  it 'should be able to find migrations between two versions' do
21
- migrations = KPM::Migrations.new('work-for-release-0.16.3', 'work-for-release-0.16.4', 'killbill/killbill', ENV['TOKEN']).migrations
21
+ migrations = KPM::Migrations.new('killbill-0.16.3', 'killbill-0.16.4', 'killbill/killbill', ENV['TOKEN']).migrations
22
22
 
23
23
  migrations.size.should == 1
24
24
  migrations.first[:name].should == 'V20160324060345__revisit_payment_methods_indexes_509.sql'
@@ -28,7 +28,7 @@ describe KPM::Migrations do
28
28
  end
29
29
 
30
30
  it 'should be able to find migrations for a given version' do
31
- migrations = KPM::Migrations.new('work-for-release-0.16.4', nil, 'killbill/killbill', ENV['TOKEN']).migrations
31
+ migrations = KPM::Migrations.new('killbill-0.16.4', nil, 'killbill/killbill', ENV['TOKEN']).migrations
32
32
 
33
33
  migrations.size.should == 1
34
34
  migrations.first[:name].should == 'V20160324060345__revisit_payment_methods_indexes_509.sql'
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe KPM::Installer do
4
+
5
+ context 'when no config file is specified' do
6
+ let(:all_kb_versions) { %w(0.15.0 0.15.1 0.15.10 0.15.11-SNAPSHOT 0.15.2 0.15.3 0.16.0 0.16.1 0.16.10 0.16.11 0.16.12-SNAPSHOT 0.16.2 0.16.3 0.17.0 0.17.1 0.17.2 0.17.2-SNAPSHOT 0.17.3-SNAPSHOT) }
7
+
8
+ it 'finds the right stable versions' do
9
+ config = KPM::Installer.build_default_config(all_kb_versions)
10
+ config['killbill'].should_not be_nil
11
+ config['killbill']['version'].should == '0.16.11'
12
+
13
+ config['kaui'].should_not be_nil
14
+ config['kaui']['version'].should == 'LATEST'
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-17 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -146,6 +146,7 @@ files:
146
146
  - spec/kpm/remote/tomcat_manager_spec.rb
147
147
  - spec/kpm/unit/base_artifact_spec.rb
148
148
  - spec/kpm/unit/inspector_spec.rb
149
+ - spec/kpm/unit/installer_spec.rb
149
150
  - spec/kpm/unit/plugins_directory_spec.rb
150
151
  - spec/kpm/unit/plugins_manager_spec.rb
151
152
  - spec/kpm/unit/sha1_checker_spec.rb
@@ -178,20 +179,4 @@ rubygems_version: 2.4.6
178
179
  signing_key:
179
180
  specification_version: 4
180
181
  summary: Kill Bill package manager.
181
- test_files:
182
- - spec/kpm/remote/base_artifact_spec.rb
183
- - spec/kpm/remote/base_installer_spec.rb
184
- - spec/kpm/remote/installer_spec.rb
185
- - spec/kpm/remote/kaui_artifact_spec.rb
186
- - spec/kpm/remote/killbill_plugin_artifact_spec.rb
187
- - spec/kpm/remote/killbill_server_artifact_spec.rb
188
- - spec/kpm/remote/migrations_spec.rb
189
- - spec/kpm/remote/tomcat_manager_spec.rb
190
- - spec/kpm/unit/base_artifact_spec.rb
191
- - spec/kpm/unit/inspector_spec.rb
192
- - spec/kpm/unit/plugins_directory_spec.rb
193
- - spec/kpm/unit/plugins_manager_spec.rb
194
- - spec/kpm/unit/sha1_checker_spec.rb
195
- - spec/kpm/unit/sha1_test.yml
196
- - spec/kpm/unit/uninstaller_spec.rb
197
- - spec/spec_helper.rb
182
+ test_files: []