foreman_omaha 5.0.1 → 5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4de0935e85838acb0fdd917072c2619b9fb24eb9496f8075ecf5addc0c517e4f
4
- data.tar.gz: '0047259a6a55630216f155c2751c391256fddb5b11d8f47a2494d647283b4a62'
3
+ metadata.gz: 991466be3a58e6ec0a11da16ccbc0af98cedc117f4def524948a64e96504f0db
4
+ data.tar.gz: e511bc47ecc16080e2ba16cc399d32d8c46d02212aa6ccccee075dccd5ea0d18
5
5
  SHA512:
6
- metadata.gz: d1aa36e5c03a1104802f968f9417217ffcb67c628aefba80efc4ecadd6ba940275d0c08ce9c2a490ec8ddb66782f8bf366945732506ad3244ef3f0e849667447
7
- data.tar.gz: 32bf0acccb2ebd329f66651874fa1b68822851c7c1c9ce8d85b0c45e29505455b1fd2be09e59c0564f5173f1ddca8940c81dda13f2848817c777ebaaaf6805dd
6
+ metadata.gz: de3df0f800c907f7cbfdccde128e11e57b7415c72a39c517d5c4021fd7bfa0321a8cddcfea276b285adeeb8bbae387f5398cde569ff49d3c5c6c46a01dea5db9
7
+ data.tar.gz: 599c02b711439bae7aea6559948b50eafdac63a8374c62500c428d0effac14683c88745fb16bb79108011fdb64f6f9a31081a1baa816a6143037f2edb45aede4
@@ -72,8 +72,9 @@ module Api
72
72
  ::ForemanOmaha::OmahaReport
73
73
  end
74
74
 
75
- def resource_scope(options = {})
76
- super(options.merge(:permission => :view_omaha_reports)).my_reports
75
+ def resource_scope(*args, **options)
76
+ options[:permission] = :view_omaha_reports
77
+ super(*args, **options).my_reports
77
78
  end
78
79
 
79
80
  def action_permission
@@ -29,12 +29,12 @@ class OmahaHostsController < ApplicationController
29
29
  not_found
30
30
  end
31
31
 
32
- protected
33
-
34
32
  def model_of_controller
35
33
  ::Host::Managed
36
34
  end
37
35
 
36
+ protected
37
+
38
38
  def resource_base
39
39
  super.joins(:omaha_facet)
40
40
  end
@@ -3,6 +3,7 @@
3
3
  module ForemanOmaha
4
4
  module Types
5
5
  class OmahaGroup < ::Types::BaseObject
6
+ graphql_name 'ForemanOmaha_OmahaGroup'
6
7
  model_class ForemanOmaha::OmahaGroup
7
8
  description 'An Omaha Group'
8
9
 
@@ -12,10 +13,6 @@ module ForemanOmaha
12
13
  field :uuid, String
13
14
 
14
15
  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
16
  end
20
17
  end
21
18
  end
@@ -3,6 +3,7 @@
3
3
  module ForemanOmaha
4
4
  module Types
5
5
  class OmahaReport < ::Types::BaseObject
6
+ graphql_name 'ForemanOmaha_OmahaReport'
6
7
  model_class ForemanOmaha::OmahaReport
7
8
  description 'An Omaha Report'
8
9
 
@@ -12,10 +13,6 @@ module ForemanOmaha
12
13
  field :omaha_version, String
13
14
 
14
15
  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
16
  end
20
17
  end
21
18
  end
@@ -11,7 +11,7 @@ module ForemanOmaha
11
11
 
12
12
  belongs_to :omaha_group, :inverse_of => :omaha_facets, :class_name => 'ForemanOmaha::OmahaGroup'
13
13
 
14
- scope :out_of_sync, ->(*args) { where(['last_report < ?', (args.first || (30 + Setting[:outofsync_interval]).minutes.ago)]) }
14
+ scope :out_of_sync, ->(*args) { where(['last_report < ?', args.first || (30 + Setting[:outofsync_interval]).minutes.ago]) }
15
15
 
16
16
  validates_lengths_from_database
17
17
 
@@ -26,12 +26,7 @@ module ForemanOmaha
26
26
  end
27
27
 
28
28
  def latest_operatingsystem
