Skip to content

Commit

Permalink
Merge pull request #88 from praste/master
Browse files Browse the repository at this point in the history
Fix for issue #58, issue #83 and Issue #87
  • Loading branch information
KAllan357 committed Jul 17, 2014
2 parents b30f30a + ef8ca91 commit 6a791c1
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
site :opscode
chef_api :config
source 'https://api.berkshelf.com'

metadata
52 changes: 45 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ Attribute | Description | Type | Default
--------- |------------- |----- |--------
name | Name of the plugin to install | String | name

## nexus\_repository
## nexus\_hosted\_repository

Resource provider for creating and deleting Neuxs repositories.
Resource provider for creating and deleting hosted Neuxs repositories.

### Actions
Action | Description | Default
Expand All @@ -114,11 +114,49 @@ update | Updates a repository |
### Attributes
Attribute | Description | Type | Default
--------- |------------- |----- |--------
name | Name of the repository to create/delete | String | name
type | The type of repository - either "hosted" or "proxy". | String |
name | Name of the repository to create/delete/update | String | name
publisher | The type of repository - either "hosted" or "proxy". | String |
policy | Either "HOSTED" or "SNAPSHOT" repository policy for artifacts | String |


## nexus\_group\_repository

Resource provider for creating and deleting group Neuxs repositories.

### Actions
Action | Description | Default
------- |------------- |---------
create | Creates a new repository | Yes
delete | Deletes a repository |
add_to | Adds a repository to group repository |
remove_from | Removes a repository to group repository |


### Attributes
Attribute | Description | Type | Default
--------- |------------- |----- |--------
name | Name of the repository to create/delete/add_to /remove_from | String | name
repository | Repository to add/remove from group repo | String |


## nexus\_proxy\_repository

Resource provider for creating and deleting proxy Neuxs repositories.

### Actions
Action | Description | Default
------- |------------- |---------
create | Creates a new repository | Yes
delete | Deletes a repository |
update | Updates a repository |

### Attributes
Attribute | Description | Type | Default
--------- |------------- |----- |--------
name | Name of the repository to create/delete/update | String | name
url | The url used for a proxy repository. | String |
policy | Either "HOSTED" or "SNAPSHOT" repository policy for artifacts | String |
publisher | Whether this repository is a publisher of artifacts. | TrueClass, FalseClass |
publisher | The type of repository - either "hosted" or "proxy". | String |
subscriber | Whether this repository is a subscriber to artifacts. | TrueClass, FalseClass |
preemptive_fetch | Whether this (proxy) repository should preemptively fetch artifacts | TrueClass, FalseClass |

Expand All @@ -134,8 +172,8 @@ update | Updates a global Nexus setting to a new value. | Yes
### Attributes
Attribute | Description | Type | Default
--------- |------------- |----- |--------
path | The element of the settings that is going to be changed. | String | name
value | The new value to update the path to. | String, TrueClass, FalseClass |
path | Period '.' delimited path to element of the settings that is going to be changed. | String | name
value | The new value to update the path to. | String, TrueClass, FalseClass, Hash |

## nexus\_user

Expand Down
10 changes: 10 additions & 0 deletions libraries/chef_nexus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ def encrypted_data_bag_item(node, data_bag, data_bag_item)
Mash.from_hash(item.to_hash)
rescue Net::HTTPServerException => e
nil

# chef_data_bag_item.rb fails to handle scenario of missing data bag :-(,
# it reports this as Chef::Exceptions::ValidationFailed exception.
# Adding a different rescue block if things exception needs to be handled differently
rescue Chef::Exceptions::ValidationFailed => e
nil

# if you are using vault and if data bag it not present we need to handle that exception as well
rescue ChefVault::Exceptions::KeysNotFound
nil
end
end
end
Expand Down
7 changes: 4 additions & 3 deletions providers/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def get_nexus_settings_json

def update_nexus_settings_json
require 'json'
json = JSON.parse(get_nexus_settings_json)
edited_json = JsonPath.for(json).gsub("$..#{new_resource.path}") {|value| new_resource.value}.to_hash
Chef::Nexus.nexus(node).upload_global_settings(JSON.dump(edited_json))
hashed_settings = JSON.parse(get_nexus_settings_json)
*path_elements, setting_to_update = new_resource.path.split(".")
path_elements.inject(hashed_settings, :fetch)[setting_to_update] = new_resource.value
Chef::Nexus.nexus(node).upload_global_settings(JSON.dump(hashed_settings))
end
2 changes: 1 addition & 1 deletion resources/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
default_action :update

attribute :path, :kind_of => String, :name_attribute => true
attribute :value, :kind_of => [String, TrueClass, FalseClass], :required => true
attribute :value, :kind_of => [String, TrueClass, FalseClass, Hash], :required => true

0 comments on commit 6a791c1

Please sign in to comment.