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

extend create_repository with username and password #106

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.0
4.1.1
19 changes: 12 additions & 7 deletions lib/nexus_cli/mixins/repository_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ module RepositoryActions
# @param provider [String] repo provider (maven2 by default)
#
# @return [Boolean] returns true on success
def create_repository(name, proxy, url, id, policy, provider)
def create_repository(name, proxy, url, id, policy, provider, username, password)
json = if proxy
create_proxy_repository_json(name, url, id, policy, provider)
create_proxy_repository_json(name, url, id, policy, provider, username, password)
else
create_hosted_repository_json(name, id, policy, provider)
end
Expand Down Expand Up @@ -186,14 +186,14 @@ def create_hosted_repository_json(name, id, policy, provider)
params[:browseable] = true
params[:indexable] = true
params[:repoType] = "hosted"
params[:repoPolicy] = policy.nil? ? "RELEASE" : ["RELEASE", "SNAPSHOT"].include?(policy) ? policy : "RELEASE"
params[:name] = name
params[:repoPolicy] = policy.nil? ? "RELEASE" : ["RELEASE", "SNAPSHOT"].include?(policy) ? policy : "RELEASE"
params[:name] = name.nil? ? id : name
params[:id] = id.nil? ? sanitize_for_id(name) : sanitize_for_id(id)
params[:format] = "maven2"
JSON.dump(:data => params)
end

def create_proxy_repository_json(name, url, id, policy, provider)
def create_proxy_repository_json(name, url, id, policy, provider, username, password)
params = {:provider => provider.nil? ? "maven2" : provider}
params[:providerRole] = "org.sonatype.nexus.proxy.repository.Repository"
params[:exposed] = true
Expand All @@ -205,15 +205,20 @@ def create_proxy_repository_json(name, url, id, policy, provider)
params[:writePolicy] = "READ_ONLY"
params[:downloadRemoteIndexes] = true
params[:autoBlockActive] = false
params[:name] = name
params[:name] = name.nil? ? id : name
params[:id] = id.nil? ? sanitize_for_id(name) : sanitize_for_id(id)
params[:remoteStorage] = {:remoteStorageUrl => url.nil? ? "http://change-me.com/" : url}
if (username) && (password)
params[:remoteStorage] = {:remoteStorageUrl => url.nil? ? "http://change-me.com/" : url, :authentication => {"username" => username ,"password" => password}}
else
params[:remoteStorage] = {:remoteStorageUrl => url.nil? ? "http://change-me.com/" : url}
end
JSON.dump(:data => params)
end

def create_group_repository_json(name, id, provider)
params = {:id => id.nil? ? sanitize_for_id(name) : sanitize_for_id(id)}
params[:name] = name
params[:name] = name.nil? ? id : name
params[:provider] = provider.nil? ? "maven2" : provider
params[:exposed] = true
JSON.dump(:data => params)
Expand Down