29
- case database_adapter_type
30
- when :postgresql
31
- operatingsystems.reorder('').order('major::text::integer DESC').order('minor::text::float DESC').limit(1).last
32
- else
33
- operatingsystems.reorder('').order(:major, :minor).last
34
- end
29
+ operatingsystems.reorder('').order(:major, :minor).last
35
30
  end
36
31
 
37
32
  private
@@ -39,9 +34,5 @@ module ForemanOmaha
39
34
  def ensure_uuid
40
35
  self.uuid ||= SecureRandom.uuid
41
36
  end
42
-
43
- def database_adapter_type
44
- ActiveRecord::Base.connection.adapter_name.downcase.to_sym
45
- end
46
37
  end
47
38
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module HostStatus
4
- class OmahaStatus < HostStatus::Status
3
+ module ForemanOmaha
4
+ class OmahaStatus < ::HostStatus::Status
5
5
  def self.status_name
6
6
  N_('Omaha Status')
7
7
  end
@@ -17,13 +17,13 @@ module HostStatus
17
17
 
18
18
  case host.omaha_facet.status.to_sym
19
19
  when :complete, :downloaded, :downloading, :installed
20
- HostStatus::Global::OK
20
+ ::HostStatus::Global::OK
21
21
  when :instance_hold
22
- HostStatus::Global::WARN
22
+ ::HostStatus::Global::WARN
23
23
  when :error
24
- HostStatus::Global::ERROR
24
+ ::HostStatus::Global::ERROR
25
25
  else
26
- HostStatus::Global::OK
26
+ ::HostStatus::Global::OK
27
27
  end
28
28
  end
29
29
 
@@ -1,5 +1,4 @@
1
1
  <% javascript 'foreman_omaha/application' %>
2
- <% javascript 'charts' %>
3
2
  <% title @omaha_group.name %>
