foreman_kernel_care 0.0.1 → 1.0.0.pre.alfa

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -5
  3. data/Rakefile +2 -2
  4. data/app/models/concerns/foreman_kernel_care/host_managed_extensions.rb +8 -2
  5. data/app/views/foreman_kernel_care/job_templates/update_kernel.erb +15 -0
  6. data/db/seeds.d/100_assign_features_with_templates.rb +21 -0
  7. data/db/seeds.d/70_job_templates.rb +28 -0
  8. data/lib/foreman_kernel_care/engine.rb +7 -32
  9. data/lib/foreman_kernel_care/remote_execution.rb +16 -0
  10. data/lib/foreman_kernel_care/version.rb +1 -1
  11. data/lib/tasks/foreman_kernel_care_tasks.rake +2 -12
  12. data/test/factories/foreman_kernel_care_factories.rb +14 -2
  13. data/test/test_plugin_helper.rb +4 -1
  14. data/test/unit/host_managed_extensions_test.rb +42 -0
  15. metadata +44 -36
  16. data/app/helpers/concerns/foreman_kernel_care/hosts_helper_extensions.rb +0 -13
  17. data/app/models/concerns/foreman_kernel_care/host_extensions.rb +0 -19
  18. data/app/views/dashboard/_foreman_kernel_care_widget.html.erb +0 -2
  19. data/app/views/foreman_kernel_care/layouts/layouts/new_layout.html.erb +0 -0
  20. data/app/views/foreman_kernel_care/layouts/new_layout.html.erb +0 -0
  21. data/config/routes.rb +0 -9
  22. data/locale/Makefile +0 -60
  23. data/locale/en/foreman_kernel_care.po +0 -19
  24. data/locale/foreman_kernel_care.pot +0 -19
  25. data/locale/gemspec.rb +0 -2
  26. data/package.json +0 -44
  27. data/test/unit/foreman_kernel_care_test.rb +0 -11
  28. data/webpack/global_index.js +0 -17
  29. data/webpack/global_test_setup.js +0 -11
  30. data/webpack/index.js +0 -8
  31. data/webpack/src/Components/EmptyState/Constants.js +0 -2
  32. data/webpack/src/Components/EmptyState/EmptyStateReducer.js +0 -19
  33. data/webpack/src/Components/EmptyState/ExtendedEmptyState.js +0 -43
  34. data/webpack/src/Components/EmptyState/__tests__/ExtendedEmptyState.test.js +0 -37
  35. data/webpack/src/Extends/index.js +0 -15
  36. data/webpack/src/Router/WelcomePage/Welcome.js +0 -9
  37. data/webpack/src/Router/WelcomePage/index.js +0 -1
  38. data/webpack/src/Router/routes.js +0 -12
  39. data/webpack/src/reducers.js +0 -10
  40. data/webpack/test_setup.js +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6d0461ccf8b6c5499dfad71c1a558c9624e38ca96736946a52418a08c29d5cb
4
- data.tar.gz: 1b048269ccdddc043d8dc5bbb35237ae32d1a3e3b8157d63abc3a5c8f1e3e189
3
+ metadata.gz: 5b69d029637d5bee05bb0c109c33c6c132f78eea786ffe869f65ca71b46b1094
4
+ data.tar.gz: e42b57600e3633a14238ac046a9782128f50d37002fbf2a806904c91f34a820c
5
5
  SHA512:
6
- metadata.gz: d06f81902376cf81f5539a221080d9c10d4802e4412f0bd86ba9f988a6e1aae5e3a827918f0a1f7646508b1ccd4b129946df51517946f44f3f27556cb4ccac32
7
- data.tar.gz: 5451791474e1a65fc39a29571118f742ba6c205f51fbee6993d38ed6110bf47b4e548860b1bfb0dd842be62ba7919d8433e6e9a9c49de8445d69ac3bfc535e1e
6
+ metadata.gz: 2033bc0576354e02c2b56bfd8dea0b966702c538ae3fbb967284b9a3a07afb659957c20baa0e619d82c29355dfbb505989188ef00fdf3dad8d0e75a8ab424e0b
7
+ data.tar.gz: 0b0a1f5475398e2340b22d6953cd785a5f911499ad8ba8b59d621d4469cfbb642b029e9ce401c6a060db115a535da43288c783b75c8198fb3acd305b969f709b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ForemanKernelCare
2
2
 
