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 #4 from poliva83/master
Browse files Browse the repository at this point in the history
Version 0.1.1 - 04/04/2016
  • Loading branch information
poliva83 authored Jul 25, 2016
2 parents b674c22 + 695fa1d commit 8dfb1ab
Show file tree
Hide file tree
Showing 26 changed files with 324 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.1 (04/04/2016)
- Fixed bug regarding improper parsing of local_file with names like test.0.0.4.qcow2
- Now guarding against empty strings for coordinates

## 0.1.0 (03/23/2016)
- Implemented actions :upload, :download, :delete, :delete_url
- Created rspec tests
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chef::Nexus

chef-nexus is a Chef resource for managing artifacts on Nexus by Sonatype.
chef-nexus is a Ruby gem that provides the `nexus` Chef resource for managing artifacts on Nexus by Sonatype.

## Usage

Expand All @@ -11,7 +11,7 @@ There is an optional Nexus config file that you can create and it will be read i
2. `File.read("#{ENV['HOME']}/.nexus/config")`
3. `File.read('/etc/.nexus/config')`

**Note:** only the first one found will be loaded
**NOTE:** only the first one found will be loaded

Example config file:
```json
Expand Down Expand Up @@ -77,7 +77,7 @@ Order of precedence:
:classifier => String name of the files classifier
:version => [String, Fixnum, Float] of the version
```
**NOTES**:
**NOTE:**

* `:remote_url` will be parsed for pom information if it is syntactically correct according to Maven & Nexus standards, as in:
`<NEXUS_URL>/repositories/<NEXUS_REPO>/<groupId>/<artifactId>/<version>/<artifactId>-<version>-<classifier>.<packaging>`
Expand Down Expand Up @@ -173,6 +173,7 @@ nexus 'some description' do
end
```
**NOTE:** This action does not accept attribute `:remote_url` as it is dangerous to do so. **Ex.** you might delete *ALL* artifacts by accident

**WARNING:** This action will delete the version folder (folder that holds the file), so everything inside it will be deleted as well

#### 7. Delete a file or folder from Nexus (delete folder 1.2.0 in this case)
Expand All @@ -199,6 +200,11 @@ Pull requests are very welcome! Make sure your patches are well tested. Ideally
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

To build and install the gem, go to your `chef-nexus` folder and then run:

1. `rake build`
2. `gem install pkg/chef-nexus-x.y.z.gem`, where `x.y.z` is the version you just built

### Testing

Please test your changes! Here's how:
Expand Down
5 changes: 3 additions & 2 deletions chef-nexus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
spec.authors = ['Dongyu \'Gary\' Zheng']
spec.email = ['[email protected]']

spec.summary = 'Chef resource for managing artifacts on Nexus by Sonatype'
spec.summary = 'chef-nexus is a Ruby gem that provides the `nexus` Chef resource for managing artifacts on Nexus by Sonatype.'
spec.description = spec.summary
spec.homepage = 'https://github.com/blackberry/chef-nexus'

Expand All @@ -37,7 +37,8 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_dependency 'chef'
spec.add_dependency 'compat_resource'
spec.add_dependency 'compat_resource', '~> 12.8.0'
spec.add_dependency 'activesupport'

spec.add_development_dependency 'bundler', '~> 1.11'
spec.add_development_dependency 'rake', '~> 10.0'
Expand Down
18 changes: 13 additions & 5 deletions lib/chef/nexus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

require 'chef_compat/resource'
require 'active_support/all'
require 'json'
require 'erb'
require 'digest'
Expand Down Expand Up @@ -218,11 +219,18 @@ def cords
p = eval(x)
hsh[x.to_sym] = p if p
end
fail 'Your must specify :coordinates OR at least all of [:groupId, :artifactId, :version]' if hsh.size < 3 && !remote_url
if local_file && !hsh[:packaging]
extn = ::File.basename(local_file).split('.', 2)[1]
fail 'Files require an extension, or specify it with :packaging' if extn.nil? && !remote_url
hsh[:packaging] = extn

[:groupId, :artifactId, :version].each do |x|
fail 'Your must specify :coordinates OR at least all of [:groupId, :artifactId, :version]' unless hsh[x].present?
end unless remote_url

if local_file && !hsh[:packaging].present?
extn = ::File.extname(local_file)
if !remote_url && extn.empty?
fail 'Files require an extension, or specify it with :packaging'
else
hsh[:packaging] = extn[1..-1]
end
end
hsh
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.0'
VERSION = '0.1.1'
end
end
14 changes: 14 additions & 0 deletions spec/chef/recipes/delete/coordinates.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/delete/remote_url.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/download/coordinates.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/download/coordinates_doesnt_exist.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/download/coordinates_no_packaging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/download/remote_url.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/download/remote_url_update.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/upload/different_file.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/upload/different_file_update.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/upload/extn_groupId:artifactId:version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/upload/no_extn_coordinate_attributes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
14 changes: 14 additions & 0 deletions spec/chef/recipes/upload/no_extn_groupId:artifactId:version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2016, BlackBerry, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'chef/nexus'
require "#{File.dirname(__FILE__)}/../../../config.rb"

Expand Down
Loading

0 comments on commit 8dfb1ab

Please sign in to comment.