kpm 0.1.1 → 0.1.2

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: 6819019089d4dd3219f4e68c7a55323addf194fe
4
- data.tar.gz: 47f1774f8355f87424fab114b6bad542159a9beb
3
+ metadata.gz: 22516ceff283bc4c4aff7ecb2f414f7def89aac7
4
+ data.tar.gz: edce716c37b92e06753419183c1a1011e9a2bd80
5
5
  SHA512:
6
- metadata.gz: e383b778cb444ede8ec0b1e4172f600fea63c47ee8b24e7f015727f68ff220cdb0fcdcca2dbd8f420f7c7e7b68909874155923bfb1c941bb7426a1b8d1b29db0
7
- data.tar.gz: ee4fb38ad9686232f9302c892b7c1583698faee0c2cd582929bba9e0c5c0e55c26feb888b4f9eb66e0f8c8f27de1e6dc576b2996b3b27138922feff8b64b1e38
6
+ metadata.gz: ed3db5d0b475cfe96ecabe07f0b56a3dc28c74cd46a30f7377536756cf63865120c6744614154edf02562e1ee0d8a8fb1f4159d830c84a9a98d3ef78df088c99
7
+ data.tar.gz: c185b075be6bc768a5f6ac4c72c86b29249b7f47d8e0c926983a01ce12ad6f47b13df1e8884f2ab66346529a926459d11f30dd34a37b87087b053bc5d12ccf6a
@@ -62,61 +62,67 @@ module KPM
62
62
  end
63
63
 
64
64
 
65
- def install_plugin(plugin_key, specified_group_id, specified_artifact_id, specified_packaging=nil, specified_classifier=nil, specified_version=nil, bundles_dir=nil, specified_type='java', force_download=false, verify_sha1=true)
66
65
 
66
+ def install_plugin(plugin_key, 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)
67
+
68
+ # plugin_key needs to exist
67
69
  if plugin_key.nil?
68
70
  @logger.warn("Aborting installation: User needs to specify a pluginKey")
69
71
  return nil
70
72
  end
71
73
 
72
- # Since we allow to only specify a the artifact_id to identify a given plugin we set the default on the other fields
73
- specified_group_id = specified_group_id || (specified_type.to_s == 'java' ? KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID : KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID)
74
- specified_packaging = specified_packaging || (specified_type.to_s == 'java' ? KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING : KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING)
75
- specified_classifier = specified_classifier || (specified_type.to_s == 'java' ? KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER : KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER)
76
-
77
- # Create a Proc to validate and resolve arguments
78
- resolve_and_validate_args_proc = Proc.new { |plugin_key, arg_type, specified_arg, lookup_arg|
79
-
80
- # There is an entry in plugin_directory.yml but does not match with input
81
- if lookup_arg && specified_arg && lookup_arg.to_s != specified_arg.to_s
82
- @logger.warn("Aborting installation: User specified #{arg_type}=#{specified_arg} for pluginKey = #{plugin_key}, but plugin_directory.yml resolves with #{lookup_arg}")
83
- return nil
84
- end
85
74
 
86
- # There is no entry and user did not specify anything (or we did not have any default)
87
- if lookup_arg.nil? && specified_arg.nil?
88
- @logger.warn("Aborting installation: need to specify an #{arg_type} for pluginKey = #{plugin_key}")
89
- return nil
90
- end
91
- # If validation is successful we return resolved value
92
- specified_arg || lookup_arg
93
- }
94
-
95
-
96
- # Lookup entry (will come with null everywhere if entry does not exist in plugin_directory.yml)
75
+ # Lookup artifact and perform validation against input
97
76
  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)
98
-
99
- # If there is no entry in plugins_directory.yml, the key provided must be a user key and must have a namespace
100
- if looked_up_artifact_id.nil? && plugin_key.split(':').size == 1
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)
82
+
83
+
84
+ # 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
85
+ if looked_up_artifact_id.nil? &&
86
+ specified_group_id != KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID &&
87
+ specified_group_id != KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID &&
88
+ plugin_key.split(':').size == 1
101
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)")
102
90
  return nil
103
91
  end
104
92
 
