Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #7 from poliva83/master
Browse files Browse the repository at this point in the history
Remove dependency on compat-resource as a gem.
  • Loading branch information
poliva83 authored Sep 13, 2016
2 parents 6450dd3 + 05b6887 commit 52430c4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion chef-nexus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 4 additions & 3 deletions lib/chef/nexus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/chef/nexus/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 12 additions & 12 deletions spec/chef/nexus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -124,15 +124,15 @@
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
end
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
Expand All @@ -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'"
)

############
Expand Down
4 changes: 2 additions & 2 deletions spec/config_sample.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 52430c4

Please sign in to comment.