foreman_omaha 3.0.0 → 5.0.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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/Rakefile +4 -2
  4. data/app/controllers/api/v2/omaha_groups_controller.rb +2 -0
  5. data/app/controllers/api/v2/omaha_reports_controller.rb +2 -0
  6. data/app/controllers/omaha_groups_controller.rb +2 -0
  7. data/app/controllers/omaha_hosts_controller.rb +6 -4
  8. data/app/controllers/omaha_reports_controller.rb +2 -0
  9. data/app/graphql/concerns/foreman_omaha/types/host_extensions.rb +13 -0
  10. data/app/graphql/foreman_omaha/types/omaha_group.rb +21 -0
  11. data/app/graphql/foreman_omaha/types/omaha_report.rb +21 -0
  12. data/app/graphql/foreman_omaha/types/omaha_report_status_enum.rb +11 -0
  13. data/app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb +2 -0
  14. data/app/helpers/foreman_omaha/application_helper.rb +2 -0
  15. data/app/helpers/foreman_omaha/omaha_groups_helper.rb +2 -0
  16. data/app/helpers/omaha_hosts_helper.rb +2 -0
  17. data/app/helpers/omaha_reports_helper.rb +2 -0
  18. data/app/models/concerns/foreman_omaha/host_extensions.rb +3 -1
  19. data/app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb +2 -0
  20. data/app/models/foreman_omaha/fact_name.rb +2 -0
  21. data/app/models/foreman_omaha/omaha_facet.rb +2 -0
  22. data/app/models/foreman_omaha/omaha_group.rb +4 -0
  23. data/app/models/foreman_omaha/omaha_report.rb +4 -0
  24. data/app/models/host_status/omaha_status.rb +2 -0
  25. data/app/services/foreman_omaha/charts/oem_distribution.rb +2 -0
  26. data/app/services/foreman_omaha/charts/status_distribution.rb +2 -0
  27. data/app/services/foreman_omaha/charts/version_distribution.rb +2 -0
  28. data/app/services/foreman_omaha/container_linux_config_transpiler.rb +3 -0
  29. data/app/services/foreman_omaha/fact_importer.rb +2 -0
  30. data/app/services/foreman_omaha/fact_parser.rb +11 -3
  31. data/app/services/foreman_omaha/group_version_breakdown.rb +2 -0
  32. data/app/services/foreman_omaha/omaha_report_importer.rb +2 -0
  33. data/app/services/foreman_omaha/status_mapper.rb +2 -2
  34. data/app/services/foreman_omaha/template_renderer_helper.rb +9 -0
  35. data/app/views/api/v2/omaha_groups/base.json.rabl +2 -0
  36. data/app/views/api/v2/omaha_groups/index.json.rabl +2 -0
  37. data/app/views/api/v2/omaha_groups/main.json.rabl +2 -0
  38. data/app/views/api/v2/omaha_groups/show.json.rabl +2 -0
  39. data/app/views/api/v2/omaha_reports/base.json.rabl +2 -0
  40. data/app/views/api/v2/omaha_reports/create.json.rabl +2 -0
  41. data/app/views/api/v2/omaha_reports/index.json.rabl +2 -0
  42. data/app/views/api/v2/omaha_reports/main.json.rabl +2 -0
  43. data/app/views/api/v2/omaha_reports/show.json.rabl +2 -0
  44. data/app/views/api/v2/omaha_reports/update.json.rabl +2 -0
  45. data/app/views/foreman_omaha/api/v2/omaha_facets/base.json.rabl +2 -0
  46. data/app/views/foreman_omaha/api/v2/omaha_facets/base_with_root.json.rabl +2 -0
  47. data/app/views/foreman_omaha/api/v2/omaha_facets/show.json.rabl +2 -0
  48. data/app/views/omaha_reports/_list.html.erb +1 -1
  49. data/config/routes.rb +2 -0
  50. data/db/migrate/20160812083100_add_omaha_fields_to_reports.foreman_omaha.rb +2 -0
  51. data/db/migrate/20171101204100_create_omaha_facets.foreman_omaha.rb +2 -0
  52. data/db/seeds.d/200_omaha_groups.rb +2 -0
  53. data/db/seeds.d/60_omaha_proxy_feature.rb +2 -0
  54. data/lib/foreman_omaha/engine.rb +28 -14
  55. data/lib/foreman_omaha/version.rb +3 -1
  56. data/lib/foreman_omaha.rb +2 -0
  57. data/lib/tasks/foreman_omaha_tasks.rake +2 -0
  58. data/locale/gemspec.rb +2 -0
  59. data/test/factories/feature.rb +3 -1
  60. data/test/factories/foreman_omaha_factories.rb +8 -6
  61. data/test/factories/host.rb +19 -4
  62. data/test/factories/smart_proxy.rb +2 -0
  63. data/test/functional/api/v2/omaha_groups_controller_test.rb +2 -0
  64. data/test/functional/api/v2/omaha_reports_controller_test.rb +4 -2
  65. data/test/functional/omaha_groups_controller_test.rb +2 -0
  66. data/test/functional/omaha_hosts_controller_test.rb +2 -0
  67. data/test/functional/omaha_reports_controller_test.rb +2 -0
  68. data/test/graphql/queries/host_query_extensions_test.rb +41 -0
  69. data/test/graphql/queries/omaha_group_query_test.rb +51 -0
  70. data/test/graphql/queries/omaha_groups_query_test.rb +47 -0
  71. data/test/graphql/queries/omaha_report_query_test.rb +44 -0
  72. data/test/graphql/queries/omaha_reports_query_test.rb +47 -0
  73. data/test/test_plugin_helper.rb +2 -0
  74. data/test/unit/charts/oem_distribution_test.rb +2 -0
  75. data/test/unit/charts/status_distribution_test.rb +2 -0
  76. data/test/unit/charts/version_distribution_test.rb +2 -0
  77. data/test/unit/group_version_breakdown_test.rb +2 -0
  78. data/test/unit/host_status/omaha_status_test.rb +4 -2
  79. data/test/unit/host_test.rb +2 -0
  80. data/test/unit/omaha_fact_parser_test.rb +67 -23
  81. data/test/unit/omaha_report_test.rb +2 -0
  82. data/test/unit/renderer_test.rb +2 -0
  83. metadata +64 -9
  84. data/app/lib/foreman_omaha/renderer/scope/macros/omaha.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 421a748a9a01373e725254764e8ec0eec455da8db499a948d46de2215b9378bf