105
- # Validate and resolve the value to use (user input has precedence)
106
- group_id = resolve_and_validate_args_proc.call(plugin_key, 'group_id', specified_group_id, looked_up_group_id)
107
- artifact_id = resolve_and_validate_args_proc.call(plugin_key, 'artifact_id', specified_artifact_id, looked_up_artifact_id)
108
- packaging = resolve_and_validate_args_proc.call(plugin_key, 'packaging', specified_packaging, looked_up_packaging)
109
- classifier = specified_classifier || looked_up_classifier
110
- type = resolve_and_validate_args_proc.call(plugin_key, 'type', specified_type, looked_up_type).to_s
111
- version = specified_version || looked_up_version || LATEST_VERSION
93
+
94
+ # Specified parameters have always precedence except for the artifact_id (to map stripe to stripe-plugin)
95
+ artifact_id = looked_up_artifact_id || specified_artifact_id
96
+ if artifact_id.nil?
97
+ @logger.warn("Aborting installation: unable to lookup plugin #{specified_artifact_id}")
98
+ return nil
99
+ end
112
100
 
113
101
  bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path
114
102
  plugins_dir = bundles_dir.join('plugins')
115
103
 
116
- destination = type == 'java' ? plugins_dir.join('java').join(artifact_id).join(version) : plugins_dir.join('ruby')
117
-
104
+ type = specified_type || looked_up_type
105
+ if type.to_s == 'java'
106
+ group_id = specified_group_id || looked_up_group_id || KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID
107
+ packaging = specified_packaging || looked_up_packaging || KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING
108
+ classifier = specified_classifier || looked_up_classifier || KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER
109
+ version = specified_version || looked_up_version || LATEST_VERSION
110
+ destination = plugins_dir.join('java').join(artifact_id).join(version)
111
+ else
112
+ group_id = specified_group_id || looked_up_group_id || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID
113
+ packaging = specified_packaging || looked_up_packaging || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING
114
+ classifier = specified_classifier || looked_up_classifier || KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER
115
+ version = specified_version || looked_up_version || LATEST_VERSION
116
+ destination = plugins_dir.join('ruby')
117
+ end
118
118
  sha1_file = "#{bundles_dir}/#{SHA1_FILENAME}"
119
119
 
120
+
121
+ # Before we do the install we verify that the entry we have in the plugin_identifiers.json matches our current request
122
+ coordinates = [group_id, artifact_id, packaging, classifier, version]
123
+ return if !validate_plugin_key(plugins_dir, plugin_key, coordinates)
124
+
125
+
120
126
  @logger.debug("Installing plugin: group_id=#{group_id} artifact_id=#{artifact_id} packaging=#{packaging} classifier=#{classifier} version=#{version} destination=#{destination}")
121
127
  artifact_info = KPM::KillbillPluginArtifact.pull(@logger,
122
128
  group_id,
@@ -130,14 +136,15 @@ module KPM
130
136
  verify_sha1,
131
137
  @nexus_config,
132
138
  @nexus_ssl_verify)
139
+
133
140
  mark_as_active(plugins_dir, artifact_info, artifact_id)
134
- update_plugin_identifier(plugins_dir, plugin_key, artifact_info)
141
+
142
+ update_plugin_identifier(plugins_dir, plugin_key, type.to_s, coordinates, artifact_info)
135
143
 
136
144
  artifact_info
137
145
  end
138
146
 
139
147
 
140
-
141
148
  def install_plugin_from_fs(plugin_key, file_path, name, version, bundles_dir=nil, type='java')
142
149
  bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path
143
150
  plugins_dir = bundles_dir.join('plugins')
@@ -152,11 +159,30 @@ module KPM
152
159
  artifact_info[:version] ||= version
153
160
 
154
161
  mark_as_active(plugins_dir, artifact_info)
155
- update_plugin_identifier(plugins_dir, plugin_key, artifact_info)
162
+
163
+ update_plugin_identifier(plugins_dir, plugin_key, type.to_s, nil, artifact_info)
156
164
 
157
165
  artifact_info
158
166
  end
159
167
 
