From aba03a1a907ab0d6373dde1f7d85674c8ef22dc1 Mon Sep 17 00:00:00 2001 From: Ian Ballou Date: Wed, 26 Jun 2024 19:44:01 +0000 Subject: [PATCH] Refs #37552 - rename Environment::PublishRepositories to match container usage --- .../registry/registry_proxies_controller.rb | 2 -- .../katello/api/v2/environments_controller.rb | 3 +-- ...es.rb => publish_container_repositories.rb} | 18 ++++++++---------- .../api/v2/environments_controller_test.rb | 12 ++++-------- test/models/smart_proxy_sync_history_test.rb | 4 ++-- 5 files changed, 15 insertions(+), 24 deletions(-) rename app/lib/actions/katello/environment/{publish_repositories.rb => publish_container_repositories.rb} (50%) diff --git a/app/controllers/katello/api/registry/registry_proxies_controller.rb b/app/controllers/katello/api/registry/registry_proxies_controller.rb index 862483b5c66..b59bcb0e970 100644 --- a/app/controllers/katello/api/registry/registry_proxies_controller.rb +++ b/app/controllers/katello/api/registry/registry_proxies_controller.rb @@ -7,8 +7,6 @@ class Api::Registry::RegistryProxiesController < Api::V2::ApiController before_action :optional_authorize, only: [:token, :catalog] before_action :registry_authorize, except: [:token, :v1_search, :catalog] before_action :authorize_repository_read, only: [:pull_manifest, :tags_list, :check_blob, :pull_blob] - # TODO: authorize_repository_write commented out due to container push changes. Additional task needed to fix. - # before_action :authorize_repository_write, only: [:start_upload_blob, :upload_blob, :finish_upload_blob, :push_manifest] before_action :container_push_prop_validation, only: [:start_upload_blob, :upload_blob, :finish_upload_blob, :push_manifest] before_action :create_container_repo_if_needed, only: [:start_upload_blob, :upload_blob, :finish_upload_blob, :push_manifest] skip_before_action :check_media_type, only: [:start_upload_blob, :upload_blob, :finish_upload_blob, diff --git a/app/controllers/katello/api/v2/environments_controller.rb b/app/controllers/katello/api/v2/environments_controller.rb index eaa403ec12e..72dc110de0e 100644 --- a/app/controllers/katello/api/v2/environments_controller.rb +++ b/app/controllers/katello/api/v2/environments_controller.rb @@ -108,8 +108,7 @@ def update update_params[:name] = params[:environment][:new_name] if params[:environment][:new_name] @environment.update!(update_params) if update_params[:registry_name_pattern] || update_params[:registry_unauthenticated_pull] - task = send(async ? :async_task : :sync_task, ::Actions::Katello::Environment::PublishRepositories, - @environment, content_type: Katello::Repository::DOCKER_TYPE) + task = send(async ? :async_task : :sync_task, ::Actions::Katello::Environment::PublishContainerRepositories, @environment) end if params.include?(:async) && async && task diff --git a/app/lib/actions/katello/environment/publish_repositories.rb b/app/lib/actions/katello/environment/publish_container_repositories.rb similarity index 50% rename from app/lib/actions/katello/environment/publish_repositories.rb rename to app/lib/actions/katello/environment/publish_container_repositories.rb index 7cf123ee3fc..87e3d8bfff0 100644 --- a/app/lib/actions/katello/environment/publish_repositories.rb +++ b/app/lib/actions/katello/environment/publish_container_repositories.rb @@ -1,7 +1,7 @@ module Actions module Katello module Environment - class PublishRepositories < Actions::EntryAction + class PublishContainerRepositories < Actions::EntryAction middleware.use ::Actions::Middleware::RemoteAction input_format do @@ -9,18 +9,16 @@ class PublishRepositories < Actions::EntryAction param :name end - def plan(env, options = {}) - repositories = options[:content_type] ? env.repositories.with_type(options[:content_type]) : env.repositories + def plan(env) + repositories = env.repositories action_subject(env) concurrence do repositories.each do |repository| sequence do - unless repository.root.is_container_push && repository.library_instance? - repository.set_container_repository_name - repository.clear_smart_proxy_sync_histories - plan_action(::Actions::Katello::Repository::InstanceUpdate, repository) - plan_action(::Actions::Katello::Repository::CapsuleSync, repository) - end + repository.set_container_repository_name + repository.clear_smart_proxy_sync_histories + plan_action(::Actions::Katello::Repository::InstanceUpdate, repository) + plan_action(::Actions::Katello::Repository::CapsuleSync, repository) end end @@ -33,7 +31,7 @@ def rescue_strategy end def humanized_name - _("Publish Lifecycle Environment Repositories") + _("Publish Lifecycle Environment Container Repositories") end def humanized_input diff --git a/test/controllers/api/v2/environments_controller_test.rb b/test/controllers/api/v2/environments_controller_test.rb index 52cbcfb7fd6..42cd331a174 100644 --- a/test/controllers/api/v2/environments_controller_test.rb +++ b/test/controllers/api/v2/environments_controller_test.rb @@ -160,8 +160,7 @@ def test_update def test_update_pattern_async original_label = @staging.label - assert_async_task(::Actions::Katello::Environment::PublishRepositories, @staging, - content_type: Katello::Repository::DOCKER_TYPE) + assert_async_task(::Actions::Katello::Environment::PublishContainerRepositories, @staging) put :update, params: { :organization_id => @organization.id, :id => @staging.id, :environment => { @@ -180,8 +179,7 @@ def test_update_pattern_async def test_update_pattern_sync original_label = @staging.label - assert_sync_task(::Actions::Katello::Environment::PublishRepositories, @staging, - content_type: Katello::Repository::DOCKER_TYPE) + assert_sync_task(::Actions::Katello::Environment::PublishContainerRepositories, @staging) put :update, params: { :organization_id => @organization.id, :id => @staging.id, :async => false, @@ -201,8 +199,7 @@ def test_update_pattern_sync def test_update_pull_async original_label = @staging.label - assert_async_task(::Actions::Katello::Environment::PublishRepositories, @staging, - content_type: Katello::Repository::DOCKER_TYPE) + assert_async_task(::Actions::Katello::Environment::PublishContainerRepositories, @staging) put :update, params: { :organization_id => @organization.id, :id => @staging.id, :environment => { @@ -221,8 +218,7 @@ def test_update_pull_async def test_update_pull_sync original_label = @staging.label - assert_sync_task(::Actions::Katello::Environment::PublishRepositories, @staging, - content_type: Katello::Repository::DOCKER_TYPE) + assert_sync_task(::Actions::Katello::Environment::PublishContainerRepositories, @staging) put :update, params: { :organization_id => @organization.id, :id => @staging.id, :async => false, diff --git a/test/models/smart_proxy_sync_history_test.rb b/test/models/smart_proxy_sync_history_test.rb index 3d1dd34df63..44f8e5f951a 100644 --- a/test/models/smart_proxy_sync_history_test.rb +++ b/test/models/smart_proxy_sync_history_test.rb @@ -56,8 +56,8 @@ def test_clear_history_on_publish_repositories @repo.create_smart_proxy_sync_history(proxy_with_pulp) library = katello_environments(:library) library.expects(:repositories).returns([@repo]) - ::Actions::Katello::Environment::PublishRepositories.any_instance.expects(:plan_action).twice - ::ForemanTasks.sync_task(::Actions::Katello::Environment::PublishRepositories, library) + ::Actions::Katello::Environment::PublishContainerRepositories.any_instance.expects(:plan_action).twice + ::ForemanTasks.sync_task(::Actions::Katello::Environment::PublishContainerRepositories, library) assert_equal @repo.smart_proxy_sync_histories.count, 0 end end