foreman_leapp 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/api/v2/api_authorizer.rb +31 -0
- data/app/controllers/preupgrade_reports_controller.rb +1 -1
- data/app/lib/actions/foreman_leapp/preupgrade_job.rb +2 -2
- data/app/lib/helpers/job_helper.rb +8 -6
- data/app/views/foreman_leapp/job_templates/leapp_upgrade.erb +1 -1
- data/lib/foreman_leapp/engine.rb +29 -37
- data/lib/foreman_leapp/version.rb +1 -1
- data/test/unit/helpers/job_helper_test.rb +1 -1
- metadata +4 -4
- data/app/controllers/api/v2/concerns/api_authorizer.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 815c2de3def891d8d23547a78937d3a85cd9998a2e4e6d46f97ac3f77a7fcd2e
|
4
|
+
data.tar.gz: c276ec42e54ed4d6dd98acc249b2de961372698a1bdf045ca462662cfb50c6bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5aadf3851821b208b593ce42a05b66a3c5a13af879cf6f79fa79b15dc49f7aee6aabdd7109ff552ea6eaf6b88691ce8b39292b14680d89843b0e1f6df7be919
|
7
|
+
data.tar.gz: 05f9a5f005ee281ad6f635bb211bc12728b9847315f19cbc0ba54202f04ff91c541355f070a4ec77f1eacc1585ffab4c70cb67c671fef7b51794090feb097160
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Api
|
4
|
+
module V2
|
5
|
+
module ApiAuthorizer
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
before_action :hosts_permission
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def hosts_permission
|
15
|
+
return if User.current.can?('view_hosts')
|
16
|
+
|
17
|
+
render_error 'access_denied', status: :forbidden,
|
18
|
+
locals: { details: N_('Missing one of the required permissions: view_hosts'),
|
19
|
+
missing_permissions: 'view_hosts' }
|
20
|
+
end
|
21
|
+
|
22
|
+
def resource_scope(_options = {})
|
23
|
+
@resource_scope ||= begin
|
24
|
+
scope = PreupgradeReport.joins(:host).merge(Host.authorized(:view_hosts, Host))
|
25
|
+
scope = scope.where(job_invocation_id: params[:id]) if action_name == 'job_invocation'
|
26
|
+
scope
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class PreupgradeReportsController < ::Api::V2::BaseController
|
4
|
-
include ApiAuthorizer
|
4
|
+
include Api::V2::ApiAuthorizer
|
5
5
|
|
6
6
|
def index
|
7
7
|
@preupgrade_reports = resource_scope.includes(:preupgrade_report_entries).search_for(*search_options)
|
@@ -8,8 +8,8 @@ module Actions
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def plan(job_invocation, host, *_args)
|
11
|
-
return unless ::JobHelper.correct_feature?(job_invocation, 'leapp_preupgrade') ||
|
12
|
-
::JobHelper.correct_feature?(job_invocation, 'leapp_remediation_plan')
|
11
|
+
return unless ::Helpers::JobHelper.correct_feature?(job_invocation, 'leapp_preupgrade') ||
|
12
|
+
::Helpers::JobHelper.correct_feature?(job_invocation, 'leapp_remediation_plan')
|
13
13
|
|
14
14
|
plan_self(host_id: host.id, job_invocation_id: job_invocation.id)
|
15
15
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module Helpers
|
4
|
+
module JobHelper
|
5
|
+
class << self
|
6
|
+
def correct_feature?(job_invocation, feature)
|
7
|
+
RemoteExecutionFeature.where(job_template_id: job_invocation.pattern_template_invocations
|
8
|
+
.first
|
9
|
+
.template_id, label: feature).any?
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -23,7 +23,7 @@ template_inputs:
|
|
23
23
|
---
|
24
24
|
- hosts: all
|
25
25
|
vars:
|
26
|
-
- channel_opts:
|
26
|
+
- channel_opts: <%= input('Channel') == 'ga' ? '' : "--channel #{input('Channel')}" %>
|
27
27
|
tasks:
|
28
28
|
- name: Run Leapp Upgrade
|
29
29
|
command: leapp upgrade {{ channel_opts }}
|
data/lib/foreman_leapp/engine.rb
CHANGED
@@ -7,17 +7,6 @@ module ForemanLeapp
|
|
7
7
|
class Engine < ::Rails::Engine
|
8
8
|
engine_name 'foreman_leapp'
|
9
9
|
|
10
|
-
config.eager_load_paths += Dir["#{config.root}/app/controllers/api/v2/concerns"]
|
11
|
-
config.eager_load_paths += Dir["#{config.root}/app/lib/helpers"]
|
12
|
-
|
13
|
-
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
14
|
-
config.autoload_paths += Dir["#{config.root}/app/controllers/api/v2/concerns"]
|
15
|
-
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
16
|
-
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
17
|
-
config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
18
|
-
config.autoload_paths += Dir["#{config.root}/app/lib/helpers"]
|
19
|
-
config.autoload_paths += Dir["#{config.root}/test/"]
|
20
|
-
|
21
10
|
# Add any db migrations
|
22
11
|
initializer 'foreman_leapp.load_app_instance_data' do |app|
|
23
12
|
ForemanLeapp::Engine.paths['db/migrate'].existent.each do |path|
|
@@ -25,32 +14,35 @@ module ForemanLeapp
|
|
25
14
|
end
|
26
15
|
end
|
27
16
|
|
28
|
-
initializer 'foreman_leapp.register_plugin', before: :finisher_hook do |
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
cx
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
17
|
+
initializer 'foreman_leapp.register_plugin', before: :finisher_hook do |app|
|
18
|
+
app.reloader.to_prepare do
|
19
|
+
Foreman::Plugin.register :foreman_leapp do
|
20
|
+
requires_foreman '>= 3.13'
|
21
|
+
register_gettext
|
22
|
+
|
23
|
+
apipie_documented_controllers ["#{ForemanLeapp::Engine.root}/app/controllers/api/v2/*.rb"]
|
24
|
+
extend_template_helpers ForemanLeapp::TemplateHelper
|
25
|
+
|
26
|
+
extend_page 'job_invocations/show' do |cx|
|
27
|
+
cx.add_pagelet :main_tabs,
|
28
|
+
partial: 'job_invocations/leapp_preupgrade_report',
|
29
|
+
name: _('Leapp preupgrade report'),
|
30
|
+
id: 'leapp_preupgrade_report',
|
31
|
+
onlyif: proc { |subject|
|
32
|
+
::Helpers::JobHelper.correct_feature?(subject, 'leapp_preupgrade') ||
|
33
|
+
::Helpers::JobHelper.correct_feature?(subject, 'leapp_remediation_plan')
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
security_block :foreman_leapp do
|
38
|
+
permission :view_job_invocations, { :preupgrade_reports => %i[index show job_invocation],
|
39
|
+
'api/v2/preupgrade_reports' => %i[index show job_invocation] },
|
40
|
+
:resource_type => 'JobInvocation'
|
41
|
+
end
|
42
|
+
|
43
|
+
describe_host do
|
44
|
+
multiple_actions_provider :leapp_hosts_multiple_actions
|
45
|
+
end
|
54
46
|
end
|
55
47
|
end
|
56
48
|
end
|
@@ -4,7 +4,7 @@ require 'test_plugin_helper'
|
|
4
4
|
|
5
5
|
module Helpers
|
6
6
|
class JobHelperTest < ActionView::TestCase
|
7
|
-
let(:helper) { ::JobHelper }
|
7
|
+
let(:helper) { ::Helpers::JobHelper }
|
8
8
|
|
9
9
|
let(:job_template) do
|
10
10
|
FactoryBot.create(:job_template, template: 'echo "1"', job_category: 'leapp',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_leapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Leapp team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman_remote_execution
|
@@ -68,8 +68,8 @@ files:
|
|
68
68
|
- app/assets/javascripts/foreman_leapp/locale/ja/foreman_leapp.js
|
69
69
|
- app/assets/javascripts/foreman_leapp/locale/ka/foreman_leapp.js
|
70
70
|
- app/assets/javascripts/foreman_leapp/locale/zh_CN/foreman_leapp.js
|
71
|
-
- app/controllers/api/v2/concerns/api_authorizer.rb
|
72
71
|
- app/controllers/api/v2/preupgrade_reports_controller.rb
|
72
|
+
- app/controllers/concerns/api/v2/api_authorizer.rb
|
73
73
|
- app/controllers/preupgrade_reports_controller.rb
|
74
74
|
- app/helpers/foreman_leapp/hosts_helper.rb
|
75
75
|
- app/helpers/foreman_leapp/template_helper.rb
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
|
-
rubygems_version: 3.
|
216
|
+
rubygems_version: 3.5.23
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: A Foreman plugin for Leapp utility.
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ApiAuthorizer
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
before_action :hosts_permission
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def hosts_permission
|
13
|
-
return if User.current.can?('view_hosts')
|
14
|
-
|
15
|
-
render_error 'access_denied', status: :forbidden,
|
16
|
-
locals: { details: N_('Missing one of the required permissions: view_hosts'),
|
17
|
-
missing_permissions: 'view_hosts' }
|
18
|
-
end
|
19
|
-
|
20
|
-
def resource_scope(_options = {})
|
21
|
-
@resource_scope ||= begin
|
22
|
-
scope = PreupgradeReport.joins(:host).merge(Host.authorized(:view_hosts, Host))
|
23
|
-
scope = scope.where(job_invocation_id: params[:id]) if action_name == 'job_invocation'
|
24
|
-
scope
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|