Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxyrepo auth #103

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,41 @@ update | Updates a repository |
Attribute | Description | Type | Default
--------- |------------- |----- |--------
name | Name of the repository to create/delete/update | String | name
description | Describe the repository | String |
url | The url used for a proxy repository. | String |
policy | Either "HOSTED" or "SNAPSHOT" repository policy for artifacts | String |
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 |
repo_provider | 'rubygems-proxy', 'maven2', ...etc | String | nil will use 'maven2'

#### Proxy Repo Authentication
Below is how you should create your data bags for using authentication in proxy repo:

knife data bag create nexus _wildcard -c your/chef/config --secret-file your/encrypted_data_bag_key

{
"id": "_wildcard",
"credentials": {
"default_admin": {
"username": "admin",
"password": "admin123"
},
"updated_admin": {
"username": "admin",
"password": "new_password"
},
"reponame": {
"username": "remoteuser",
"password": "remotepassword"
}
},
"license": {
"file": "base64d license file"
}
}


## nexus\_settings

Resource provider for modifying the global Nexus settings.
Expand Down
2 changes: 1 addition & 1 deletion providers/hosted_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def load_current_resource

action :create do
unless repository_exists?(@current_resource.name)
Chef::Nexus.nexus(node).create_repository(new_resource.name, false, nil, nil, new_resource.policy, new_resource.repo_provider)
Chef::Nexus.nexus(node).create_repository(new_resource.description, false, nil, new_resource.name, new_resource.policy, new_resource.repo_provider, nil, nil)
set_publisher if new_resource.publisher
new_resource.updated_by_last_action(true)
end
Expand Down
13 changes: 12 additions & 1 deletion providers/proxy_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ def load_current_resource

action :create do
unless repository_exists?(@current_resource.name)
Chef::Nexus.nexus(node).create_repository(new_resource.name, true, new_resource.url, nil, new_resource.policy, new_resource.repo_provider)
credentials_entry = Chef::Nexus.get_credentials(node)
Chef::Log.info "Looking for #{new_resource.name} user and password"
if credentials_entry[new_resource.name]
username = credentials_entry[new_resource.name]["username"]
password = credentials_entry[new_resource.name]["password"]
Chef::Log.info "#{new_resource.name} - found authentication data"
else
username = nil
password = nil
Chef::Log.info "#{new_resource.name} - no authentication data found"
end
Chef::Nexus.nexus(node).create_repository(new_resource.description, true, new_resource.url, new_resource.name, new_resource.policy, new_resource.repo_provider, username, password)
set_publisher if new_resource.publisher
set_subscriber if new_resource.subscriber
new_resource.updated_by_last_action(true)
Expand Down
1 change: 1 addition & 0 deletions resources/hosted_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
default_action :create

attribute :name, :kind_of => String, :name_attribute => true
attribute :description, :kind_of => String, :default => nil
attribute :publisher, :kind_of => [TrueClass, FalseClass], :default => nil
attribute :policy, :kind_of => String, :default => nil
attribute :repo_provider, :kind_of => String, :default => nil
1 change: 1 addition & 0 deletions resources/proxy_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
default_action :create

attribute :name, :kind_of => String, :name_attribute => true
attribute :description, :kind_of => String, :default => nil
attribute :url, :kind_of => String, :required => true
attribute :policy, :kind_of => String, :default => nil
attribute :publisher, :kind_of => [TrueClass, FalseClass], :default => nil
Expand Down