Skip to content

Commit

Permalink
Fixes #37895 - Handle version removal for multi-CV activation key
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanshekar committed Dec 3, 2024
1 parent 3f2a522 commit 705ba6a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/lib/actions/katello/content_view_environment/destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ def plan(cv_env, options = {})
organization_destroy = options.fetch(:organization_destroy, false)
content_view = cv_env.content_view
environment = cv_env.environment
if cv_env.activation_keys.any?(&:multi_content_view_environment?)
remove_activation_key_associations(cv_env)
remove_content_view_environment_association(content_view, environment)
plan_self(:id => cv_env.id, :docker_cleanup => false)
return true
end
content_view.check_remove_from_environment!(environment) unless organization_destroy
docker_cleanup = false
sequence do
Expand Down Expand Up @@ -34,6 +40,16 @@ def finalize
end
::Katello::DockerMetaTag.cleanup_tags if input[:docker_cleanup]
end

def remove_activation_key_associations(cv_env)
cv_env.activation_keys.each do |key|
key.content_view_environment_activation_keys.find_by(content_view_environment: cv_env)&.destroy
end
end

def remove_content_view_environment_association(content_view, environment)
content_view.content_view_environments.find_by(environment: environment)&.destroy
end
end
end
end
Expand Down

0 comments on commit 705ba6a

Please sign in to comment.