168
+ def uninstall_plugin(plugin_key, plugin_version=nil, bundles_dir=nil)
169
+
170
+ bundles_dir = Pathname.new(bundles_dir || DEFAULT_BUNDLES_DIR).expand_path
171
+ plugins_dir = bundles_dir.join('plugins')
172
+
173
+ plugins_manager = PluginsManager.new(plugins_dir, @logger)
174
+
175
+ plugin_name = plugins_manager.get_plugin_name_from_key(plugin_key)
176
+ if plugin_name.nil?
177
+ @logger.warn("Cannot uninstall plugin: Unknown plugin_key = #{plugin_key}");
178
+ return
179
+ end
180
+
181
+ modified = plugins_manager.uninstall(plugin_name, plugin_version)
182
+ plugins_manager.remove_plugin_identifier_key(plugin_key)
183
+ modified
184
+ end
185
+
160
186
  def install_default_bundles(bundles_dir, specified_version=nil, kb_version=nil, force_download=false, verify_sha1=true)
161
187
  group_id = 'org.kill-bill.billing'
162
188
  artifact_id = 'killbill-platform-osgi-bundles-defaultbundles'
@@ -199,18 +225,34 @@ module KPM
199
225
 
200
226
  private
201
227
 
202
- def update_plugin_identifier(plugins_dir, plugin_key, artifact_info)
203
- # In case the artifact on disk already existed and the installation is skipped, we don't try to update the pluginKey mapping
204
- # (of course if the install is retried with a different pluginKey that may be confusing for the user)
205
- if artifact_info[:bundle_dir].nil?
206
- @logger.info("Skipping updating plugin identifier for already installed plugin")
207
- return
228
+ def validate_installation_arg(plugin_key, arg_type, specified_arg, looked_up_arg)
229
+
230
+ # If nothing was specified, or if we don't find anything from the lookup, nothing to validate against
231
+ if specified_arg.nil? || looked_up_arg.nil?
232
+ return true
208
233
  end
209
234
 
235
+ if specified_arg.to_s != looked_up_arg.to_s
236
+ @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}")
237
+ return false
238
+ end
239
+
240
+ true
241
+ end
242
+
243
+ def validate_plugin_key(plugins_dir, plugin_key, coordinates)
244
+ plugins_manager = PluginsManager.new(plugins_dir, @logger)
245
+ return plugins_manager.validate_plugin_identifier_key(plugin_key, coordinates)
246
+ end
247
+
248
+ def update_plugin_identifier(plugins_dir, plugin_key, type, coordinates, artifact_info)
249
+ # In case the artifact on disk already existed and the installation is skipped, info[:bundle_dir] is null but the path exists in info[:dir_name]
250
+ path = artifact_info[:bundle_dir] || artifact_info[:dir_name]
251
+
210
252
  # The plugin_name needs to be computed after the fact (after the installation) because some plugin archive embed their directory structure
211
- plugin_name = Pathname.new(artifact_info[:bundle_dir]).parent.split[1].to_s
253
+ plugin_name = Pathname.new(path).parent.split[1].to_s
212
254
  plugins_manager = PluginsManager.new(plugins_dir, @logger)
213
- plugins_manager.update_plugin_identifier(plugin_key, plugin_name)
255
+ plugins_manager.add_plugin_identifier_key(plugin_key, plugin_name, type, coordinates)
214
256
  end
215
257
 
216
258
  def mark_as_active(plugins_dir, artifact_info, artifact_id=nil)
@@ -17,7 +17,7 @@ module KPM
17
17
 
18
18
  if plugin_version.nil?
19
19
  # Full path specified, with version
20
- link = Pathname.new(plugin_name_or_path).join('../ACTIVE')
20
+ link = Pathname.new(plugin_name_or_path).join('../SET_DEFAULT')
21
21
  FileUtils.rm_f(link)
22
22
  FileUtils.ln_s(plugin_name_or_path, link, :force => true)
23
23
  else
@@ -26,14 +26,14 @@ module KPM
26
26
  # Only one should match (java or ruby plugin)
27
27
  Dir.glob(plugin_dir_glob).each do |plugin_dir_path|
28
28
  plugin_dir = Pathname.new(plugin_dir_path)
29
- link = plugin_dir.join('ACTIVE')
29
+ link = plugin_dir.join('SET_DEFAULT')
30
30
  FileUtils.rm_f(link)