4
- data.tar.gz: 893fd2401152eba58c412e5e87900d9d246fc6f0849f091e94172ea740f32dc8
3
+ metadata.gz: c0ee3bbe2a41f9d5ac5ffac14c72895f5f523ba58691cdbd59c21086638d74b7
4
+ data.tar.gz: 6348671022cae92df4f7da03f665514234f325be028c523db136ab3c81244eea
5
5
  SHA512:
6
- metadata.gz: '09028f73bcf73132903dfe8318befca2428178f01b9b83138fed7d431a7b51eda6b4268ca3d6cc3851871587391fabd45c7b54c35ee802c2532c970867c25cda'
7
- data.tar.gz: 5e5cc0bb9cda50abe5bb9cec5d04ac46711403465928a9fda8e6e8b32fe0d9ab05d6bec380d9077fbf3ee16567ae3fffa3c08186f2ead2ca3e1c2d5c4d0ec2a2
6
+ metadata.gz: b97bae1c564d7745876cae86a16558f986057a63553676e8c55e6199208c810cceeca7f8a588bb637399fc32c485bfac874b61b649dd0e9252752c3226be467c
7
+ data.tar.gz: adae755d7a4e0859663bea2495c2ccce1041a7d05d478ae4eca3ca2d8910a8aff3bdcca925165e6a28101005612a5ffc980e7af2a1a0fe427a884b9f92f98ebd
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ForemanOmaha
2
2
 