4
3
  <%= breadcrumbs(
5
4
  items: [
data/config/routes.rb CHANGED
@@ -6,7 +6,7 @@ Rails.application.routes.draw do
6
6
  :defaults => { :apiv => 'v2' },
7
7
  :apiv => /v1|v2/,
8
8
  :constraints => ApiConstraints.new(:version => 2, :default => true) do
9
- constraints(:id => /[^\/]+/) do
9
+ constraints(:id => %r{[^/]+}) do
10
10
  resources :omaha_reports, :only => [:index, :show, :destroy] do
11
11
  get :last, :on => :collection
12
12
  end
@@ -34,9 +34,9 @@ Rails.application.routes.draw do
34
34
  end
35
35
  end
36
36
 
37
- constraints(:id => /[^\/]+/) do
37
+ constraints(:id => %r{[^/]+}) do
38
38
  resources :hosts do
39
- constraints(:host_id => /[^\/]+/) do
39
+ constraints(:host_id => %r{[^/]+}) do
40
40
  resources :omaha_reports, :only => [:index, :show]
41
41
  end
42
42
  end
@@ -19,99 +19,101 @@ module ForemanOmaha
19
19
  end
20
20
  end
21
21
 
22
- initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |_app|
23
- Foreman::Plugin.register :foreman_omaha do
24
- requires_foreman '>= 3.0'
25
-
26
- automatic_assets(false)
27
- precompile_assets(['foreman_omaha/version_breakdown.css', 'foreman_omaha/application.js'])
28
-
29
- apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
30
-
31
- register_custom_status HostStatus::OmahaStatus
32
-
33
- # Add permissions
34
- security_block :foreman_omaha do
35
- permission :view_omaha_reports, {
36
- :omaha_reports => [:index, :show, :auto_complete_search],
37
- :'api/v2/omaha_reports' => [:index, :show, :last]
38
- }, :resource_type => 'ForemanOmaha::OmahaReport'
39
-
40
- permission :destroy_omaha_reports, {
41
- :omaha_reports => [:destroy],
42
- :'api/v2/omaha_reports' => [:destroy]
43
- }, :resource_type => 'ForemanOmaha::OmahaReport'
44
-
45
- permission :upload_omaha_reports, {
46
- :omaha_reports => [:create],
47
- :'api/v2/omaha_reports' => [:create]
48
- }, :resource_type => 'ForemanOmaha::OmahaReport'
49
-
50
- permission :view_omaha_groups, {
51
- :omaha_groups => [:index, :auto_complete_search, :show],
52
- :'api/v2/omaha_groups' => [:index, :show]
53
- }, :resource_type => 'ForemanOmaha::OmahaGroup'
22
+ initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |app|
23
+ app.reloader.to_prepare do
24
+ Foreman::Plugin.register :foreman_omaha do
25
+ requires_foreman '>= 3.0'
26
+
27
+ automatic_assets(false)
28
+ precompile_assets(['foreman_omaha/version_breakdown.css', 'foreman_omaha/application.js'])
29
+
30
+ apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
31
+
32
+ register_custom_status ForemanOmaha::OmahaStatus
33
+
34
+ # Add permissions
35
+ security_block :foreman_omaha do
36
+ permission :view_omaha_reports, {
37
+ :omaha_reports => [:index, :show, :auto_complete_search],
38
+ :'api/v2/omaha_reports' => [:index, :show, :last]
39
+ }, :resource_type => 'ForemanOmaha::OmahaReport'
40
+
41
+ permission :destroy_omaha_reports, {
42
+ :omaha_reports => [:destroy],
43
+ :'api/v2/omaha_reports' => [:destroy]
44
+ }, :resource_type => 'ForemanOmaha::OmahaReport'
45
+
46
+ permission :upload_omaha_reports, {
47
+ :omaha_reports => [:create],
48
+ :'api/v2/omaha_reports' => [:create]
49
+ }, :resource_type => 'ForemanOmaha::OmahaReport'
50
+
51
+ permission :view_omaha_groups, {
52
+ :omaha_groups => [:index, :auto_complete_search, :show],
53
+ :'api/v2/omaha_groups' => [:index, :show]
54
+ }, :resource_type => 'ForemanOmaha::OmahaGroup'
55
+ end
56
+
57
+ role 'Omaha reports viewer',
58
+ [:view_omaha_reports],
59
+ 'Role granting permissions to view Omaha reports.'
60
+ role 'Omaha reports manager',
61
+ [:view_omaha_reports, :destroy_omaha_reports, :upload_omaha_reports],
62
+ 'Role granting permissions to manage Omaha reports.'
63
+
64
+ # add menu entry
65
+ menu :top_menu, :omaha_reports,
66
+ :url_hash => { controller: :omaha_reports, action: :index },
67
+ :caption => N_('Omaha Reports'),
68
+ :parent => :monitor_menu,
69
+ :after => :reports
70
+
71
+ menu :top_menu, :omaha_hosts,
72
+ :url_hash => { :controller => :omaha_hosts, :action => :index },
73
+ :caption => N_('Omaha Hosts'),
74
+ :parent => :hosts_menu,
75
+ :after => :hosts
76
+
77
+ divider :top_menu, :caption => N_('Omaha'), :parent => :configure_menu, :last => true
78
+
79
+ menu :top_menu, :omaha_groups,
80
+ :url_hash => { :controller => :omaha_groups, :action => :index },
81
+ :caption => N_('Omaha Groups'),
82
+ :parent => :configure_menu,
83
+ :last => :true
84
+
85
+ # Omaha Facet
86
+ register_facet(ForemanOmaha::OmahaFacet, :omaha_facet) do
87
+ api_view :list => 'foreman_omaha/api/v2/omaha_facets/base_with_root', :single => 'foreman_omaha/api/v2/omaha_facets/show'
88
+ end
89
+
90
+ # extend host show page
91
+ extend_page('hosts/show') do |context|
92
+ context.add_pagelet :main_tabs,
93
+ :name => N_('Omaha'),
94
+ :partial => 'hosts/omaha_tab',
95
+ :onlyif => proc(&:omaha_facet)
96
+ end
97
+
98
+ add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:omaha_facet) }
99
+
100
+ # add renderer extensions
101
+ extend_template_helpers ForemanOmaha::TemplateRendererHelper
102
+ allowed_template_helpers :transpile_container_linux_config
103
+
104
+ register_graphql_query_field :omaha_group, 'ForemanOmaha::Types::OmahaGroup', :record_field
105
+ register_graphql_query_field :omaha_groups, 'ForemanOmaha::Types::OmahaGroup', :collection_field
106
+
107
+ register_graphql_query_field :omaha_report, 'ForemanOmaha::Types::OmahaReport', :record_field
108
+ register_graphql_query_field :omaha_reports, 'ForemanOmaha::Types::OmahaReport', :collection_field
54
109
  end
55
110
 
