lib/kpm/base_installer.rb in kpm-0.1.3 vs lib/kpm/base_installer.rb in kpm-0.1.4
- old
+ new
@@ -61,21 +61,21 @@
@nexus_ssl_verify)
end
- 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)
+ 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)
# plugin_key needs to exist
if plugin_key.nil?
@logger.warn("Aborting installation: User needs to specify a pluginKey")
return nil
end
# Lookup artifact and perform validation against input
- 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)
+ 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)
return if !validate_installation_arg(plugin_key, 'group_id', specified_group_id, looked_up_group_id)
return if !validate_installation_arg(plugin_key, 'artifact_id', specified_artifact_id, looked_up_artifact_id)
return if !validate_installation_arg(plugin_key, 'packaging', specified_packaging, looked_up_packaging)
return if !validate_installation_arg(plugin_key, 'type', specified_type, looked_up_type)
return if !validate_installation_arg(plugin_key, 'classifier', specified_classifier, looked_up_classifier)
@@ -117,12 +117,12 @@
end
sha1_file = "#{bundles_dir}/#{SHA1_FILENAME}"
# Before we do the install we verify that the entry we have in the plugin_identifiers.json matches our current request
- coordinates = [group_id, artifact_id, packaging, classifier, version]
- return if !validate_plugin_key(plugins_dir, plugin_key, coordinates)
+ coordinate_map = {:group_id => group_id, :artifact_id => artifact_id, :packaging => packaging, :classifier => classifier}
+ return if !validate_plugin_key(plugins_dir, plugin_key, coordinate_map)
@logger.debug("Installing plugin: group_id=#{group_id} artifact_id=#{artifact_id} packaging=#{packaging} classifier=#{classifier} version=#{version} destination=#{destination}")
artifact_info = KPM::KillbillPluginArtifact.pull(@logger,
group_id,
@@ -135,13 +135,16 @@
force_download,
verify_sha1,
@nexus_config,
@nexus_ssl_verify)
+ # Update with resolved version
+ coordinate_map[:version] = artifact_info[:version]
+
mark_as_active(plugins_dir, artifact_info, artifact_id)
- update_plugin_identifier(plugins_dir, plugin_key, type.to_s, coordinates, artifact_info)
+ update_plugin_identifier(plugins_dir, plugin_key, type.to_s, coordinate_map, artifact_info)
artifact_info
end
@@ -238,34 +241,26 @@
end
true
end
- def validate_plugin_key(plugins_dir, plugin_key, coordinates)
+ def validate_plugin_key(plugins_dir, plugin_key, coordinate_map)
plugins_manager = PluginsManager.new(plugins_dir, @logger)
- return plugins_manager.validate_plugin_identifier_key(plugin_key, coordinates)
+ return plugins_manager.validate_plugin_identifier_key(plugin_key, coordinate_map)
end
- def update_plugin_identifier(plugins_dir, plugin_key, type, coordinates, artifact_info)
- # 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]
- path = artifact_info[:bundle_dir] || artifact_info[:dir_name]
+ def update_plugin_identifier(plugins_dir, plugin_key, type, coordinate_map, artifact_info)
+ path = artifact_info[:bundle_dir]
# The plugin_name needs to be computed after the fact (after the installation) because some plugin archive embed their directory structure
plugin_name = Pathname.new(path).parent.split[1].to_s
plugins_manager = PluginsManager.new(plugins_dir, @logger)
- plugins_manager.add_plugin_identifier_key(plugin_key, plugin_name, type, coordinates)
+ plugins_manager.add_plugin_identifier_key(plugin_key, plugin_name, type, coordinate_map)
end
def mark_as_active(plugins_dir, artifact_info, artifact_id=nil)
# Mark this bundle as active
plugins_manager = PluginsManager.new(plugins_dir, @logger)
- if artifact_info[:bundle_dir].nil?
- # In case the artifact on disk already existed and the installation is skipped,
- # we don't know the plugin name on disk (arbitrary if it's a .tar.gz). That being said,
- # we can guess it for Kill Bill plugins (using our naming conventions)
- plugins_manager.set_active(plugins_manager.guess_plugin_name(artifact_id), artifact_info[:version])
- else
- plugins_manager.set_active(artifact_info[:bundle_dir])
- end
+ plugins_manager.set_active(artifact_info[:bundle_dir])
end
end
end