Skip to content

Commit

Permalink
Refs #37552 - rename Environment::PublishRepositories to match contai…
Browse files Browse the repository at this point in the history
…ner usage
  • Loading branch information
ianballou committed Jun 26, 2024
1 parent 251dcda commit aba03a1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/katello/api/v2/environments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
module Actions
module Katello
module Environment
class PublishRepositories < Actions::EntryAction
class PublishContainerRepositories < Actions::EntryAction
middleware.use ::Actions::Middleware::RemoteAction

input_format do
param :id
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

Expand All @@ -33,7 +31,7 @@ def rescue_strategy
end

def humanized_name
_("Publish Lifecycle Environment Repositories")
_("Publish Lifecycle Environment Container Repositories")
end

def humanized_input
Expand Down
12 changes: 4 additions & 8 deletions test/controllers/api/v2/environments_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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,
Expand All @@ -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 => {
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/models/smart_proxy_sync_history_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aba03a1

Please sign in to comment.