56
- role 'Omaha reports viewer',
57
- [:view_omaha_reports],
58
- 'Role granting permissions to view Omaha reports.'
59
- role 'Omaha reports manager',
60
- [:view_omaha_reports, :destroy_omaha_reports, :upload_omaha_reports],
61
- 'Role granting permissions to manage Omaha reports.'
62
-
63
- # add menu entry
64
- menu :top_menu, :omaha_reports,
65
- :url_hash => { controller: :omaha_reports, action: :index },
66
- :caption => N_('Omaha Reports'),
67
- :parent => :monitor_menu,
68
- :after => :reports
69
-
70
- menu :top_menu, :omaha_hosts,
71
- :url_hash => { :controller => :omaha_hosts, :action => :index },
72
- :caption => N_('Omaha Hosts'),
73
- :parent => :hosts_menu,
74
- :after => :hosts
75
-
76
- divider :top_menu, :caption => N_('Omaha'), :parent => :configure_menu, :last => true
77
-
78
- menu :top_menu, :omaha_groups,
79
- :url_hash => { :controller => :omaha_groups, :action => :index },
80
- :caption => N_('Omaha Groups'),
81
- :parent => :configure_menu,
82
- :last => :true
83
-
84
- # Omaha Facet
85
- register_facet(ForemanOmaha::OmahaFacet, :omaha_facet) do
86
- api_view :list => 'foreman_omaha/api/v2/omaha_facets/base_with_root', :single => 'foreman_omaha/api/v2/omaha_facets/show'
87
- end
88
-
89
- # extend host show page
90
- extend_page('hosts/show') do |context|
91
- context.add_pagelet :main_tabs,
92
- :name => N_('Omaha'),
93
- :partial => 'hosts/omaha_tab',
94
- :onlyif => proc { |host| host.omaha_facet }
95
- end
96
-
97
- add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:omaha_facet) }
98
-
99
- # add renderer extensions
100
- extend_template_helpers ForemanOmaha::TemplateRendererHelper
101
- allowed_template_helpers :transpile_container_linux_config
102
-
103
- register_graphql_query_field :omaha_group, 'ForemanOmaha::Types::OmahaGroup', :record_field
104
- register_graphql_query_field :omaha_groups, 'ForemanOmaha::Types::OmahaGroup', :collection_field
105
-
106
- register_graphql_query_field :omaha_report, 'ForemanOmaha::Types::OmahaReport', :record_field
107
- register_graphql_query_field :omaha_reports, 'ForemanOmaha::Types::OmahaReport', :collection_field
111
+ # Extend built in permissions
112
+ Foreman::AccessControl.permission(:view_hosts).actions.concat [
113
+ 'omaha_hosts/index',
114
+ 'omaha_hosts/auto_complete_search'
115
+ ]
108
116
  end
109
-
110
- # Extend built in permissions
111
- Foreman::AccessControl.permission(:view_hosts).actions.concat [
112
- 'omaha_hosts/index',
113
- 'omaha_hosts/auto_complete_search'
114
- ]
115
117
  end
116
118
 
117
119
  # Include concerns in this config.to_prepare block
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanOmaha
4
- VERSION = '5.0.1'
4
+ VERSION = '5.1.0'
5
5
  end
@@ -23,7 +23,7 @@ namespace :test do
23
23
  end
24
24
 
25
25
  namespace :foreman_omaha do
26
- task :rubocop do
26
+ task rubocop: :environment do
27
27
  begin
28
28
  require 'rubocop/rake_task'
29
29
  RuboCop::RakeTask.new(:rubocop_foreman_omaha) do |task|
@@ -4,7 +4,7 @@ require 'test_plugin_helper'
4
4
 
5
5
  class OmahaStatusTest < ActiveSupport::TestCase
6
6
  let(:host) { FactoryBot.build_stubbed(:host, :with_omaha_facet) }
7
- let(:status) { HostStatus::OmahaStatus.new }
7
+ let(:status) { ForemanOmaha::OmahaStatus.new }
8
8
 
9
9
  setup do
