Skip to content

Commit

Permalink
fixup! [PR] Fixes #38048 - Add rolling content views
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernhard authored and quba42 committed Dec 6, 2024
1 parent 31b4ae3 commit 2127da6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def index_relation
param :repository_ids, Array, :desc => N_("list of repository ids")
param :description, String, :desc => N_("description of the filter")
def create
if @view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to create a filter for a Rolling content view.")
end
params[:type] = "erratum" if (params[:type] == "erratum_date" || params[:type] == "erratum_id")
filter = ContentViewFilter.create_for(params[:type], filter_params.merge(:content_view => @view))
respond :resource => filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def show
param :environment_ids, Array, :desc => N_("Identifiers for Lifecycle Environment")
param :description, String, :desc => N_("The description for the content view version promotion")
def promote
if @view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to promote a Rolling content view.")
end
is_force = ::Foreman::Cast.to_bool(params[:force])
task = async_task(::Actions::Katello::ContentView::Promote,
@content_view_version, @environments, is_force, params[:description])
Expand Down Expand Up @@ -97,6 +100,9 @@ def republish_repositories
api :DELETE, "/content_view_versions/:id", N_("Remove content view version")
param :id, :number, :desc => N_("Content view version identifier"), :required => true
def destroy
if @view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to destroy a version of a Rolling content view.")
end
task = async_task(::Actions::Katello::ContentViewVersion::Destroy, @content_view_version)
respond_for_async :resource => task
end
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/katello/api/v2/content_views_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def show
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
param :environment_id, :number, :desc => N_("environment numeric identifier"), :required => true
def remove_from_environment
if @content_view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to remove a Rolling content view from an environment.")
end
unless @content_view.environments.include?(@environment)
fail HttpErrors::BadRequest, _("Content view '%{view}' is not in lifecycle environment '%{env}'.") %
{view: @content_view.name, env: @environment.name}
Expand All @@ -158,6 +161,9 @@ def remove_from_environment
param :key_environment_id, :number, :desc => N_("environment to reassign orphaned activation keys to")
param :destroy_content_view, :boolean, :desc => N_("delete the content view with all the versions and environments")
def remove
if @content_view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to remove versions from a Rolling content view.")
end
if params[:destroy_content_view]
cv_envs = @content_view.content_view_environments
versions = @content_view.versions
Expand Down Expand Up @@ -194,6 +200,9 @@ def remove
param :key_content_view_id, :number, :desc => N_("content view to reassign orphaned activation keys to")
param :key_environment_id, :number, :desc => N_("environment to reassign orphaned activation keys to")
def bulk_delete_versions
if @content_view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to bulk remove versions from a Rolling content view.")
end
params[:bulk_content_view_version_ids] ||= {}

versions = find_bulk_items(bulk_params: params[:bulk_content_view_version_ids],
Expand Down Expand Up @@ -239,6 +248,9 @@ def destroy
param :name, String, :required => true, :desc => N_("New content view name")
def copy
@content_view = Katello::ContentView.readable.find_by(:id => params[:id])
if @content_view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to copy a Rolling content view.")
end
throw_resource_not_found(name: 'content_view', id: params[:id]) if @content_view.blank?
ensure_non_default
new_content_view = @content_view.copy(params[:content_view][:name])
Expand All @@ -248,6 +260,9 @@ def copy
private

def validate_publish_params!
if @content_view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to publish a Rolling content view.")
end
if params[:repos_units].present? && @content_view.composite?
fail HttpErrors::BadRequest, _("Directly setting package lists on composite content views is not allowed. Please " \
"update the components, then re-publish the composite.")
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/katello/api/v2/exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def find_exportable_content_view_version
@version = ContentViewVersion.exportable.find_by_id(params[:id])
throw_resource_not_found(name: 'content view version', id: params[:id]) if @version.blank?
@view = @version.content_view
if @view.rolling?
fail HttpErrors::BadRequest, _("It's not possible to export a Rolling content view.")
end
end

def find_history
Expand Down

0 comments on commit 2127da6

Please sign in to comment.