Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #29991 - Fix zeitwerk-related issues #724

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ruby_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ jobs:
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: foreman_ansible
foreman_version: refs/pull/10131/head
2 changes: 1 addition & 1 deletion app/controllers/ansible_roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def default_order
end

def create_importer
@importer = ForemanAnsible::UiRolesImporter.new(@proxy)
@importer = ForemanAnsible::UIRolesImporter.new(@proxy)
@variables_importer = ForemanAnsible::VariablesImporter.new(@proxy)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ansible_variables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def import_new_roles

def create_importer
@importer = ForemanAnsible::VariablesImporter.new(@proxy)
@importer_roles = ForemanAnsible::UiRolesImporter.new(@proxy)
@importer_roles = ForemanAnsible::UIRolesImporter.new(@proxy)
end

def find_required_proxy
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/ansible_playbooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def action_permission
end

def plan_ansible_sync(proxy_id, playbooks_names)
ForemanTasks.async_task(ImportPlaybooksJob::Async::SyncPlaybooks, proxy_id, playbooks_names)
ForemanTasks.async_task(Actions::SyncPlaybooks, proxy_id, playbooks_names)
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/ansible_roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def find_proxy
# rubocop:enable Layout/DotPosition

def create_importer
@roles_importer = ForemanAnsible::UiRolesImporter.new(@proxy)
@roles_importer = ForemanAnsible::UIRolesImporter.new(@proxy)
@variables_importer = ForemanAnsible::VariablesImporter.new(@proxy)
@importer = ForemanAnsible::ApiRolesImporter.new(@proxy)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ui_ansible_roles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UiAnsibleRolesController < ::Api::V2::BaseController
class UIAnsibleRolesController < ::Api::V2::BaseController
def resource_name(resource = 'AnsibleRole')
super resource
end
Expand Down
25 changes: 0 additions & 25 deletions app/jobs/sync_playbooks.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/jobs/sync_roles_and_variables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class SyncRolesAndVariables < ::ApplicationJob
queue_as :default

def perform(changed, proxy)
roles_importer = ForemanAnsible::UiRolesImporter.new(proxy)
roles_importer = ForemanAnsible::UIRolesImporter.new(proxy)
variables_importer = ForemanAnsible::VariablesImporter.new(proxy)
roles_importer.finish_import(changed)
variables_importer.import_variables_roles(changed) if changed['new'] || changed['old']
Expand Down
23 changes: 23 additions & 0 deletions app/lib/actions/sync_playbooks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Actions
class SyncPlaybooks < ::Actions::EntryAction
def plan(proxy_id, playbooks_names)
plan_self(proxy_id: proxy_id, playbooks_names: playbooks_names)
end

def run
playbooks_importer = ForemanAnsible::PlaybooksImporter.new(proxy)
output[:result] = playbooks_importer.import_playbooks(playbooks_names)
ForemanAnsible::ImportPlaybooksSuccessNotification.deliver!(task)
rescue StandardError => e
ForemanAnsible::ImportPlaybooksErrorNotification.new(e, task).deliver!
end

def proxy
SmartProxy.find(input[:proxy_id])
end

def playbooks_names
input[:playbooks_names]
end
end
end
2 changes: 1 addition & 1 deletion app/services/foreman_ansible/api_roles_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ApiRolesImporter < RolesImporter
include ::ForemanAnsible::AnsibleRolesDataPreparations

def import!(role_names)
@roles_importer = ForemanAnsible::UiRolesImporter.new(@ansible_proxy)
@roles_importer = ForemanAnsible::UIRolesImporter.new(@ansible_proxy)
@variables_importer = ForemanAnsible::VariablesImporter.new(@ansible_proxy)
params = { 'changed' => {} }
roles = prepare_ansible_import_rows(@roles_importer.import!, @variables_importer, false)
Expand Down
2 changes: 1 addition & 1 deletion app/services/foreman_ansible/ui_roles_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module ForemanAnsible
# imports ansible roles through UI
class UiRolesImporter < RolesImporter
class UIRolesImporter < RolesImporter
def import!
import_role_names
end
Expand Down
1 change: 1 addition & 0 deletions gemfile.d/foreman_remote_execution.local.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem 'foreman_remote_execution', github: 'ofedoren/foreman_remote_execution', branch: 'feat-37453-support-zeitwerk'
1 change: 1 addition & 0 deletions gemfile.d/foreman_tasks.local.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem 'foreman-tasks', github: 'ofedoren/foreman-tasks', branch: 'feat-37452-support-zeitwerk'
2 changes: 1 addition & 1 deletion lib/foreman_ansible/register.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Foreman::Plugin.register :foreman_ansible do
requires_foreman '>= 3.10.0'
requires_foreman '>= 3.12.0'
register_gettext

settings do
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ansible_variables_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AnsibleVariablesControllerTest < ActionController::TestCase
test 'there are no problems when the import hash is empty' do
ForemanAnsible::VariablesImporter.any_instance.
expects(:import_variable_names).returns({})
ForemanAnsible::UiRolesImporter.any_instance.
ForemanAnsible::UIRolesImporter.any_instance.
expects(:import_role_names).returns({})

get :import,
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ui_ansible_roles_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'test_plugin_helper'

class UiAnsibleRolesControllerTest < ActionController::TestCase
class UIAnsibleRolesControllerTest < ActionController::TestCase
setup do
@role = FactoryBot.create(:ansible_role)
end
Expand Down
6 changes: 3 additions & 3 deletions test/unit/services/ui_roles_importer_test.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require 'test_plugin_helper'
# unit tests for UiRolesImporter
class UiRolesImporterTest < ActiveSupport::TestCase
# unit tests for UIRolesImporter
class UIRolesImporterTest < ActiveSupport::TestCase
setup do
changed_roles
@importer = ForemanAnsible::UiRolesImporter.new
@importer = ForemanAnsible::UIRolesImporter.new
end

test 'should create new role' do
Expand Down
Loading