3
- Plugin for KernelCare
3
+ This plugin removes kernel [trace](https://theforeman.org/plugins/katello/3.18/user_guide/tracer/index.html) if [KernelCare](https://www.kernelcare.com/product/) package is installed on host
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,10 +11,6 @@ for how to install Foreman plugins
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!
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('../test/dummy/Rakefile', __FILE__)
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
 
@@ -5,9 +5,15 @@ module ForemanKernelCare
5
5
  tracer_profile.each do |trace, attributes|
6
6
  next if attributes[:helper].blank?
7
7
 
8
- next if trace == 'kernel' && kernelcare?
8
+ if trace.to_s == 'kernel' && kernelcare?
9
+ composer = ::JobInvocationComposer.for_feature(:update_kernel, self)
10
+ composer.triggering.mode = :future
11
+ composer.trigger!
9
12
 
10
- traces << { host_id: self.id, application: trace, helper: attributes[:helper], app_type: attributes[:type] }
13
+ next
14
+ end
15
+
16
+ traces << { host_id: id, application: trace, helper: attributes[:helper], app_type: attributes[:type] }
11
17
  end
12
18
  host_traces.delete_all
13
19
  Katello::HostTracer.import(traces, validate: false)
@@ -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,21 @@
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
+ end
20
+ end
21
+ 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,26 @@
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 '>= 2.4.0'
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 'ForemanKernelCare', [:view_foreman_kernel_care]
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
- begin
37
- Host::Managed.send(:include, ForemanKernelCare::HostExtensions)
38
- HostsHelper.send(:include, ForemanKernelCare::HostsHelperExtensions)
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
+ rescue StandardError => e
23
+ Rails.logger.warn "ForemanKernelCare: skipping engine hook (#{e})"
43
24
  end
44
25
 
45
26
  rake_tasks do
@@ -47,11 +28,5 @@ module ForemanKernelCare
47
28
  ForemanKernelCare::Engine.load_seed
48
29
  end
49
30
  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
31
  end
57
32
  end
@@ -0,0 +1,16 @@
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
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module ForemanKernelCare
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '1.0.0-alfa'.freeze
3
3
  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 :rubocop do
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.define do
1
+ FactoryBot.modify do
2
2
  factory :host do
3
- name 'foreman_kernel_care'
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
@@ -2,5 +2,8 @@
2
2
  require 'test_helper'
3
3
 
4
4
  # Add plugin to FactoryBot's paths
5
- FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
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,42 @@
1
+ require 'test_plugin_helper'
2
+
3
+ module ForemanKernelCare
4
+ class HostManagedExtensionsTestBase < ActiveSupport::TestCase
5
+ def setup
6
+ template = FactoryBot.create(:job_template, name: 'Update kernel')
7
+ template.sync_feature('update_kernel')
8
+ end
9
+ end
10
+
11
+ class HostTracerTest < HostManagedExtensionsTestBase
12
+ def setup
13
+ super
14
+ @tracer_json = {
15
+ "kernel": {
16
+ "type": 'static',
17
+ "helper": 'You will have to reboot your computer'
18
+ }
19
+ }
20
+ end
21
+
22
+ def test_import_kerenl_trace_with_kernelcare
23
+ host = FactoryBot.create(:host, :with_kernelcare)
24
+ host.import_tracer_profile(@tracer_json)
25
+ host.reload
26
+
27
+ assert_empty host.host_traces.where(application: 'kernel')
28
+ assert_equal 1, JobInvocation.count
29
+ assert_equal 'Update kernel', JobInvocation.first.description
30
+ end
31
+
32
+ def test_import_kerenl_trace_without_kernelcare
33
+ host = FactoryBot.create(:host)
34
+ host.import_tracer_profile(@tracer_json)
35
+ host.reload
36
+
37
+ assert_equal 1, host.host_traces.count
38
+ assert_equal 'kernel', host.host_traces.first.application
39
+ assert_empty JobInvocation.all
40
+ end
41
+ end
42
+ 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: 0.0.1
4
+ version: 1.0.0.pre.alfa
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Petukhov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2021-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rubocop
14
+ name: katello
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: foreman_remote_execution
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.6
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: rdoc
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: Plugin for KernelCare
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,18 @@ files:
48
77
  - LICENSE
49
78
  - README.md
50
79
  - Rakefile
51
- - app/helpers/concerns/foreman_kernel_care/hosts_helper_extensions.rb
52
- - app/models/concerns/foreman_kernel_care/host_extensions.rb
53
80
  - app/models/concerns/foreman_kernel_care/host_managed_extensions.rb
54
- - app/views/dashboard/_foreman_kernel_care_widget.html.erb
55
- - app/views/foreman_kernel_care/layouts/layouts/new_layout.html.erb
56
- - app/views/foreman_kernel_care/layouts/new_layout.html.erb
57
- - config/routes.rb
81
+ - app/views/foreman_kernel_care/job_templates/update_kernel.erb
82
+ - db/seeds.d/100_assign_features_with_templates.rb
83
+ - db/seeds.d/70_job_templates.rb
58
84
  - lib/foreman_kernel_care.rb
59
85
  - lib/foreman_kernel_care/engine.rb
86
+ - lib/foreman_kernel_care/remote_execution.rb
60
87
  - lib/foreman_kernel_care/version.rb
61
88
  - 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
89
  - test/factories/foreman_kernel_care_factories.rb
68
90
  - test/test_plugin_helper.rb
69
- - test/unit/foreman_kernel_care_test.rb
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
91
+ - test/unit/host_managed_extensions_test.rb
83
92
  homepage: https://github.com/maccelf/foreman_kernel_care
84
93
  licenses:
85
94
  - GPL-3.0
@@ -95,16 +104,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
104
  version: '0'
96
105
  required_rubygems_version: !ruby/object:Gem::Requirement
97
106
  requirements:
98
- - - ">="
107
+ - - ">"
99
108
  - !ruby/object:Gem::Version
100
- version: '0'
109
+ version: 1.3.1
101
110
  requirements: []
102
- rubygems_version: 3.1.2
111
+ rubygems_version: 3.1.6
103
112
  signing_key:
104
113
  specification_version: 4
105
114
  summary: Plugin for KernelCare
106
115
  test_files:
107
- - test/test_plugin_helper.rb
108
- - test/unit/foreman_kernel_care_test.rb
109
116
  - test/factories/foreman_kernel_care_factories.rb
110
- - webpack/src/Components/EmptyState/__tests__/ExtendedEmptyState.test.js
117
+ - test/test_plugin_helper.rb
118
+ - test/unit/host_managed_extensions_test.rb
@@ -1,13 +0,0 @@
1
- module ForemanKernelCare
2
- module HostsHelperExtensions
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
- end
13
- end
@@ -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
@@ -1,2 +0,0 @@
1
- <h4 class="header ca"><%= _('ForemanKernelCare') %></h4>
2
- <%= _('Widget content') %>
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
@@ -1,2 +0,0 @@
1
- # Matches foreman_kernel_care.gemspec
2
- _('TODO: Description of ForemanKernelCare.')
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
- }
@@ -1,11 +0,0 @@
1
- require 'test_plugin_helper'
2
-
3
- class ForemanPluginTemplateTest < ActiveSupport::TestCase
4
- setup do
5
- User.current = User.find_by_login 'admin'
6
- end
7
-
8
- test 'the truth' do
9
- assert true
10
- end
11
- end
@@ -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,2 +0,0 @@
1
- export const GENERAL_ACTION_TYPE = '[PLUGIN_TEMPLATE] GENERAL ACTION';
2
- export const FOREMAN_STORYBOOK = 'https://foreman.surge.sh';
@@ -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';
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import WelcomePage from './WelcomePage';
3
-
4
- const routes = [
5
- {
6
- path: '/foreman_kernel_care/welcome',
7
- exact: true,
8
- render: (props) => <WelcomePage {...props} />,
9
- },
10
- ];
11
-
12
- export default routes;
@@ -1,10 +0,0 @@
1
- import { combineReducers } from 'redux';
2
- import EmptyStateReducer from './Components/EmptyState/EmptyStateReducer';
3
-
4
- const reducers = {
5
- foremanKernelCare: combineReducers({
6
- emptyState: EmptyStateReducer,
7
- }),
8
- };
9
-
10
- export default reducers;
@@ -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;