3
- This plug-in enables CoreOS updates using [The Foreman](https://theforeman.org/) without using the public update infrastructure.
3
+ This plug-in enables CoreOS and Flatcar updates using [The Foreman](https://theforeman.org/) without using the public update infrastructure.
4
4
  To follow along with common Foreman architecture, you need this Foreman plug-in installed and a [Smart-Proxy plugin](https://github.com/theforeman/smart_proxy_omaha). The smart-proxy plug-in does all the heavy lifting. The Foreman plug-in shows facts and reports for your hosts.
5
5
  Foreman core already supports deploying CoreOS hosts and is great for on-premise setups. This plug-in enables you to better manage your servers.
6
6
 
@@ -12,6 +12,8 @@ Foreman core already supports deploying CoreOS hosts and is great for on-premise
12
12
  | >= 1.17 | ~> 1.0 |
13
13
  | >= 1.18 | ~> 2.0 |
14
14
  | >= 1.20 | ~> 3.0 |
15
+ | >= 1.24 | ~> 4.0 |
16
+ | >= 3.0 | ~> 5.0 |
15
17
 
16
18
  ## Installation
17
19
 
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env rake
2
+ # frozen_string_literal: true
3
+
2
4
  begin
3
5
  require 'bundler/setup'
4
6
  rescue LoadError
@@ -20,7 +22,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
22
  rdoc.rdoc_files.include('lib/**/*.rb')
21
23
  end
22
24
 
23
- APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
25
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
24
26
 
25
27
  Bundler::GemHelper.install_tasks
26
28
 
@@ -38,7 +40,7 @@ task default: :test
38
40
  begin
39
41
  require 'rubocop/rake_task'
40
42
  RuboCop::RakeTask.new
41
- rescue => _
43
+ rescue StandardError => _e
42
44
  puts 'Rubocop not loaded.'
43
45
  end
44
46
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Api
2
4
  module V2
3
5
  class OmahaGroupsController < V2::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Api
2
4
  module V2
3
5
  class OmahaReportsController < V2::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class OmahaGroupsController < ApplicationController
2
4
  include Foreman::Controller::AutoCompleteSearch
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class OmahaHostsController < ApplicationController
2
4
  include Foreman::Controller::AutoCompleteSearch
3
5
  include ScopesPerAction
@@ -15,10 +17,10 @@ class OmahaHostsController < ApplicationController
15
17
 
16
18
  def welcome
17
19
  has_entries = begin
18
- resource_base.first.nil?
19
- rescue StandardError
20
- false
21
- end
20
+ resource_base.first.nil?
21
+ rescue StandardError
22
+ false
23
+ end
22
24
  if has_entries
23
25
  @welcome = true
24
26
  render :welcome
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class OmahaReportsController < ApplicationController
2
4
  include Foreman::Controller::AutoCompleteSearch
3
5
 
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanOmaha
4
+ module Types
5
+ module HostExtensions
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ has_many :omaha_reports, ForemanOmaha::Types::OmahaReport
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanOmaha
4
+ module Types
5
+ class OmahaGroup < ::Types::BaseObject
6
+ model_class ForemanOmaha::OmahaGroup
7
+ description 'An Omaha Group'
8
+
9
+ global_id_field :id
10
+ timestamps
11
+ field :name, String
12
+ field :uuid, String
13
+
14
+ has_many :hosts, ::Types::Host
15
+
16
+ def self.graphql_definition
17
+ super.tap { |type| type.instance_variable_set(:@name, 'ForemanOmaha::OmahaGroup') }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanOmaha
4
+ module Types
5
+ class OmahaReport < ::Types::BaseObject
6
+ model_class ForemanOmaha::OmahaReport
7
+ description 'An Omaha Report'
8
+
9
+ global_id_field :id
10
+ timestamps
11
+ field :status, ForemanOmaha::Types::OmahaReportStatusEnum
12
+ field :omaha_version, String
13
+
14
+ belongs_to :host, ::Types::Host
15
+
16
+ def self.graphql_definition
17
+ super.tap { |type| type.instance_variable_set(:@name, 'ForemanOmaha::OmahaReport') }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanOmaha
4
+ module Types
5
+ class OmahaReportStatusEnum < ::Types::BaseEnum
6
+ ForemanOmaha::OmahaFacet::VALID_OMAHA_STATUSES.each do |status|
7
+ value status
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module HostsHelperExtensions
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module ApplicationHelper
3
5
  def facets_count(association, resource_name = controller.resource_name)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module OmahaGroupsHelper
3
5
  def omaha_version_breakdown_bar(omaha_group)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OmahaHostsHelper
2
4
  def last_omaha_report_column(record)
3
5
  time = record.omaha_facet.last_report? ? _('%s ago') % time_ago_in_words(record.omaha_facet.last_report) : ''
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OmahaReportsHelper
2
4
  def iconclass_for_omaha_status(status)
3
5
  case status.to_sym
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module HostExtensions
3
5
  extend ActiveSupport::Concern
@@ -14,7 +16,7 @@ module ForemanOmaha
14
16
  end
15
17
 
16
18
  def clear_omaha_facet
17
- omaha_facet.destroy if omaha_facet
19
+ omaha_facet&.destroy
18
20
  end
19
21
 
20
22
  def clear_omaha_facet_on_build
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module OmahaFacetHostExtensions
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class FactName < ::FactName
3
5
  def origin
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class OmahaFacet < ApplicationRecord
3
5
  include Facets::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class OmahaGroup < ApplicationRecord
3
5
  include Authorizable
@@ -6,6 +8,8 @@ module ForemanOmaha
6
8
  N_('Omaha Channel')
7
9
  end
8
10
 
11
+ graphql_type '::Types::OmahaGroup'
12
+
9
13
  has_many :omaha_facets, :class_name => 'ForemanOmaha::OmahaFacet', :foreign_key => :omaha_group_id,
10
14
  :inverse_of => :omaha_group, :dependent => :restrict_with_exception
11
15
  has_many :hosts, :class_name => '::Host::Managed', :through => :omaha_facets,
@@ -1,7 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class OmahaReport < ::Report
3
5
  enum :status => OmahaFacet::VALID_OMAHA_STATUSES
4
6
 
7
+ graphql_type '::Types::OmahaReport'
8
+
5
9
  scoped_search :on => :omaha_version, :rename => :version, :complete_value => true
6
10
  scoped_search :on => :status, :complete_value => statuses
7
11
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HostStatus
2
4
  class OmahaStatus < HostStatus::Status
3
5
  def self.status_name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module Charts
3
5
  class OemDistribution
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module Charts
3
5
  class StatusDistribution
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module Charts
3
5
  class VersionDistribution
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open3'
2
4
 
3
5
  module ForemanOmaha
4
6
  class ContainerLinuxConfigTranspiler
5
7
  class TranspilerNotFound < StandardError; end
8
+
6
9
  class TranspileError < StandardError; end
7
10
 
8
11
  attr_accessor :input, :output, :errors, :status
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class FactImporter < ::FactImporter
3
5
  def self.authorized_smart_proxy_features
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class FactParser < ::FactParser
3
5
  def operatingsystem
4
- args = { :name => facts['platform'], :major => facts['osmajor'], :minor => facts['osminor'] }
5
- description = "#{facts['platform']} #{facts['version']}"
6
+ args = { :name => os_name, :major => facts['osmajor'], :minor => facts['osminor'] }
7
+ description = "#{os_name} #{facts['version']}"
6
8
  Coreos.where(args).first ||
7
9
  create_coreos_version(args.merge(:description => description,
8
10
  :release_name => facts['track']))
@@ -31,6 +33,12 @@ module ForemanOmaha
31
33
 
32
34
  private
33
35
 
36
+ def os_name
37
+ return 'Flatcar' if facts['distribution']&.downcase == 'flatcar'
38
+
39
+ facts['platform']
40
+ end
41
+
34
42
  def create_coreos_version(attrs)
35
43
  previous_version = previous_coreos_version
36
44
  return Coreos.create!(attrs) unless previous_coreos_version
@@ -43,7 +51,7 @@ module ForemanOmaha
43
51
  end
44
52
 
45
53
  def previous_coreos_version
46
- Coreos.all.max_by { |os| Gem::Version.new(os.release) }
54
+ Coreos.where(name: os_name).max_by { |os| Gem::Version.new(os.release) }
47
55
  end
48
56
  end
49
57
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class GroupVersionBreakdown
3
5
  attr_accessor :omaha_group
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class OmahaReportImporter < ::ReportImporter
3
5
  def report_name_class
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class StatusMapper
3
5
  attr_accessor :status
@@ -25,7 +27,6 @@ module ForemanOmaha
25
27
  end
26
28
  end
27
29
 
28
- # rubocop:disable Metrics/CyclomaticComplexity
29
30
  def to_description(version = nil)
30
31
  case status.to_sym
31
32
  when :complete
@@ -48,6 +49,5 @@ module ForemanOmaha
48
49
  _('The status of this host is unknown.')
49
50
  end
50
51
  end
51
- # rubocop:enable Metrics/CyclomaticComplexity
52
52
  end
53
53
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanOmaha
4
+ module TemplateRendererHelper
5
+ def transpile_container_linux_config(input)
6
+ ForemanOmaha::ContainerLinuxConfigTranspiler.new(input).run!
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_group
2
4
 
3
5
  attributes :id, :name, :uuid
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  collection @omaha_groups
2
4
 
3
5
  extends 'api/v2/omaha_groups/main'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_group
2
4
 
3
5
  extends 'api/v2/omaha_groups/base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_group
2
4
 
3
5
  extends 'api/v2/omaha_groups/main'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  attributes :id, :host_id, :host_name, :reported_at, :status
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  extends 'api/v2/omaha_reports/show'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  collection @omaha_reports
2
4
 
3
5
  extends 'api/v2/omaha_reports/main'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  extends 'api/v2/omaha_reports/base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  extends 'api/v2/omaha_reports/main'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  extends 'api/v2/omaha_reports/show'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  attributes :id, :last_report, :version, :machineid, :status
2
4
 
3
5
  child :omaha_group => :omaha_group do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  child :omaha_facet => :omaha_facet_attributes do |_omaha_facet|
2
4
  extends 'foreman_omaha/api/v2/omaha_facets/base'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  child :omaha_facet => :omaha_facet_attributes do
2
4
  extends 'foreman_omaha/api/v2/omaha_facets/base'
3
5
  end
@@ -25,7 +25,7 @@
25
25
  <td title="<%= report.to_description(report.omaha_version) %>"><span class="<%= iconclass_for_omaha_status(report.status) %>"></span> <%= report.to_label %></td>
26
26
  <td>
27
27
  <%= action_buttons(display_delete_if_authorized hash_for_omaha_report_path(:id => report).merge(:auth_object => report, :authorizer => authorizer),
28
- :confirm => _("Delete report for %s?") % report.host.try(:name)) %>
28
+ :data => { :confirm => _("Delete report for %s?") % report.host.try(:name)}) %>
29
29
  </td>
30
30
  </tr>
31
31
  <% end %>
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  namespace :api, :defaults => { :format => 'json' } do
3
5
  scope '(:apiv)', :module => :v2,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddOmahaFieldsToReports < ActiveRecord::Migration[4.2]
2
4
  def change
3
5
  add_column :reports, :omaha_version, :string
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateOmahaFacets < ActiveRecord::Migration[4.2]
2
4
  def change
3
5
  create_table :omaha_groups do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  default_groups = %w[Alpha Beta Stable]
2
4
 
3
5
  default_groups.each do |group|
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  f = Feature.where(:name => 'Omaha').first_or_create
2
4
  raise "Unable to create proxy feature: #{format_errors f}" if f.nil? || f.errors.any?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jquery-matchheight-rails'
2
4
 
3
5
  module ForemanOmaha
@@ -19,7 +21,7 @@ module ForemanOmaha
19
21
 
20
22
  initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |_app|
21
23
  Foreman::Plugin.register :foreman_omaha do
22
- requires_foreman '>= 1.20'
24
+ requires_foreman '>= 3.0'
23
25
 
24
26
  apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
25
27
 
@@ -49,9 +51,11 @@ module ForemanOmaha
49
51
  end
50
52
 
51
53
  role 'Omaha reports viewer',
52
- [:view_omaha_reports]
54
+ [:view_omaha_reports],
55
+ 'Role granting permissions to view Omaha reports.'
53
56
  role 'Omaha reports manager',
54
- [:view_omaha_reports, :destroy_omaha_reports, :upload_omaha_reports]
57
+ [:view_omaha_reports, :destroy_omaha_reports, :upload_omaha_reports],
58
+ 'Role granting permissions to manage Omaha reports.'
55
59
 
56
60
  # add menu entry
57
61
  menu :top_menu, :omaha_reports,
@@ -87,10 +91,17 @@ module ForemanOmaha
87
91
  :onlyif => proc { |host| host.omaha_facet }
88
92
  end
89
93
 
90
- add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:omaha_facet) }
94
+ add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:omaha_facet) }
91
95
 