31
31
  FileUtils.ln_s(plugin_dir.join(plugin_version), link, :force => true)
32
32
  end
33
33
  end
34
34
 
35
35
  update_fs(plugin_name_or_path, plugin_version) do |tmp_dir|
36
- FileUtils.rm_f(tmp_dir.join('stop.txt'))
36
+ FileUtils.rm_f(tmp_dir.join('disabled.txt'))
37
37
  FileUtils.rm_f(tmp_dir.join('restart.txt'))
38
38
  end
39
39
  end
@@ -42,44 +42,72 @@ module KPM
42
42
  update_fs(plugin_name_or_path, plugin_version) do |tmp_dir|
43
43
  FileUtils.rm_f(tmp_dir.join('restart.txt'))
44
44
  # Be safe, keep the code, just never start it
45
- FileUtils.touch(tmp_dir.join('stop.txt'))
45
+ FileUtils.touch(tmp_dir.join('disabled.txt'))
46
46
  end
47
47
  end
48
48
 
49
49
  def restart(plugin_name_or_path, plugin_version=nil)
50
50
  update_fs(plugin_name_or_path, plugin_version) do |tmp_dir|
51
- # Remove stop.txt so that the plugin is started if it was stopped
52
- FileUtils.rm_f(tmp_dir.join('stop.txt'))
51
+ # Remove disabled.txt so that the plugin is started if it was stopped
52
+ FileUtils.rm_f(tmp_dir.join('disabled.txt'))
53
53
  FileUtils.touch(tmp_dir.join('restart.txt'))
54
54
  end
55
55
  end
56
56
 
57
- def update_plugin_identifier(plugin_key, plugin_name)
58
- path = Pathname.new(@plugins_dir).join('plugin_identifiers.json')
59
- backup_path = Pathname.new(path.to_s + ".back")
57
+ def validate_plugin_identifier_key(plugin_key, coordinates)
60
58
 
61
- identifiers = {}
62
- begin
63
- identifiers = File.open(path, 'r') do |f|
64
- JSON.parse(f.read)
59
+ identifiers = read_plugin_identifiers
60
+ entry = identifiers[plugin_key]
61
+ if entry
62
+ [:group_id, :artifact_id, :packaging, :classifier, :version].each_with_index do |value_type, idx|
63
+ return false if !validate_plugin_identifier_key_value(plugin_key, value_type, entry[value_type.to_s], coordinates[idx])
65
64
  end
66
- # Move file in case something happens until we complete the operation
67
- FileUtils.mv(path, backup_path)
68
- rescue Errno::ENOENT
69
65
  end
66
+ true
67
+ end
68
+
69
+ def add_plugin_identifier_key(plugin_key, plugin_name, language, coordinates)
70
70
 
71
- identifiers[plugin_key] = plugin_name
72
- File.open(path, 'w') do |f|
73
- f.write(identifiers.to_json)
71
+ identifiers = read_plugin_identifiers
72
+ # If key does not already exists we update it, if not nothing to do
73
+ if !identifiers.has_key?(plugin_key)
74
+
75
+ entry = {'plugin_name' => plugin_name}
76
+ entry['language'] = language
77
+ if coordinates
78
+ entry['group_id'] = coordinates[0]
79
+ entry['artifact_id'] = coordinates[1]
80
+ entry['packaging'] = coordinates[2]
81
+ entry['classifier'] = coordinates[3]
82
+ entry['version'] = coordinates[4]
83
+ end
84
+ identifiers[plugin_key] = entry
85
+ write_plugin_identifiers(identifiers)
74
86
  end
75
87
 
76
- # Cleanup backup entry
77
- FileUtils.rm(backup_path, :force => true)
88
+ identifiers
89
+ end
90
+
91
+ def remove_plugin_identifier_key(plugin_key)
92
+
93
+ identifiers = read_plugin_identifiers
94
+ # If key does not already exists we update it, if not nothing to do.
95
+ if identifiers.has_key?(plugin_key)
96
+ identifiers.delete(plugin_key)
97
+ write_plugin_identifiers(identifiers)
98
+ end
78
99
 
79
100
  identifiers
80
101
  end
81
102
 
82
103
 
