foreman_kernel_care 0.0.1 → 1.1.0
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/README.md +3 -7
- data/Rakefile +2 -2
- data/app/controllers/concerns/foreman_kernel_care/foreman_tasks.rb +22 -0
- data/app/models/concerns/foreman_kernel_care/host_managed_extensions.rb +57 -2
- data/app/views/foreman_kernel_care/job_templates/kernel_version.erb +15 -0
- data/app/views/foreman_kernel_care/job_templates/update_kernel.erb +15 -0
- data/db/seeds.d/100_assign_features_with_templates.rb +28 -0
- data/db/seeds.d/70_job_templates.rb +28 -0
- data/lib/foreman_kernel_care/engine.rb +8 -32
- data/lib/foreman_kernel_care/remote_execution.rb +22 -0
- data/lib/foreman_kernel_care/version.rb +1 -1
- data/lib/tasks/foreman_kernel_care_tasks.rake +2 -12
- data/test/factories/foreman_kernel_care_factories.rb +14 -2
- data/test/test_plugin_helper.rb +4 -1
- data/test/unit/host_managed_extensions_test.rb +67 -0
- metadata +43 -33
- data/app/helpers/concerns/foreman_kernel_care/hosts_helper_extensions.rb +0 -13
- data/app/models/concerns/foreman_kernel_care/host_extensions.rb +0 -19
- data/app/views/dashboard/_foreman_kernel_care_widget.html.erb +0 -2
- data/app/views/foreman_kernel_care/layouts/layouts/new_layout.html.erb +0 -0
- data/app/views/foreman_kernel_care/layouts/new_layout.html.erb +0 -0
- data/config/routes.rb +0 -9
- data/locale/Makefile +0 -60
- data/locale/en/foreman_kernel_care.po +0 -19
- data/locale/foreman_kernel_care.pot +0 -19
- data/locale/gemspec.rb +0 -2
- data/package.json +0 -44
- data/test/unit/foreman_kernel_care_test.rb +0 -11
- data/webpack/global_index.js +0 -17
- data/webpack/global_test_setup.js +0 -11
- data/webpack/index.js +0 -8
- data/webpack/src/Components/EmptyState/Constants.js +0 -2
- data/webpack/src/Components/EmptyState/EmptyStateReducer.js +0 -19
- data/webpack/src/Components/EmptyState/ExtendedEmptyState.js +0 -43
- data/webpack/src/Components/EmptyState/__tests__/ExtendedEmptyState.test.js +0 -37
- data/webpack/src/Extends/index.js +0 -15
- data/webpack/src/Router/WelcomePage/Welcome.js +0 -9
- data/webpack/src/Router/WelcomePage/index.js +0 -1
- data/webpack/src/Router/routes.js +0 -12
- data/webpack/src/reducers.js +0 -10
- data/webpack/test_setup.js +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1d0ef271076e4187e05dfbb9b3b46c15566c103e735e81edfbe864507664176
|
4
|
+
data.tar.gz: cbabb299ec2d3bd510f3828ac20713ceb065f8a551c0b5adec0310a26e0bfdd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68d4e8475ec10d76a71bf96adf0e20d832868b8263bcc613e685d36f0506e0eee809b2f8f02c968739dc4e6aeb9fe285dbc70a5821a3757f845e74e7e8fb129a
|
7
|
+
data.tar.gz: 1a6fc20bb8eb792f6bf4d85db1de7b2935f7b7a51b3ebbddcdc7da8994d5c21032e70cada23a526a73a555cfbeeb8df04ed377c8d1d1751492997d4522933c62
|
data/README.md
CHANGED
@@ -1,27 +1,23 @@
|
|
1
1
|
# ForemanKernelCare
|
2
2
|
|
3
|
-
|
3
|
+
This plugin removes kernel [trace](https://theforeman.org/plugins/katello/nightly/user_guide/tracer/index.html) and update the kernel package version if [KernelCare](https://www.kernelcare.com/product/) package is installed on host
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
See [How_to_Install_a_Plugin](
|
7
|
+
See [How_to_Install_a_Plugin](https://www.theforeman.org/plugins/#2.Installation)
|
8
8
|
for how to install Foreman plugins
|
9
9
|
|
10
10
|
## Usage
|
11
11
|
|
12
12
|
Nothing to do, just install plugin
|
13
13
|
|
14
|
-
## TODO
|
15
|
-
|
16
|
-
- Check not only presence of the kernelcare package on host, but also the applied kernel version from kernelcare
|
17
|
-
|
18
14
|
## Contributing
|
19
15
|
|
20
16
|
Fork and send a Pull Request. Thanks!
|
21
17
|
|
22
18
|
## Copyright
|
23
19
|
|
24
|
-
Copyright (c)
|
20
|
+
Copyright (c) 2022 maccelf
|
25
21
|
|
26
22
|
This program is free software: you can redistribute it and/or modify
|
27
23
|
it under the terms of the GNU General Public License as published by
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
APP_RAKEFILE = File.expand_path('
|
23
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
24
24
|
|
25
25
|
Bundler::GemHelper.install_tasks
|
26
26
|
|
@@ -38,7 +38,7 @@ task default: :test
|
|
38
38
|
begin
|
39
39
|
require 'rubocop/rake_task'
|
40
40
|
RuboCop::RakeTask.new
|
41
|
-
rescue =>
|
41
|
+
rescue StandardError => _e
|
42
42
|
puts 'Rubocop not loaded.'
|
43
43
|
end
|
44
44
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ForemanKernelCare
|
2
|
+
module ForemanTasks
|
3
|
+
def callback
|
4
|
+
callbacks = params.key?(:callback) ? Array(params) : params[:callbacks]
|
5
|
+
ids = callbacks.map { |payload| payload[:callback][:task_id] }
|
6
|
+
foreman_tasks = ::ForemanTasks::Task.where(:id => ids)
|
7
|
+
external_map = Hash[*foreman_tasks.pluck(:id, :external_id).flatten]
|
8
|
+
callbacks.each do |payload|
|
9
|
+
# We need to call .to_unsafe_h to unwrap the hash from ActionController::Parameters
|
10
|
+
callback = payload[:callback]
|
11
|
+
foreman_task = foreman_tasks.find { |task| task.id == callback[:task_id] }
|
12
|
+
if foreman_task.action.include?('Get patched kernel version')
|
13
|
+
version, release = payload[:data].to_unsafe_h['result'].first['output'].strip.split('-')
|
14
|
+
job_invocation = ::JobInvocation.where(:task_id => foreman_task.parent_task_id).first
|
15
|
+
job_invocation.targeting.hosts.each { |host| host.update_kernel_version(version, release) }
|
16
|
+
end
|
17
|
+
process_callback(external_map[callback[:task_id]], callback[:step_id].to_i, payload[:data].to_unsafe_h, :request_id => ::Logging.mdc['request'])
|
18
|
+
end
|
19
|
+
render :json => { :message => 'processing' }.to_json
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,19 +1,74 @@
|
|
1
1
|
module ForemanKernelCare
|
2
2
|
module HostManagedExtensions
|
3
|
+
def import_package_profile(simple_packages)
|
4
|
+
if kernelcare?
|
5
|
+
composer = ::JobInvocationComposer.for_feature(:kernel_version, self)
|
6
|
+
composer.triggering.mode = :future
|
7
|
+
composer.trigger!
|
8
|
+
end
|
9
|
+
|
10
|
+
found = import_package_profile_in_bulk(simple_packages)
|
11
|
+
sync_package_associations(found.map(&:id).uniq)
|
12
|
+
end
|
13
|
+
|
3
14
|
def import_tracer_profile(tracer_profile)
|
4
15
|
traces = []
|
5
16
|
tracer_profile.each do |trace, attributes|
|
6
17
|
next if attributes[:helper].blank?
|
7
18
|
|
8
|
-
|
19
|
+
if trace.to_s == 'kernel' && kernelcare?
|
20
|
+
composer = ::JobInvocationComposer.for_feature(:update_kernel, self)
|
21
|
+
composer.triggering.mode = :future
|
22
|
+
composer.trigger!
|
9
23
|
|
10
|
-
|
24
|
+
next
|
25
|
+
end
|
26
|
+
|
27
|
+
traces << { host_id: id, application: trace, helper: attributes[:helper], app_type: attributes[:type] }
|
11
28
|
end
|
12
29
|
host_traces.delete_all
|
13
30
|
Katello::HostTracer.import(traces, validate: false)
|
14
31
|
update_trace_status
|
15
32
|
end
|
16
33
|
|
34
|
+
def update_kernel_version(version, release)
|
35
|
+
packages = ::Katello::InstalledPackage.where('name LIKE ?', '%kernel%').where.not(name: 'kernelcare').to_a
|
36
|
+
delete_ids = []
|
37
|
+
simple_packages = packages.map do |p|
|
38
|
+
delete_ids << p.id
|
39
|
+
::Katello::Pulp::SimplePackage.new({
|
40
|
+
arch: p.arch,
|
41
|
+
epoch: p.epoch,
|
42
|
+
version: version,
|
43
|
+
release: release,
|
44
|
+
name: p.name
|
45
|
+
})
|
46
|
+
end
|
47
|
+
found = import_package_profile_in_bulk(simple_packages)
|
48
|
+
sync_kernel_associations(found.map(&:id).uniq, delete_ids)
|
49
|
+
end
|
50
|
+
|
51
|
+
def sync_kernel_associations(new_patched_kernel_ids, delete_ids)
|
52
|
+
::Katello::Util::Support.active_record_retry do
|
53
|
+
table_name = host_installed_packages.table_name
|
54
|
+
|
55
|
+
queries = []
|
56
|
+
|
57
|
+
if delete_ids.any?
|
58
|
+
queries << "DELETE FROM #{table_name} WHERE host_id=#{id} AND installed_package_id IN (#{delete_ids.join(', ')})"
|
59
|
+
end
|
60
|
+
|
61
|
+
unless new_patched_kernel_ids.empty?
|
62
|
+
inserts = new_patched_kernel_ids.map { |unit_id| "(#{unit_id.to_i}, #{id.to_i})" }
|
63
|
+
queries << "INSERT INTO #{table_name} (installed_package_id, host_id) VALUES #{inserts.join(', ')}"
|
64
|
+
end
|
65
|
+
|
66
|
+
queries.each do |query|
|
67
|
+
::ActiveRecord::Base.connection.execute(query)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
17
72
|
protected
|
18
73
|
|
19
74
|
def kernelcare?
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%#
|
2
|
+
kind: job_template
|
3
|
+
name: Kernel version
|
4
|
+
model: JobTemplate
|
5
|
+
job_category: Commands
|
6
|
+
description_format: "Get patched kernel version"
|
7
|
+
provider_type: SSH
|
8
|
+
feature: kernel_version
|
9
|
+
%>
|
10
|
+
<%
|
11
|
+
unless @host.installed_packages.select { |package| package.name == 'kernelcare' }.empty?
|
12
|
+
render_error(N_('Unsupported host.'))
|
13
|
+
end
|
14
|
+
%>
|
15
|
+
/usr/bin/kcarectl --uname
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%#
|
2
|
+
kind: job_template
|
3
|
+
name: Update kernel
|
4
|
+
model: JobTemplate
|
5
|
+
job_category: Commands
|
6
|
+
description_format: "Run yum update kernel"
|
7
|
+
provider_type: SSH
|
8
|
+
feature: update_kernel
|
9
|
+
%>
|
10
|
+
<%
|
11
|
+
unless @host.operatingsystem.family == 'Redhat'
|
12
|
+
render_error(N_('Unsupported operating system for this host.'))
|
13
|
+
end
|
14
|
+
%>
|
15
|
+
yum update -y kernel*
|
@@ -0,0 +1,28 @@
|
|
1
|
+
User.as_anonymous_admin do
|
2
|
+
RemoteExecutionFeature.without_auditing do
|
3
|
+
if Rails.env.test? || Foreman.in_rake?
|
4
|
+
# If this file tries to import a template with a REX feature in a SeedsTest,
|
5
|
+
# it will fail - the REX feature isn't registered on SeedsTest because
|
6
|
+
# DatabaseCleaner truncates the db before every test.
|
7
|
+
# During db:seed, we also want to know the feature is registered before
|
8
|
+
# seeding the template
|
9
|
+
# kudos to dLobatog
|
10
|
+
ForemanKernelCare::Engine.register_rex_feature
|
11
|
+
end
|
12
|
+
JobTemplate.without_auditing do
|
13
|
+
module_template = JobTemplate.find_by(name: 'Update kernel')
|
14
|
+
if module_template && !Rails.env.test? && Setting[:remote_execution_sync_templates]
|
15
|
+
module_template.sync_feature('update_kernel')
|
16
|
+
module_template.organizations << Organization.unscoped.all if module_template.organizations.empty?
|
17
|
+
module_template.locations << Location.unscoped.all if module_template.locations.empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
module_template = JobTemplate.find_by(name: 'Kernel version')
|
21
|
+
if module_template && !Rails.env.test? && Setting[:remote_execution_sync_templates]
|
22
|
+
module_template.sync_feature('kernel_version')
|
23
|
+
module_template.organizations << Organization.unscoped.all if module_template.organizations.empty?
|
24
|
+
module_template.locations << Location.unscoped.all if module_template.locations.empty?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
organizations = Organization.unscoped.all
|
4
|
+
locations = Location.unscoped.all
|
5
|
+
User.as_anonymous_admin do
|
6
|
+
RemoteExecutionFeature.without_auditing do
|
7
|
+
if Rails.env.test? || Foreman.in_rake?
|
8
|
+
# If this file tries to import a template with a REX feature in a SeedsTest,
|
9
|
+
# it will fail - the REX feature isn't registered on SeedsTest because
|
10
|
+
# DatabaseCleaner truncates the db before every test.
|
11
|
+
# During db:seed, we also want to know the feature is registered before
|
12
|
+
# seeding the template
|
13
|
+
ForemanKernelCare::Engine.register_rex_feature
|
14
|
+
end
|
15
|
+
JobTemplate.without_auditing do
|
16
|
+
Dir[File.join("#{ForemanKernelCare::Engine.root}/app/views/"\
|
17
|
+
'foreman_kernel_care/job_templates/**/*.erb')].each do |template|
|
18
|
+
sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
|
19
|
+
template = JobTemplate.import_raw!(File.read(template),
|
20
|
+
:default => true,
|
21
|
+
:lock => true,
|
22
|
+
:update => sync)
|
23
|
+
template.organizations = organizations if template.present?
|
24
|
+
template.locations = locations if template.present?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,45 +1,27 @@
|
|
1
|
+
require 'foreman_kernel_care/remote_execution'
|
2
|
+
|
1
3
|
module ForemanKernelCare
|
2
4
|
class Engine < ::Rails::Engine
|
3
5
|
isolate_namespace ForemanKernelCare
|
4
6
|
engine_name 'foreman_kernel_care'
|
5
7
|
|
6
|
-
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
7
|
-
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
8
8
|
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
9
|
-
config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
10
|
-
|
11
|
-
# Add any db migrations
|
12
|
-
initializer 'foreman_kernel_care.load_app_instance_data' do |app|
|
13
|
-
ForemanKernelCare::Engine.paths['db/migrate'].existent.each do |path|
|
14
|
-
app.config.paths['db/migrate'] << path
|
15
|
-
end
|
16
|
-
end
|
17
9
|
|
18
10
|
initializer 'foreman_kernel_care.register_plugin', :before => :finisher_hook do |_app|
|
19
11
|
Foreman::Plugin.register :foreman_kernel_care do
|
20
|
-
requires_foreman '>=
|
21
|
-
|
22
|
-
# Add Global files for extending foreman-core components and routes
|
23
|
-
register_global_js_file 'global'
|
12
|
+
requires_foreman '>= 1.19.0'
|
24
13
|
|
25
14
|
# Add a new role called 'Discovery' if it doesn't exist
|
26
|
-
role '
|
27
|
-
|
28
|
-
# add dashboard widget
|
29
|
-
widget 'foreman_kernel_care_widget', name: N_('KernelCare widget'), sizex: 4, sizey: 1
|
15
|
+
role 'Foreman KernelCare', [:view_job_templates]
|
30
16
|
end
|
31
17
|
end
|
32
18
|
|
33
19
|
# Include concerns in this config.to_prepare block
|
34
20
|
config.to_prepare do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
Katello::Concerns::HostManagedExtensions.send(:prepend, ForemanKernelCare::HostManagedExtensions)
|
40
|
-
rescue => e
|
41
|
-
Rails.logger.warn "ForemanKernelCare: skipping engine hook (#{e})"
|
42
|
-
end
|
21
|
+
Katello::Concerns::HostManagedExtensions.prepend ForemanKernelCare::HostManagedExtensions
|
22
|
+
ForemanTasks::Api::TasksController.prepend ForemanKernelCare::ForemanTasks
|
23
|
+
rescue StandardError => e
|
24
|
+
Rails.logger.warn "ForemanKernelCare: skipping engine hook (#{e})"
|
43
25
|
end
|
44
26
|
|
45
27
|
rake_tasks do
|
@@ -47,11 +29,5 @@ module ForemanKernelCare
|
|
47
29
|
ForemanKernelCare::Engine.load_seed
|
48
30
|
end
|
49
31
|
end
|
50
|
-
|
51
|
-
initializer 'foreman_kernel_care.register_gettext', after: :load_config_initializers do |_app|
|
52
|
-
locale_dir = File.join(File.expand_path('../../..', __FILE__), 'locale')
|
53
|
-
locale_domain = 'foreman_kernel_care'
|
54
|
-
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
55
|
-
end
|
56
32
|
end
|
57
33
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'foreman_remote_execution'
|
4
|
+
|
5
|
+
module ForemanKernelCare
|
6
|
+
# Dependencies related with the remote execution plugin
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
def self.register_rex_feature
|
9
|
+
RemoteExecutionFeature.register(
|
10
|
+
:update_kernel,
|
11
|
+
N_('Run Update kernel'),
|
12
|
+
:description => N_('Runs Update kernel')
|
13
|
+
)
|
14
|
+
|
15
|
+
RemoteExecutionFeature.register(
|
16
|
+
:kernel_version,
|
17
|
+
N_('Get patched kernel version'),
|
18
|
+
:description => N_('Get patched kernel version')
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,15 +1,5 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
|
3
|
-
# Tasks
|
4
|
-
namespace :foreman_kernel_care do
|
5
|
-
namespace :example do
|
6
|
-
desc 'Example Task'
|
7
|
-
task task: :environment do
|
8
|
-
# Task goes here
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
3
|
# Tests
|
14
4
|
namespace :test do
|
15
5
|
desc 'Test ForemanKernelCare'
|
@@ -24,7 +14,7 @@ namespace :test do
|
|
24
14
|
end
|
25
15
|
|
26
16
|
namespace :foreman_kernel_care do
|
27
|
-
task :
|
17
|
+
task rubocop: :environment do
|
28
18
|
begin
|
29
19
|
require 'rubocop/rake_task'
|
30
20
|
RuboCop::RakeTask.new(:rubocop_foreman_kernel_care) do |task|
|
@@ -32,7 +22,7 @@ namespace :foreman_kernel_care do
|
|
32
22
|
"#{ForemanKernelCare::Engine.root}/lib/**/*.rb",
|
33
23
|
"#{ForemanKernelCare::Engine.root}/test/**/*.rb"]
|
34
24
|
end
|
35
|
-
rescue
|
25
|
+
rescue StandardError
|
36
26
|
puts 'Rubocop not loaded.'
|
37
27
|
end
|
38
28
|
|
@@ -1,5 +1,17 @@
|
|
1
|
-
FactoryBot.
|
1
|
+
FactoryBot.modify do
|
2
2
|
factory :host do
|
3
|
-
|
3
|
+
trait :with_kernelcare do
|
4
|
+
after(:create) do |host|
|
5
|
+
package_json = {
|
6
|
+
:name => 'kernelcare',
|
7
|
+
:version => '2.54',
|
8
|
+
:release => '1.el7',
|
9
|
+
:arch => 'x86_64',
|
10
|
+
:epoch => '1',
|
11
|
+
:nvra => 'kernelcare-2.54-1.el7.x86_64'
|
12
|
+
}
|
13
|
+
host.import_package_profile([::Katello::Pulp::SimplePackage.new(package_json)])
|
14
|
+
end
|
15
|
+
end
|
4
16
|
end
|
5
17
|
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -2,5 +2,8 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
4
|
# Add plugin to FactoryBot's paths
|
5
|
-
|
5
|
+
rex_factories_path = "#{ForemanRemoteExecution::Engine.root}/test/factories"
|
6
|
+
plugin_factories_path = File.join(File.dirname(__FILE__), 'factories')
|
7
|
+
FactoryBot.definition_file_paths << rex_factories_path
|
8
|
+
FactoryBot.definition_file_paths << plugin_factories_path
|
6
9
|
FactoryBot.reload
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
module ForemanKernelCare
|
4
|
+
class HostManagedExtensionsTestBase < ActiveSupport::TestCase
|
5
|
+
end
|
6
|
+
|
7
|
+
class HostInstalledPackagesTest < HostManagedExtensionsTestBase
|
8
|
+
def setup
|
9
|
+
feature = RemoteExecutionFeature.register('kernel_version', 'Kernel version')
|
10
|
+
template = FactoryBot.create(:job_template, name: 'Kernel versionl')
|
11
|
+
template.sync_feature(feature.label)
|
12
|
+
|
13
|
+
@host = FactoryBot.create(:host, :with_kernelcare)
|
14
|
+
package_json = {:name => "kernel", :version => "1", :release => "1.el7", :arch => "x86_64", :epoch => "1",
|
15
|
+
:nvra => "kernel-1-1.el7.x86_64"}
|
16
|
+
@host.import_package_profile([::Katello::Pulp::SimplePackage.new(package_json)])
|
17
|
+
@nvra = 'kernel-1-1.el7.x86_64'
|
18
|
+
@host.reload
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_update_kernel_version
|
22
|
+
version = '2'
|
23
|
+
release = '2.el7'
|
24
|
+
@host.update_kernel_version(version, release)
|
25
|
+
kernel_package = @host.installed_packages.where(name: 'kernel').first
|
26
|
+
|
27
|
+
assert_not_equal kernel_package.nvra, @nvra
|
28
|
+
assert_equal kernel_package.version, version
|
29
|
+
assert_equal kernel_package.release, release
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class HostTracerTest < HostManagedExtensionsTestBase
|
34
|
+
def setup
|
35
|
+
feature = RemoteExecutionFeature.register('update_kernel', 'Update Kernel')
|
36
|
+
template = FactoryBot.create(:job_template, name: 'Update kernel')
|
37
|
+
template.sync_feature(feature.label)
|
38
|
+
|
39
|
+
@tracer_json = {
|
40
|
+
"kernel": {
|
41
|
+
"type": 'static',
|
42
|
+
"helper": 'You will have to reboot your computer'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_import_kerenl_trace_with_kernelcare
|
48
|
+
host = FactoryBot.create(:host, :with_kernelcare)
|
49
|
+
host.import_tracer_profile(@tracer_json)
|
50
|
+
host.reload
|
51
|
+
|
52
|
+
assert_empty host.host_traces.where(application: 'kernel')
|
53
|
+
assert_equal 1, JobInvocation.count
|
54
|
+
assert_equal 'Update kernel', JobInvocation.first.description
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_import_kerenl_trace_without_kernelcare
|
58
|
+
host = FactoryBot.create(:host)
|
59
|
+
host.import_tracer_profile(@tracer_json)
|
60
|
+
host.reload
|
61
|
+
|
62
|
+
assert_equal 1, host.host_traces.count
|
63
|
+
assert_equal 'kernel', host.host_traces.first.application
|
64
|
+
assert_empty JobInvocation.all
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_kernel_care
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxim Petukhov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: foreman_remote_execution
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.5.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.5.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: katello
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.8.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.8.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
45
|
- - ">="
|
@@ -25,7 +53,7 @@ dependencies:
|
|
25
53
|
- !ruby/object:Gem::Version
|
26
54
|
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
56
|
+
name: rubocop
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - ">="
|
@@ -38,7 +66,8 @@ dependencies:
|
|
38
66
|
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
41
|
-
description:
|
69
|
+
description: This plugin removes kernel trace if KernelCare package is installed on
|
70
|
+
host
|
42
71
|
email:
|
43
72
|
- maxmol27@gmail.com
|
44
73
|
executables: []
|
@@ -48,38 +77,20 @@ files:
|
|
48
77
|
- LICENSE
|
49
78
|
- README.md
|
50
79
|
- Rakefile
|
51
|
-
- app/
|
52
|
-
- app/models/concerns/foreman_kernel_care/host_extensions.rb
|
80
|
+
- app/controllers/concerns/foreman_kernel_care/foreman_tasks.rb
|
53
81
|
- app/models/concerns/foreman_kernel_care/host_managed_extensions.rb
|
54
|
-
- app/views/
|
55
|
-
- app/views/foreman_kernel_care/
|
56
|
-
-
|
57
|
-
-
|
82
|
+
- app/views/foreman_kernel_care/job_templates/kernel_version.erb
|
83
|
+
- app/views/foreman_kernel_care/job_templates/update_kernel.erb
|
84
|
+
- db/seeds.d/100_assign_features_with_templates.rb
|
85
|
+
- db/seeds.d/70_job_templates.rb
|
58
86
|
- lib/foreman_kernel_care.rb
|
59
87
|
- lib/foreman_kernel_care/engine.rb
|
88
|
+
- lib/foreman_kernel_care/remote_execution.rb
|
60
89
|
- lib/foreman_kernel_care/version.rb
|
61
90
|
- lib/tasks/foreman_kernel_care_tasks.rake
|
62
|
-
- locale/Makefile
|
63
|
-
- locale/en/foreman_kernel_care.po
|
64
|
-
- locale/foreman_kernel_care.pot
|
65
|
-
- locale/gemspec.rb
|
66
|
-
- package.json
|
67
91
|
- test/factories/foreman_kernel_care_factories.rb
|
68
92
|
- test/test_plugin_helper.rb
|
69
|
-
- test/unit/
|
70
|
-
- webpack/global_index.js
|
71
|
-
- webpack/global_test_setup.js
|
72
|
-
- webpack/index.js
|
73
|
-
- webpack/src/Components/EmptyState/Constants.js
|
74
|
-
- webpack/src/Components/EmptyState/EmptyStateReducer.js
|
75
|
-
- webpack/src/Components/EmptyState/ExtendedEmptyState.js
|
76
|
-
- webpack/src/Components/EmptyState/__tests__/ExtendedEmptyState.test.js
|
77
|
-
- webpack/src/Extends/index.js
|
78
|
-
- webpack/src/Router/WelcomePage/Welcome.js
|
79
|
-
- webpack/src/Router/WelcomePage/index.js
|
80
|
-
- webpack/src/Router/routes.js
|
81
|
-
- webpack/src/reducers.js
|
82
|
-
- webpack/test_setup.js
|
93
|
+
- test/unit/host_managed_extensions_test.rb
|
83
94
|
homepage: https://github.com/maccelf/foreman_kernel_care
|
84
95
|
licenses:
|
85
96
|
- GPL-3.0
|
@@ -104,7 +115,6 @@ signing_key:
|
|
104
115
|
specification_version: 4
|
105
116
|
summary: Plugin for KernelCare
|
106
117
|
test_files:
|
107
|
-
- test/test_plugin_helper.rb
|
108
|
-
- test/unit/foreman_kernel_care_test.rb
|
109
118
|
- test/factories/foreman_kernel_care_factories.rb
|
110
|
-
-
|
119
|
+
- test/test_plugin_helper.rb
|
120
|
+
- test/unit/host_managed_extensions_test.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module ForemanKernelCare
|
2
|
-
module HostExtensions
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
# execute callbacks
|
7
|
-
end
|
8
|
-
|
9
|
-
# create or overwrite instance methods...
|
10
|
-
def instance_method_name
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
# create or overwrite class methods...
|
15
|
-
def class_method_name
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
File without changes
|
File without changes
|
data/config/routes.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
ForemanKernelCare::Engine.routes.draw do
|
2
|
-
get 'new_action', to: 'example#new_action', as: 'new_action'
|
3
|
-
get 'plugin_template_description', to: 'example#react_template_page_description'
|
4
|
-
get 'welcome', to: '/react#index', as: 'welcome'
|
5
|
-
end
|
6
|
-
|
7
|
-
Foreman::Application.routes.draw do
|
8
|
-
mount ForemanKernelCare::Engine, at: '/foreman_kernel_care'
|
9
|
-
end
|
data/locale/Makefile
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Makefile for PO merging and MO generation. More info in the README.
|
3
|
-
#
|
4
|
-
# make all-mo (default) - generate MO files
|
5
|
-
# make check - check translations using translate-tool
|
6
|
-
# make tx-update - download and merge translations from Transifex
|
7
|
-
# make clean - clean everything
|
8
|
-
#
|
9
|
-
DOMAIN = foreman_kernel_care
|
10
|
-
VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
|
11
|
-
POTFILE = $(DOMAIN).pot
|
12
|
-
MOFILE = $(DOMAIN).mo
|
13
|
-
POFILES = $(shell find . -name '$(DOMAIN).po')
|
14
|
-
MOFILES = $(patsubst %.po,%.mo,$(POFILES))
|
15
|
-
POXFILES = $(patsubst %.po,%.pox,$(POFILES))
|
16
|
-
EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
|
17
|
-
|
18
|
-
%.mo: %.po
|
19
|
-
mkdir -p $(shell dirname $@)/LC_MESSAGES
|
20
|
-
msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
|
21
|
-
|
22
|
-
# Generate MO files from PO files
|
23
|
-
all-mo: $(MOFILES)
|
24
|
-
|
25
|
-
# Check for malformed strings
|
26
|
-
%.pox: %.po
|
27
|
-
msgfmt -c $<
|
28
|
-
pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
|
29
|
-
-t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@
|
30
|
-
cat $@
|
31
|
-
! grep -q msgid $@
|
32
|
-
|
33
|
-
%.edit.po:
|
34
|
-
touch $@
|
35
|
-
|
36
|
-
check: $(POXFILES)
|
37
|
-
|
38
|
-
# Unify duplicate translations
|
39
|
-
uniq-po:
|
40
|
-
for f in $(shell find ./ -name "*.po") ; do \
|
41
|
-
msguniq $$f -o $$f ; \
|
42
|
-
done
|
43
|
-
|
44
|
-
tx-pull: $(EDITFILES)
|
45
|
-
tx pull -f
|
46
|
-
for f in $(EDITFILES) ; do \
|
47
|
-
sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
|
48
|
-
done
|
49
|
-
|
50
|
-
tx-update: tx-pull
|
51
|
-
@echo
|
52
|
-
@echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation, then make -C locale mo-files to finish
|
53
|
-
@echo
|
54
|
-
|
55
|
-
mo-files: $(MOFILES)
|
56
|
-
git add $(POFILES) $(POTFILE) ../locale/*/LC_MESSAGES
|
57
|
-
git commit -m "i18n - pulling from tx"
|
58
|
-
@echo
|
59
|
-
@echo Changes commited!
|
60
|
-
@echo
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# foreman_kernel_care
|
2
|
-
#
|
3
|
-
# This file is distributed under the same license as foreman_kernel_care.
|
4
|
-
#
|
5
|
-
#, fuzzy
|
6
|
-
msgid ""
|
7
|
-
msgstr ""
|
8
|
-
"Project-Id-Version: version 0.0.1\n"
|
9
|
-
"Report-Msgid-Bugs-To: \n"
|
10
|
-
"POT-Creation-Date: 2014-08-20 08:46+0100\n"
|
11
|
-
"PO-Revision-Date: 2014-08-20 08:54+0100\n"
|
12
|
-
"Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
|
13
|
-
"Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
|
14
|
-
"Language: \n"
|
15
|
-
"MIME-Version: 1.0\n"
|
16
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
17
|
-
"Content-Transfer-Encoding: 8bit\n"
|
18
|
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
19
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# foreman_kernel_care
|
2
|
-
#
|
3
|
-
# This file is distributed under the same license as foreman_kernel_care.
|
4
|
-
#
|
5
|
-
#, fuzzy
|
6
|
-
msgid ""
|
7
|
-
msgstr ""
|
8
|
-
"Project-Id-Version: version 0.0.1\n"
|
9
|
-
"Report-Msgid-Bugs-To: \n"
|
10
|
-
"POT-Creation-Date: 2014-08-20 08:46+0100\n"
|
11
|
-
"PO-Revision-Date: 2014-08-20 08:46+0100\n"
|
12
|
-
"Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
|
13
|
-
"Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
|
14
|
-
"Language: \n"
|
15
|
-
"MIME-Version: 1.0\n"
|
16
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
17
|
-
"Content-Transfer-Encoding: 8bit\n"
|
18
|
-
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
19
|
-
|
data/locale/gemspec.rb
DELETED
data/package.json
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "foreman_kernel_care",
|
3
|
-
"version": "1.0.0",
|
4
|
-
"description": "DESCRIPTION",
|
5
|
-
"main": "index.js",
|
6
|
-
"scripts": {
|
7
|
-
"lint": "tfm-lint --plugin -d /webpack",
|
8
|
-
"test": "tfm-test --config jest.config.js",
|
9
|
-
"test:watch": "tfm-test --plugin --watchAll",
|
10
|
-
"test:current": "tfm-test --plugin --watch",
|
11
|
-
"publish-coverage": "tfm-publish-coverage",
|
12
|
-
"stories": "tfm-stories --plugin",
|
13
|
-
"stories:build": "tfm-build-stories --plugin",
|
14
|
-
"create-react-component": "yo react-domain"
|
15
|
-
},
|
16
|
-
"repository": {
|
17
|
-
"type": "git",
|
18
|
-
"url": "git+https://github.com/theforeman/foreman_kernel_care.git"
|
19
|
-
},
|
20
|
-
"bugs": {
|
21
|
-
"url": "http://projects.theforeman.org/projects/foreman_kernel_care/issues"
|
22
|
-
},
|
23
|
-
"peerDependencies": {
|
24
|
-
"@theforeman/vendor": ">= 6.0.0"
|
25
|
-
},
|
26
|
-
"dependencies": {
|
27
|
-
"react-intl": "^2.8.0"
|
28
|
-
},
|
29
|
-
"devDependencies": {
|
30
|
-
"@babel/core": "^7.7.0",
|
31
|
-
"@sheerun/mutationobserver-shim": "^0.3.3",
|
32
|
-
"@theforeman/builder": "^6.0.0",
|
33
|
-
"@theforeman/eslint-plugin-foreman": "6.0.0",
|
34
|
-
"@theforeman/find-foreman": "^4.8.0",
|
35
|
-
"@theforeman/stories": "^7.0.0",
|
36
|
-
"@theforeman/test": "^8.0.0",
|
37
|
-
"@theforeman/vendor-dev": "^6.0.0",
|
38
|
-
"babel-eslint": "^10.0.3",
|
39
|
-
"eslint": "^6.7.2",
|
40
|
-
"prettier": "^1.19.1",
|
41
|
-
"stylelint-config-standard": "^18.0.0",
|
42
|
-
"stylelint": "^9.3.0"
|
43
|
-
}
|
44
|
-
}
|
data/webpack/global_index.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import { registerReducer } from 'foremanReact/common/MountingService';
|
2
|
-
import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
|
3
|
-
import { registerRoutes } from 'foremanReact/routes/RoutingService';
|
4
|
-
import Routes from './src/Router/routes'
|
5
|
-
import reducers from './src/reducers';
|
6
|
-
|
7
|
-
// register reducers
|
8
|
-
Object.entries(reducers).forEach(([key, reducer]) =>
|
9
|
-
registerReducer(key, reducer)
|
10
|
-
);
|
11
|
-
|
12
|
-
// register client routes
|
13
|
-
registerRoutes('PluginTemplate', Routes);
|
14
|
-
|
15
|
-
// register fills for extending foreman core
|
16
|
-
// http://foreman.surge.sh/?path=/docs/introduction-slot-and-fill--page
|
17
|
-
addGlobalFill('<slotId>', '<fillId>', <div key='plugin-template-example' />, 300);
|
@@ -1,11 +0,0 @@
|
|
1
|
-
// runs before each test to make sure console.error output will
|
2
|
-
// fail a test (i.e. default PropType missing). Check the error
|
3
|
-
// output and traceback for actual error.
|
4
|
-
global.console.error = (error, stack) => {
|
5
|
-
/* eslint-disable-next-line no-console */
|
6
|
-
if (stack) console.log(stack); // Prints out original stack trace
|
7
|
-
throw new Error(error);
|
8
|
-
};
|
9
|
-
|
10
|
-
// Increase jest timeout as some tests using multiple http mocks can time out on CI systems.
|
11
|
-
jest.setTimeout(10000);
|
data/webpack/index.js
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import componentRegistry from 'foremanReact/components/componentRegistry';
|
2
|
-
import ExtendedEmptyState from './src/Components/EmptyState/ExtendedEmptyState';
|
3
|
-
|
4
|
-
// register components for erb mounting
|
5
|
-
componentRegistry.register({
|
6
|
-
name: 'ExtendedEmptyState',
|
7
|
-
type: ExtendedEmptyState,
|
8
|
-
});
|
@@ -1,19 +0,0 @@
|
|
1
|
-
// This is an example for a generic redux's reducer
|
2
|
-
// Reducers should be registered to foreman-core
|
3
|
-
// For a further registration demonstration, have a look in `webpack/global_index.js`
|
4
|
-
|
5
|
-
import Immutable from 'seamless-immutable';
|
6
|
-
import { GENERAL_ACTION_TYPE } from './Constants';
|
7
|
-
|
8
|
-
const initialState = Immutable({});
|
9
|
-
|
10
|
-
export default (state = initialState, action) => {
|
11
|
-
const { payload } = action;
|
12
|
-
|
13
|
-
switch (action.type) {
|
14
|
-
case GENERAL_ACTION_TYPE:
|
15
|
-
return state.set('generalProprty', payload);
|
16
|
-
default:
|
17
|
-
return state;
|
18
|
-
}
|
19
|
-
};
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Button, Alert } from '@patternfly/react-core';
|
3
|
-
import EmptyState from 'foremanReact/components/common/EmptyState/EmptyStatePattern';
|
4
|
-
import SkeletonLoader from 'foremanReact/components/common/SkeletonLoader';
|
5
|
-
import PropTypes from 'prop-types';
|
6
|
-
|
7
|
-
import { STATUS } from 'foremanReact/constants'
|
8
|
-
import { useAPI } from 'foremanReact/common/hooks/API/APIHooks'
|
9
|
-
import { translate as __ } from 'foremanReact/common/I18n';
|
10
|
-
import { FOREMAN_STORYBOOK } from './Constants';
|
11
|
-
|
12
|
-
const ExtendedEmptyState = ({ header }) => {
|
13
|
-
// AJAX request using useAPI hook
|
14
|
-
const { response: { description }, status } = useAPI('get', '/foreman_kernel_care/plugin_template_description')
|
15
|
-
|
16
|
-
|
17
|
-
const storybookBtn = (
|
18
|
-
<Button onClick={() => window.open(FOREMAN_STORYBOOK, '_blank')}>
|
19
|
-
Storybook
|
20
|
-
</Button>
|
21
|
-
);
|
22
|
-
|
23
|
-
switch (status) {
|
24
|
-
case STATUS.ERROR:
|
25
|
-
return (<Alert variant="danger" title={__("Loading description has failed")} />);
|
26
|
-
case STATUS.RESOLVED: return (
|
27
|
-
<EmptyState
|
28
|
-
icon="add-circle-o"
|
29
|
-
action={storybookBtn}
|
30
|
-
header={header}
|
31
|
-
description={description}
|
32
|
-
documentation={false}
|
33
|
-
/>
|
34
|
-
)
|
35
|
-
default:
|
36
|
-
return (<SkeletonLoader isLoading={status === STATUS.PENDING} count={5} />);
|
37
|
-
}
|
38
|
-
};
|
39
|
-
ExtendedEmptyState.PropTypes = {
|
40
|
-
header: PropTypes.string.isRequired
|
41
|
-
};
|
42
|
-
|
43
|
-
export default ExtendedEmptyState;
|
@@ -1,37 +0,0 @@
|
|
1
|
-
// Tests work with react-testing-library or enzyme
|
2
|
-
// This test uses react testing library
|
3
|
-
// https://testing-library.com/docs/react-testing-library/api
|
4
|
-
|
5
|
-
// For more information, test utils, and snapshots testing examples:
|
6
|
-
// https://github.com/theforeman/foreman-js/tree/master/packages/test
|
7
|
-
|
8
|
-
|
9
|
-
import React from 'react';
|
10
|
-
import { createStore, applyMiddleware, combineReducers } from 'redux';
|
11
|
-
import { render, waitFor, screen } from '@testing-library/react'
|
12
|
-
import { Provider } from 'react-redux';
|
13
|
-
|
14
|
-
import { reducers as APIReducer } from 'foremanReact/redux/API';
|
15
|
-
import { middlewares } from 'foremanReact/redux/middlewares';
|
16
|
-
import APIHelper from 'foremanReact/redux/API/API';
|
17
|
-
import ExtendedEmptyState from '../ExtendedEmptyState';
|
18
|
-
|
19
|
-
jest.mock('foremanReact/redux/API/API');
|
20
|
-
|
21
|
-
const reducers = combineReducers(APIReducer);
|
22
|
-
const store = createStore(reducers, applyMiddleware(...middlewares));
|
23
|
-
const wrapper = ({ children }) => (
|
24
|
-
<Provider store={store}>{children}</Provider>
|
25
|
-
);
|
26
|
-
describe('foreman plugin template', () => {
|
27
|
-
it('should render an error alert', async () => {
|
28
|
-
APIHelper.get.mockRejectedValue({ error: new Error() });
|
29
|
-
render(<ExtendedEmptyState />, { wrapper });
|
30
|
-
await waitFor(() => expect(screen.getByText('Loading description has failed')).toBeInTheDocument());
|
31
|
-
});
|
32
|
-
it('should render an empty state with custom description', async () => {
|
33
|
-
APIHelper.get.mockResolvedValue({ data: { description: 'some description' } });
|
34
|
-
render(<ExtendedEmptyState />, { wrapper });
|
35
|
-
await waitFor(() => expect(screen.getByText('some description')).toBeInTheDocument());
|
36
|
-
});
|
37
|
-
});
|
@@ -1,15 +0,0 @@
|
|
1
|
-
// This is an example of extending foreman-core's component via slot&fill
|
2
|
-
// http://foreman.surge.sh/?path=/docs/introduction-slot-and-fill--page
|
3
|
-
/*
|
4
|
-
import React from 'react';
|
5
|
-
import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
|
6
|
-
|
7
|
-
addGlobalFill('slotId', 'fillId', <SomeComponent key="some-key" />, 300);
|
8
|
-
|
9
|
-
addGlobalFill(
|
10
|
-
'slotId',
|
11
|
-
'fillId',
|
12
|
-
{ someProp: 'this is an override prop' },
|
13
|
-
300
|
14
|
-
);
|
15
|
-
*/
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import ExtendedEmptyState from '../../Components/EmptyState/ExtendedEmptyState';
|
3
|
-
import { translate as __ } from 'foremanReact/common/I18n';
|
4
|
-
|
5
|
-
const WelcomePage = () => (
|
6
|
-
<ExtendedEmptyState header={__("Welcome to the plugin template")} />
|
7
|
-
);
|
8
|
-
|
9
|
-
export default WelcomePage;
|
@@ -1 +0,0 @@
|
|
1
|
-
export { default } from './Welcome';
|
data/webpack/src/reducers.js
DELETED
data/webpack/test_setup.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import 'core-js/shim';
|
2
|
-
import 'regenerator-runtime/runtime';
|
3
|
-
import MutationObserver from '@sheerun/mutationobserver-shim';
|
4
|
-
|
5
|
-
import { configure } from 'enzyme';
|
6
|
-
import Adapter from 'enzyme-adapter-react-16';
|
7
|
-
|
8
|
-
configure({ adapter: new Adapter() });
|
9
|
-
|
10
|
-
// Mocking translation function
|
11
|
-
global.__ = text => text; // eslint-disable-line
|
12
|
-
|
13
|
-
// Mocking locales to prevent unnecessary fallback messages
|
14
|
-
window.locales = { en: { domain: 'app', locale_data: { app: { '': {} } } } };
|
15
|
-
|
16
|
-
// see https://github.com/testing-library/dom-testing-library/releases/tag/v7.0.0
|
17
|
-
window.MutationObserver = MutationObserver;
|