10
10
  User.current = FactoryBot.create(:user, :admin)
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_plugin_helper'
4
+
5
+ class OmahaGroupTest < ActiveSupport::TestCase
6
+ setup do
7
+ User.current = FactoryBot.create(:user, :admin)
8
+ end
9
+
10
+ let(:omaha_group) { FactoryBot.create(:omaha_group, :uuid => 'stable', :name => 'Stable') }
11
+ let(:releases) { ['1520.5.0', '1520.6.0', '1465.8.0'].map { |release| Gem::Version.new(release) } }
12
+ let(:operatingsystems) do
13
+ releases.map do |semver|
14
+ FactoryBot.create(
15
+ :coreos,
16
+ :with_associations,
17
+ :major => semver.segments.first,
18
+ :minor => semver.segments.last(2).join('.'),
19
+ :release_name => 'stable',
20
+ :title => "CoreOS #{semver}"
21
+ )
22
+ end
23
+ end
24
+
25
+ context 'with operatingsystems' do
26
+ setup do
27
+ operatingsystems
28
+ end
29
+
30
+ test 'return latest operating system' do
31
+ latest_operatingsystem = omaha_group.latest_operatingsystem
32
+
33
+ assert_equal '1520', latest_operatingsystem.major
34
+ assert_equal '6.0', latest_operatingsystem.minor
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_omaha
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-05-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: jquery-matchheight-rails
@@ -39,61 +38,19 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  - !ruby/object:Gem::Dependency
42
- name: rubocop
41
+ name: theforeman-rubocop
43
42
  requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 0.80.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 0.80.0
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop-minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.7.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
43
  requirements:
66
44
  - - "~>"
67
45
  - !ruby/object:Gem::Version
68
- version: 0.7.0
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-performance
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.5.2
46
+ version: 0.1.2
76
47
  type: :development
77
48
  prerelease: false
78
49
  version_requirements: !ruby/object:Gem::Requirement
79
50
  requirements:
80
51
  - - "~>"
81
52
  - !ruby/object:Gem::Version
82
- version: 1.5.2
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 2.4.2
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 2.4.2
53
+ version: 0.1.2
97
54
  description: This plug-in adds support for the Omaha procotol to The Foreman. It allows
98
55
  you to better manage and update your CoreOS servers.
99
56
  email:
@@ -128,7 +85,7 @@ files:
128
85
  - app/models/foreman_omaha/omaha_facet.rb
129
86
  - app/models/foreman_omaha/omaha_group.rb
130
87
  - app/models/foreman_omaha/omaha_report.rb
131
- - app/models/host_status/omaha_status.rb
88
+ - app/models/foreman_omaha/omaha_status.rb
132
89
  - app/services/foreman_omaha/charts/oem_distribution.rb
133
90
  - app/services/foreman_omaha/charts/status_distribution.rb
134
91
  - app/services/foreman_omaha/charts/version_distribution.rb
@@ -198,13 +155,13 @@ files:
198
155
  - test/unit/host_status/omaha_status_test.rb
199
156
  - test/unit/host_test.rb
200
157
  - test/unit/omaha_fact_parser_test.rb
158
+ - test/unit/omaha_group_test.rb
201
159
  - test/unit/omaha_report_test.rb
202
160
  - test/unit/renderer_test.rb
203
161
  homepage: http://github.com/theforeman/foreman_omaha
204
162
  licenses:
205
163
  - GPL-3
206
164
  metadata: {}
207
- post_install_message:
208
165
  rdoc_options: []
209
166
  require_paths:
210
167
  - lib
@@ -212,15 +169,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
212
169
  requirements:
213
170
  - - ">="
214
171
  - !ruby/object:Gem::Version
215
- version: '0'
172
+ version: '3.0'
216
173
  required_rubygems_version: !ruby/object:Gem::Requirement
217
174
  requirements:
218
175
  - - ">="
219
176
  - !ruby/object:Gem::Version
220
177
  version: '0'
221
178
  requirements: []
222
- rubygems_version: 3.3.3
223
- signing_key:
179
+ rubygems_version: 4.0.16
224
180
  specification_version: 4
225
181
  summary: This plug-in adds support for the Omaha procotol to The Foreman.
226
182
  test_files:
@@ -246,5 +202,6 @@ test_files:
246
202
  - test/unit/host_status/omaha_status_test.rb
247
203
  - test/unit/host_test.rb
248
204
  - test/unit/omaha_fact_parser_test.rb
205
+ - test/unit/omaha_group_test.rb
249
206
  - test/unit/omaha_report_test.rb
250
207
  - test/unit/renderer_test.rb