104
+ def get_plugin_name_from_key(plugin_key)
105
+ identifiers = read_plugin_identifiers
106
+ return nil if identifiers.nil? || !identifiers.has_key?(plugin_key)
107
+ identifiers[plugin_key]['plugin_name']
108
+ end
109
+
110
+
83
111
  def guess_plugin_name(artifact_id)
84
112
  return nil if artifact_id.nil?
85
113
  captures = artifact_id.scan(/(.*)-plugin/)
@@ -103,6 +131,42 @@ module KPM
103
131
 
104
132
  private
105
133
 
134
+ def validate_plugin_identifier_key_value(plugin_key, value_type, entry_value, coordinate_value)
135
+ # The json does not contain the coordinates (case when installed from install_plugin_from_fs)
136
+ return true if entry_value.nil?
137
+
138
+ if entry_value != coordinate_value
139
+ @logger.warn("Entry in plugin_identifiers.json for key #{plugin_key} does not match for coordinate #{value_type}: got #{coordinate_value} instead of #{entry_value}")
140
+ return false
141
+ end
142
+ true
143
+ end
144
+
145
+ def read_plugin_identifiers
146
+ path = Pathname.new(@plugins_dir).join('plugin_identifiers.json')
147
+ identifiers = {}
148
+ begin
149
+ identifiers = File.open(path, 'r') do |f|
150
+ JSON.parse(f.read)
151
+ end
152
+ rescue Errno::ENOENT
153
+ end
154
+ identifiers
155
+ end
156
+
157
+ def write_plugin_identifiers(identifiers)
158
+
159
+ path = Pathname.new(@plugins_dir).join('plugin_identifiers.json')
160
+ Dir.mktmpdir do |tmp_dir|
161
+ tmp_path = Pathname.new(tmp_dir).join('plugin_identifiers.json')
162
+ File.open(tmp_path, 'w') do |f|
163
+ f.write(identifiers.to_json)
164
+ end
165
+
166
+ FileUtils.mv(tmp_path, path)
167
+ end
168
+ end
169
+
106
170
  # Note: the plugin name here is the directory name on the filesystem
107
171
  def update_fs(plugin_name_or_path, plugin_version=nil, &block)
108
172
  if plugin_name_or_path.nil?
@@ -1,3 +1,3 @@
1
1
  module KPM
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -21,28 +21,17 @@ describe KPM::Installer do
21
21
  'java' => [{
22
22
  'name' => 'analytics',
23
23
  'version' => '0.7.1'
24
- },
25
- # Re-add a second time the same plugin to validate the idempotency of installation
26
- {
27
- 'name' => 'analytics',
28
- 'version' => '0.7.1'
29
24
  }],
30
25
  'ruby' => [{
31
- 'name' => 'killbill:payment-test-plugin',
26
+ 'name' => 'payment-test-plugin',
32
27
  'artifact_id' => 'payment-test-plugin',
28
+ 'group_id' => 'org.kill-bill.billing.plugin.ruby',
33
29
  'version' => '1.8.7'
34
30
  },
35
31
  {
36
32
  'name' => 'stripe'
37
- },
38
- # Re-add a second time the same plugin to validate the idempotency of installation
39
- {
40
- 'name' => 'killbill:payment-test-plugin',
41
- 'artifact_id' => 'payment-test-plugin',
42
- 'version' => '1.8.7'
43
- }
44
- ]
45
- },
33
+ }]
34
+ }
46
35
  },
