From 05b68870e39c8aeaebf9e5116e586d9222ee4928 Mon Sep 17 00:00:00 2001 From: poliva83 Date: Tue, 13 Sep 2016 18:51:26 +0000 Subject: [PATCH] Remove dependency on compat-resource as a gem. --- CHANGELOG.md | 3 +++ chef-nexus.gemspec | 1 - lib/chef/nexus.rb | 7 ++++--- lib/chef/nexus/version.rb | 2 +- spec/chef/nexus_spec.rb | 24 ++++++++++++------------ spec/config_sample.rb | 4 ++-- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8edb40..74267fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.2.0 (09/13/2016) +- Remove dependency on compat-resource as a gem (resolves https://github.com/blackberry/chef-nexus/issues/6) + ## 0.1.2 (04/28/2016) - Added copyright notices - Created .rubocop.yml and ran RuboCop diff --git a/chef-nexus.gemspec b/chef-nexus.gemspec index 0abeb6d..1c859aa 100644 --- a/chef-nexus.gemspec +++ b/chef-nexus.gemspec @@ -37,7 +37,6 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_dependency 'chef' - spec.add_dependency 'compat_resource', '~> 12.8.0' spec.add_dependency 'activesupport' spec.add_development_dependency 'bundler', '~> 1.11' diff --git a/lib/chef/nexus.rb b/lib/chef/nexus.rb index a9763b5..80aac9a 100644 --- a/lib/chef/nexus.rb +++ b/lib/chef/nexus.rb @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -gem 'compat_resource', '~> 12.8.0' -require 'chef_compat/resource' +require 'chef/resource' require 'active_support/all' require 'json' require 'erb' @@ -24,7 +23,7 @@ class Resource # # Chef resource for managing artifacts on Nexus by Sonatype # - class Nexus < ChefCompat::Resource + class Nexus < Chef::Resource resource_name :nexus property :nexus_profile, String, desired_state: false @@ -217,7 +216,9 @@ def cords hsh[:classifier] = splt[3] if splt.length == 5 end %w(groupId artifactId version packaging classifier).each do |x| + # rubocop:disable Lint/Eval p = eval(x) + # rubocop:enable Lint/Eval hsh[x.to_sym] = p if p end diff --git a/lib/chef/nexus/version.rb b/lib/chef/nexus/version.rb index ebcbc8c..77f28e9 100644 --- a/lib/chef/nexus/version.rb +++ b/lib/chef/nexus/version.rb @@ -18,6 +18,6 @@ module Chef # See: http://semver.org/spec/v2.0.0.html # module Nexus - VERSION = '0.1.2' + VERSION = '0.2.0' end end diff --git a/spec/chef/nexus_spec.rb b/spec/chef/nexus_spec.rb index 62c6368..e4e53c8 100644 --- a/spec/chef/nexus_spec.rb +++ b/spec/chef/nexus_spec.rb @@ -22,17 +22,17 @@ idempotency_helper( 'Upload file with extension using coordinates groupId:artifactId:version', 'upload/extn_groupId:artifactId:version.rb', - "uploaded file '/tmp/chef_nexus_rspec_temp/has_extension.test' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/artifact/1.0.0/artifact-1.0.0.test'" + "uploaded file '/tmp/chef_nexus_rspec_temp/has_extension.test' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/artifact/1.0.0/artifact-1.0.0.test'" ) idempotency_helper( 'Upload file with extension using coordinates groupId:artifactId:packaging:version', 'upload/extn_groupId:artifactId:packaging:version.rb', - "uploaded file '/tmp/chef_nexus_rspec_temp/has_extension.test' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/sub/artifact/1.0.0/artifact-1.0.0.jar'" + "uploaded file '/tmp/chef_nexus_rspec_temp/has_extension.test' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/sub/artifact/1.0.0/artifact-1.0.0.jar'" ) idempotency_helper( 'Upload file with extension using coordinates groupId:artifactId:packaging:classifier:version', 'upload/extn_groupId:artifactId:packaging:classifier:version.rb', - "uploaded file '/tmp/chef_nexus_rspec_temp/has_extension.test' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/sub/subsub/artifact/1.0.0/artifact-1.0.0-classifier.jar'" + "uploaded file '/tmp/chef_nexus_rspec_temp/has_extension.test' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/sub/subsub/artifact/1.0.0/artifact-1.0.0-classifier.jar'" ) describe 'Try to upload a file without package, should fail.' do it do @@ -46,12 +46,12 @@ idempotency_helper( 'Upload file without an extension using package attribute', 'upload/no_extn_package_groupId:artifactId:version.rb', - "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/artifact/1.0.1/artifact-1.0.1.pkg'" + "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/artifact/1.0.1/artifact-1.0.1.pkg'" ) idempotency_helper( 'Upload file with all coordinate attributes, overriding Maven coordinates', 'upload/no_extn_coordinate_attributes.rb', - "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/artifact/1.2/artifact-1.2-classifier.pkg'" + "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/artifact/1.2/artifact-1.2-classifier.pkg'" ) describe 'Try to upload a different file to one that already exists on Nexus, should fail.' do it do @@ -66,7 +66,7 @@ it do is_expected.to converge_test_recipe( :recipe => 'upload/different_file_update.rb', - :expected => "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/sub/artifact/1.0.0/artifact-1.0.0.jar'" + :expected => "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/sub/artifact/1.0.0/artifact-1.0.0.jar'" ) end end @@ -82,12 +82,12 @@ idempotency_helper( 'Upload a file using remote_url which does not pass parsing, without pom', 'upload/remote_url_no_parse_no_pom.rb', - "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/no_parse'" + "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/no_parse'" ) idempotency_helper( 'Upload a file using remote_url which passes parsing', 'upload/remote_url_parse.rb', - "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/artifact/1.7/artifact-1.7-classifier.pkg'" + "uploaded file '/tmp/chef_nexus_rspec_temp/no_extension' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/artifact/1.7/artifact-1.7-classifier.pkg'" ) describe 'Try to upload a different file to one that already exists on Nexus using remote_url, should fail.' do it do @@ -102,7 +102,7 @@ it do is_expected.to converge_test_recipe( :recipe => 'upload/remote_url_different_file_update.rb', - :expected => "uploaded file '/tmp/chef_nexus_rspec_temp/has_extension.test' to Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/sub/artifact/1.0.0/artifact-1.0.0.jar'" + :expected => "uploaded file '/tmp/chef_nexus_rspec_temp/has_extension.test' to Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/sub/artifact/1.0.0/artifact-1.0.0.jar'" ) end end @@ -124,7 +124,7 @@ it do is_expected.to converge_test_recipe( :recipe => 'download/coordinates_doesnt_exist.rb', - :expected => "No file exists at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/artifact/1.0.0/artifact-1.0.0.gary' or you do not permissions", + :expected => "No file exists at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/artifact/1.0.0/artifact-1.0.0.gary' or you do not permissions", :fail_if => 'downloaded file' ) end @@ -132,7 +132,7 @@ idempotency_helper( 'Download file using coordinates', 'download/coordinates.rb', - "downloaded file '/tmp/chef_nexus_rspec_temp/downloaded.test' from Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/artifact/1.0.0/artifact-1.0.0.test'" + "downloaded file '/tmp/chef_nexus_rspec_temp/downloaded.test' from Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/artifact/1.0.0/artifact-1.0.0.test'" ) describe 'Try to download different file, should fail' do it do @@ -146,7 +146,7 @@ idempotency_helper( 'Download and overwrite file using remote_url', 'download/remote_url_update.rb', - "downloaded file '/tmp/chef_nexus_rspec_temp/downloaded.test' from Nexus at 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content/repositories/ebu-opennebula-images/chef-nexus-rspec-test/no_parse'" + "downloaded file '/tmp/chef_nexus_rspec_temp/downloaded.test' from Nexus at '#{NEXUS_URL}/repositories/#{NEXUS_REPO}/chef-nexus-rspec-test/no_parse'" ) ############ diff --git a/spec/config_sample.rb b/spec/config_sample.rb index cd45a0c..0829e13 100644 --- a/spec/config_sample.rb +++ b/spec/config_sample.rb @@ -17,7 +17,7 @@ ## Feel free to modify any variables to your needs. ## ####################################################### -NEXUS_URL = 'http://mynexus.net/nexus/content/' -NEXUS_REPO = 'chef-nexus-tests' +NEXUS_URL = 'http://ebj-pilot-nexus.devlab2k.testnet.rim.net/nexus/content' +NEXUS_REPO = 'chef-nexus-test' # ebu-opennebula-images NEXUS_AUTH = 'gary:secr3t' USE_AUTH = true