app/controllers/katello/api/v2/repositories_controller.rb in katello-3.2.1.1 vs app/controllers/katello/api/v2/repositories_controller.rb in katello-3.3.0.rc1
- old
+ new
@@ -31,10 +31,12 @@
param :checksum_type, String, :desc => N_("checksum of the repository, currently 'sha1' & 'sha256' are supported.")
param :docker_upstream_name, String, :desc => N_("name of the upstream docker repository")
param :download_policy, ["immediate", "on_demand", "background"], :desc => N_("download policy for yum repos (either 'immediate', 'on_demand', or 'background')")
param :mirror_on_sync, :bool, :desc => N_("true if this repository when synced has to be mirrored from the source and stale rpms removed.")
param :verify_ssl_on_sync, :bool, :desc => N_("if true, Katello will verify the upstream url's SSL certifcates are signed by a trusted CA.")
+ param :upstream_username, String, :desc => N_("Username of the upstream repository user used for authentication")
+ param :upstream_password, String, :desc => N_("Password of the upstream repository user used for authentication")
end
api :GET, "/repositories", N_("List of enabled repositories")
api :GET, "/content_views/:id/repositories", N_("List of repositories for a content view")
api :GET, "/organizations/:organization_id/repositories", N_("List of repositories in an organization")
@@ -55,11 +57,11 @@
param :available_for, String, :desc => N_("interpret specified object to return only Repositories that can be associated with specified object. Only 'content_view' is supported."),
:required => false
param_group :search, Api::V2::ApiController
def index
options = {:includes => [:gpg_key, :product, :environment]}
- respond(:collection => scoped_search(index_relation.uniq, :name, :desc, options))
+ respond(:collection => scoped_search(index_relation.uniq, :name, :asc, options))
end
def index_relation
query = Repository.readable
query = index_relation_product(query)
@@ -145,11 +147,12 @@
repo_params[:content_type], unprotected,
gpg_key, repository_params[:checksum_type], repo_params[:download_policy])
repository.docker_upstream_name = repo_params[:docker_upstream_name] if repo_params[:docker_upstream_name]
repository.mirror_on_sync = ::Foreman::Cast.to_bool(repo_params[:mirror_on_sync]) if repo_params.key?(:mirror_on_sync)
repository.verify_ssl_on_sync = ::Foreman::Cast.to_bool(repo_params[:verify_ssl_on_sync]) if repo_params.key?(:verify_ssl_on_sync)
-
+ repository.upstream_username = repo_params[:upstream_username] if repo_params.key?(:upstream_username)
+ repository.upstream_password = repo_params[:upstream_password] if repo_params.key?(:upstream_password)
sync_task(::Actions::Katello::Repository::Create, repository, false, true)
repository = Repository.find(repository.id)
respond_for_show(:resource => repository)
end
@@ -222,10 +225,12 @@
param :url, String, :desc => N_("the feed url of the original repository ")
param :docker_upstream_name, String, :desc => N_("name of the upstream docker repository")
param :download_policy, ["immediate", "on_demand", "background"], :desc => N_("download policy for yum repos (either 'immediate', 'on_demand', or 'background')")
param :mirror_on_sync, :bool, :desc => N_("true if this repository when synced has to be mirrored from the source and stale rpms removed.")
param :verify_ssl_on_sync, :bool, :desc => N_("if true, Katello will verify the upstream url's SSL certifcates are signed by a trusted CA.")
+ param :upstream_username, String, :desc => N_("Username of the upstream repository user for authentication")
+ param :upstream_password, String, :desc => N_("Password of the upstream repository user for authentication")
def update
repo_params = repository_params
sync_task(::Actions::Katello::Repository::Update, @repository, repo_params)
respond_for_show(:resource => @repository)
end
@@ -317,11 +322,11 @@
if params['upload_ids'].empty? && params['uploads'].empty?
fail HttpErrors::BadRequest, _('No upload param specified. Either uploads or upload_ids (deprecated) is required.')
end
if params.key?(:upload_ids)
- Foreman::Deprecation.api_deprecation_warning("The parameter upload_ids will be removed in Katello 3.3. Please update to use the uploads parameter.")
+ ::Foreman::Deprecation.api_deprecation_warning("The parameter upload_ids will be removed in Katello 3.3. Please update to use the uploads parameter.")
params[:upload_ids].each do |upload_id|
begin
sync_task(::Actions::Katello::Repository::ImportUpload, @repository, upload_id)
rescue => e
@@ -382,10 +387,10 @@
fail HttpErrors::NotFound, _("Couldn't find gpg key '%s'") % params[:gpg_key_id] if @gpg_key.nil?
end
end
def repository_params
- keys = [:download_policy, :mirror_on_sync, :verify_ssl_on_sync]
+ keys = [:download_policy, :mirror_on_sync, :verify_ssl_on_sync, :upstream_password, :upstream_username]
keys += [:label, :content_type] if params[:action] == "create"
if params[:action] == 'create' || @repository.custom?
keys += [:url, :gpg_key_id, :unprotected, :name, :checksum_type, :docker_upstream_name]
end
params.require(:repository).permit(*keys)