92
96
  # add renderer extensions
97
+ extend_template_helpers ForemanOmaha::TemplateRendererHelper
93
98
  allowed_template_helpers :transpile_container_linux_config
99
+
100
+ register_graphql_query_field :omaha_group, 'ForemanOmaha::Types::OmahaGroup', :record_field
101
+ register_graphql_query_field :omaha_groups, 'ForemanOmaha::Types::OmahaGroup', :collection_field
102
+
103
+ register_graphql_query_field :omaha_report, 'ForemanOmaha::Types::OmahaReport', :record_field
104
+ register_graphql_query_field :omaha_reports, 'ForemanOmaha::Types::OmahaReport', :collection_field
94
105
  end
95
106
 
96
107
  # Extend built in permissions
@@ -102,17 +113,20 @@ module ForemanOmaha
102
113
 
103
114
  # Include concerns in this config.to_prepare block
104
115
  config.to_prepare do
105
- begin
106
- ::FactImporter.register_fact_importer(:foreman_omaha, ForemanOmaha::FactImporter)
107
- ::FactParser.register_fact_parser(:foreman_omaha, ForemanOmaha::FactParser)
108
-
109
- Host::Managed.send(:include, ForemanOmaha::HostExtensions)
110
- Host::Managed.send(:include, ForemanOmaha::OmahaFacetHostExtensions)
111
- HostsHelper.send(:include, ForemanOmaha::HostsHelperExtensions)
112
- Foreman::Renderer::Scope::Base.send(:include, ForemanOmaha::Renderer::Scope::Macros::Omaha)
113
- rescue StandardError => e
114
- Rails.logger.warn "ForemanOmaha: skipping engine hook (#{e})"
116
+ Foreman::Plugin.fact_importer_registry.register(:foreman_omaha, ForemanOmaha::FactImporter, true)
117
+
118
+ if Foreman::Plugin.respond_to?(:fact_parser_registry)
119
+ Foreman::Plugin.fact_parser_registry.register(:foreman_omaha, ForemanOmaha::FactParser, true)
120
+ else
121
+ Foreman::Plugin.fact_importer_registry.register(:foreman_omaha, ForemanOmaha::FactParser, true)
115
122
  end
123
+
124
+ ::Host::Managed.include(ForemanOmaha::HostExtensions)
125
+ ::Host::Managed.include(ForemanOmaha::OmahaFacetHostExtensions)
126
+ ::HostsHelper.include(ForemanOmaha::HostsHelperExtensions)
127
+ ::Types::Host.include(ForemanOmaha::Types::HostExtensions)
128
+ rescue StandardError => e
129
+ Rails.logger.warn "ForemanOmaha: skipping engine hook (#{e})"
116
130
  end
117
131
 
118
132
  rake_tasks do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
- VERSION = '3.0.0'.freeze
4
+ VERSION = '5.0.0'
3
5
  end
data/lib/foreman_omaha.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'foreman_omaha/engine'
2
4
 
3
5
  module ForemanOmaha
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Tasks
2
4
  namespace :foreman_omaha do
3
5
  namespace :example do