47
36
  'kaui' => {
48
37
  'webapp_path' => kaui_webapp_path
@@ -95,9 +84,27 @@ describe KPM::Installer do
95
84
  end
96
85
 
97
86
  plugin_identifiers.size.should == 3
98
- plugin_identifiers['killbill:payment-test-plugin'].should == 'killbill-payment-test'
99
- plugin_identifiers['stripe'].should == 'killbill-stripe'
100
- plugin_identifiers['analytics'].should == 'analytics-plugin'
87
+
88
+ plugin_identifiers['analytics']['plugin_name'].should == 'analytics-plugin'
89
+ plugin_identifiers['analytics']['group_id'].should == 'org.kill-bill.billing.plugin.java'
90
+ plugin_identifiers['analytics']['artifact_id'].should == 'analytics-plugin'
91
+ plugin_identifiers['analytics']['packaging'].should == 'jar'
92
+ plugin_identifiers['analytics']['version'].should == '0.7.1'
93
+ plugin_identifiers['analytics']['language'].should == 'java'
94
+
95
+ plugin_identifiers['payment-test-plugin']['plugin_name'].should == 'killbill-payment-test'
96
+ plugin_identifiers['payment-test-plugin']['group_id'].should == 'org.kill-bill.billing.plugin.ruby'
97
+ plugin_identifiers['payment-test-plugin']['artifact_id'].should == 'payment-test-plugin'
98
+ plugin_identifiers['payment-test-plugin']['packaging'].should == 'tar.gz'
99
+ plugin_identifiers['payment-test-plugin']['version'].should == '1.8.7'
100
+ plugin_identifiers['payment-test-plugin']['language'].should == 'ruby'
101
+
102
+ plugin_identifiers['stripe']['plugin_name'].should == 'killbill-stripe'
103
+ plugin_identifiers['stripe']['group_id'].should == 'org.kill-bill.billing.plugin.ruby'
104
+ plugin_identifiers['stripe']['artifact_id'].should == 'stripe-plugin'
105
+ plugin_identifiers['stripe']['packaging'].should == 'tar.gz'
106
+ plugin_identifiers['stripe']['version'].should == '2.0.0'
107
+ plugin_identifiers['stripe']['language'].should == 'ruby'
101
108
 
102
109
  end
103
110
  end
@@ -14,54 +14,119 @@ describe KPM::PluginsManager do
14
14
  FileUtils.mkdir_p(@plugin_dir.join('1.0.0'))
15
15
  FileUtils.mkdir_p(@plugin_dir.join('2.0.0'))
16
16
 
17
- File.exists?(@plugin_dir.join('ACTIVE')).should be_false
17
+ File.exists?(@plugin_dir.join('SET_DEFAULT')).should be_false
18
18
  end
19
19
 
20
20
  after(:each) do
21
21
  FileUtils.remove_entry_secure @plugins_dir
22
22
  end
23
23
 
24
+ it 'creates a plugin identifier entry with no coordinate' do
25
+ # Verifies file gets created if does not exist
26
+ identifiers = @manager.add_plugin_identifier_key('foo', 'foo_name', 'type', nil)
27
+ identifiers.size.should == 1
28
+ identifiers['foo']['plugin_name'].should == 'foo_name'
29
+ end
30
+
31
+ it 'creates a plugin identifier entry with coordinates' do
32
+ # Verifies file gets created if does not exist
33
+ identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', ['group', 'artifact', 'packaging', nil, 'version'])
34
+ identifiers.size.should == 1
35
+ identifiers['bar']['plugin_name'].should == 'bar_name'
36
+ identifiers['bar']['group_id'].should == 'group'
37
+ identifiers['bar']['artifact_id'].should == 'artifact'
38
+ identifiers['bar']['packaging'].should == 'packaging'
39
+ identifiers['bar']['classifier'].should == nil
40
+ identifiers['bar']['version'].should == 'version'
41
+ end
42
+
24
43
 
25
- it 'it creates a plugin identifiers file and add entries' do
44
+ it 'creates plugin identifier with multiple entries' do
26
45
  # Verifies file gets created if does not exist
27
- identifiers = @manager.update_plugin_identifier('foo', 'foo_name')
46
+ identifiers = @manager.add_plugin_identifier_key('foo', 'foo_name', 'type', nil)
28
47
  identifiers.size.should == 1
29
- identifiers['foo'].should == 'foo_name'
48
+ identifiers['foo']['plugin_name'].should == 'foo_name'
30
49
 
31
50
  # Verify file was created from previous entry (prev value was read)
32
- identifiers = @manager.update_plugin_identifier('bar', 'bar_name')
51
+ identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', nil)
33
52
  identifiers.size.should == 2
34
- identifiers['foo'].should == 'foo_name'
35
- identifiers['bar'].should == 'bar_name'
53
+ identifiers['foo']['plugin_name'].should == 'foo_name'
54
+ identifiers['bar']['plugin_name'].should == 'bar_name'
36
55
 
37
56
 
38
57
  # Verify file was created from previous entry (prev value was read)
39
- identifiers = @manager.update_plugin_identifier('zoe', 'zoe_name')
58
+ identifiers = @manager.add_plugin_identifier_key('zoe', 'zoe_name', 'type', nil)
40
59
  identifiers.size.should == 3
41
- identifiers['bar'].should == 'bar_name'
42
- identifiers['foo'].should == 'foo_name'
43
- identifiers['zoe'].should == 'zoe_name'
60
+ identifiers['bar']['plugin_name'].should == 'bar_name'
61
+ identifiers['foo']['plugin_name'].should == 'foo_name'
62
+ identifiers['zoe']['plugin_name'].should == 'zoe_name'
63
+ end
64
+
65
+ it 'creates plugin identifiers with duplicate entries' do
66
+ # Verifies file gets created if does not exist
67
+ identifiers = @manager.add_plugin_identifier_key('kewl', 'kewl_name', 'type', nil)
68
+ identifiers.size.should == 1
69
+ identifiers['kewl']['plugin_name'].should == 'kewl_name'
70
+
71
+ # Add with a different plugin_name
72
+ identifiers = @manager.add_plugin_identifier_key('kewl', 'kewl_name2', 'type', nil)
73
+ identifiers.size.should == 1
74
+ identifiers['kewl']['plugin_name'].should == 'kewl_name'
75
+ end
76
+
77
+
78
+ it 'creates plugin identifiers and remove entry' do
79
+ # Verifies file gets created if does not exist
80
+ identifiers = @manager.add_plugin_identifier_key('lol', 'lol_name', 'type', nil)
81
+ identifiers.size.should == 1
82
+ identifiers['lol']['plugin_name'].should == 'lol_name'
83
+
84
+ # Remove wrong entry, nothing happens
85
+ identifiers = @manager.remove_plugin_identifier_key('lol2')
86
+ identifiers.size.should == 1
87
+ identifiers['lol']['plugin_name'].should == 'lol_name'
88
+
89
+ # Remove correct entry
90
+ identifiers = @manager.remove_plugin_identifier_key('lol')
91
+ identifiers.size.should == 0
92
+
93
+ # Add same entry again
94
+ identifiers = @manager.add_plugin_identifier_key('lol', 'lol_name', 'type', nil)
95
+ identifiers.size.should == 1
96
+ identifiers['lol']['plugin_name'].should == 'lol_name'
97
+ end
98
+
99
+ it 'creates plugin identifiers and validate entry' do
100
+ # Verifies file gets created if does not exist
101
+ identifiers = @manager.add_plugin_identifier_key('yoyo', 'yoyo_name', 'type', ['group', 'artifact', 'packaging', nil, 'version'])
102
+ identifiers.size.should == 1
103
+ identifiers['yoyo']['plugin_name'].should == 'yoyo_name'
104
+
105
+ @manager.validate_plugin_identifier_key('yoyo', ['group', 'artifact', 'packaging', nil, 'version']).should == true
106
+
107
+ # Negative validation
108
+ @manager.validate_plugin_identifier_key('yoyo', ['group1', 'artifact', 'packaging', nil, 'version']).should == false
44
109
  end
45
110
 
46
111
 
47
112
  it 'sets a path as active' do
48
113
  @manager.set_active(@plugin_dir.join('1.0.0'))
49
- File.exists?(@plugin_dir.join('ACTIVE')).should be_true
50
- File.readlink(@plugin_dir.join('ACTIVE')).should == @plugin_dir.join('1.0.0').to_s
114
+ File.exists?(@plugin_dir.join('SET_DEFAULT')).should be_true
115
+ File.readlink(@plugin_dir.join('SET_DEFAULT')).should == @plugin_dir.join('1.0.0').to_s
51
116
 
52
117
  @manager.set_active(@plugin_dir.join('2.0.0'))
53
- File.exists?(@plugin_dir.join('ACTIVE')).should be_true
54
- File.readlink(@plugin_dir.join('ACTIVE')).should == @plugin_dir.join('2.0.0').to_s
118
+ File.exists?(@plugin_dir.join('SET_DEFAULT')).should be_true
119
+ File.readlink(@plugin_dir.join('SET_DEFAULT')).should == @plugin_dir.join('2.0.0').to_s
55
120
  end
56
121
 
57
122
  it 'sets a plugin version as active' do
58
123
  @manager.set_active('killbill-stripe', '2.0.0')
59
- File.exists?(@plugin_dir.join('ACTIVE')).should be_true
60
- File.readlink(@plugin_dir.join('ACTIVE')).should == @plugin_dir.join('2.0.0').to_s
124
+ File.exists?(@plugin_dir.join('SET_DEFAULT')).should be_true
125
+ File.readlink(@plugin_dir.join('SET_DEFAULT')).should == @plugin_dir.join('2.0.0').to_s
61
126
 
62
127
  @manager.set_active('killbill-stripe', '1.0.0')
63
- File.exists?(@plugin_dir.join('ACTIVE')).should be_true
64
- File.readlink(@plugin_dir.join('ACTIVE')).should == @plugin_dir.join('1.0.0').to_s
128
+ File.exists?(@plugin_dir.join('SET_DEFAULT')).should be_true
129
+ File.readlink(@plugin_dir.join('SET_DEFAULT')).should == @plugin_dir.join('1.0.0').to_s
65
130
  end
66
131
 
67
132
  it 'uninstalls a plugin via a path' do
@@ -116,8 +181,8 @@ describe KPM::PluginsManager do
116
181
 
117
182
  private
118
183
 
119
- def check_state(version, has_restart, has_stop)
184
+ def check_state(version, has_restart, has_disabled)
120
185
  File.exists?(@plugin_dir.join(version).join('tmp').join('restart.txt')).should == has_restart
121
- File.exists?(@plugin_dir.join(version).join('tmp').join('stop.txt')).should == has_stop
186
+ File.exists?(@plugin_dir.join(version).join('tmp').join('disabled.txt')).should == has_disabled
122
187
  end
123
188
  end
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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: 2015-12-15 00:00:00.000000000 Z
11
+ date: 2015-12-17 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
- version_requirements: !ruby/object:Gem::Requirement
43
+ requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.19.1
48
- requirement: !ruby/object:Gem::Requirement
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
49
51
  requirements:
50
- - - ~>
52
+ - - "~>"
51
53
  - !ruby/object:Gem::Version
52
54
  version: 0.19.1
53
- prerelease: false
54
- type: :runtime
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
- version_requirements: !ruby/object:Gem::Requirement
57
+ requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 10.0.0
62
- requirement: !ruby/object:Gem::Requirement
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
63
65
  requirements:
64
- - - '>='
66
+ - - ">="
65
67
  - !ruby/object:Gem::Version
66
68
  version: 10.0.0
67
- prerelease: false
68
- type: :development
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- version_requirements: !ruby/object:Gem::Requirement
71
+ requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.12.0
76
- requirement: !ruby/object:Gem::Requirement
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
77
79
  requirements:
78
- - - ~>
80
+ - - "~>"
79
81
  - !ruby/object:Gem::Version
80
82
  version: 2.12.0
81
- prerelease: false
82
- type: :development
83
83
  description: A package manager for Kill Bill.
84
84
  email: killbilling-users@googlegroups.com
85
85
  executables:
@@ -87,8 +87,8 @@ executables:
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gemrelease
91
- - .gitignore
90
+ - ".gemrelease"
91
+ - ".gitignore"
92
92
  - Gemfile
93
93
  - README.md
94
94
  - Rakefile
@@ -127,26 +127,26 @@ homepage: http://kill-bill.org
127
127
  licenses:
128
128
  - Apache License (2.0)
129
129
  metadata: {}
130
- post_install_message:
130
+ post_install_message:
131
131
  rdoc_options:
132
- - --exclude
133
- - .
132
+ - "--exclude"
133
+ - "."
134
134
  require_paths:
135
135
  - lib
136
136
  required_ruby_version: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - '>='
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: 1.8.6
141
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubyforge_project:
148
- rubygems_version: 2.4.6
149
- signing_key:
147
+ rubyforge_project:
148
+ rubygems_version: 2.2.2
149
+ signing_key:
150
150
  specification_version: 4
151
151
  summary: Kill Bill package manager.
152
152
  test_files: