foreman_omaha 4.0.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63dabb188c95da7706f66c9c5c768225966e51448ce7a40ad2fc1c89871a30ad
4
- data.tar.gz: 972b61c7759fc488935792d55bf08aa7fa02a01e91ed14ed6a1d711ee4f51df2
3
+ metadata.gz: c0ee3bbe2a41f9d5ac5ffac14c72895f5f523ba58691cdbd59c21086638d74b7
4
+ data.tar.gz: 6348671022cae92df4f7da03f665514234f325be028c523db136ab3c81244eea
5
5
  SHA512:
6
- metadata.gz: 0bf9bb1350fc0e429917e58b3f5c56cf1e01c44cfdb9a4f641e78fafca08d60b46e20f7abfcc0ad0500c8094b16814ab097811a9a93fb199f1b33c6d3990c068
7
- data.tar.gz: 05d0c8e04d6edb7c71d3b9e9b861862fbfa7d4f41cff0c28147bce8f7a48e4571b4b5f568e69daeb921bb5feeebe050baac4dd9d6cd81877eae9c134ab22ca92
6
+ metadata.gz: b97bae1c564d7745876cae86a16558f986057a63553676e8c55e6199208c810cceeca7f8a588bb637399fc32c485bfac874b61b649dd0e9252752c3226be467c
7
+ data.tar.gz: adae755d7a4e0859663bea2495c2ccce1041a7d05d478ae4eca3ca2d8910a8aff3bdcca925165e6a28101005612a5ffc980e7af2a1a0fe427a884b9f92f98ebd
data/README.md CHANGED
@@ -13,6 +13,7 @@ Foreman core already supports deploying CoreOS hosts and is great for on-premise
13
13
  | >= 1.18 | ~> 2.0 |
14
14
  | >= 1.20 | ~> 3.0 |
15
15
  | >= 1.24 | ~> 4.0 |
16
+ | >= 3.0 | ~> 5.0 |
16
17
 
17
18
  ## Installation
18
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
 
@@ -17,10 +17,10 @@ class OmahaHostsController < ApplicationController
17
17
 
18
18
  def welcome
19
19
  has_entries = begin
20
- resource_base.first.nil?
21
- rescue StandardError
22
- false
23
- end
20
+ resource_base.first.nil?
21
+ rescue StandardError
22
+ false
23
+ end
24
24
  if has_entries
25
25
  @welcome = true
26
26
  render :welcome
@@ -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
@@ -5,6 +5,7 @@ require 'open3'
5
5
  module ForemanOmaha
6
6
  class ContainerLinuxConfigTranspiler
7
7
  class TranspilerNotFound < StandardError; end
8
+
8
9
  class TranspileError < StandardError; end
9
10
 
10
11
  attr_accessor :input, :output, :errors, :status
@@ -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
@@ -11,7 +11,6 @@ module ForemanOmaha
11
11
  config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
12
12
  config.autoload_paths += Dir["#{config.root}/app/services"]
13
13
  config.autoload_paths += Dir["#{config.root}/app/lib"]
14
- config.autoload_paths += Dir["#{config.root}/app/graphql"]
15
14
 
16
15
  # Add any db migrations
17
16
  initializer 'foreman_omaha.load_app_instance_data' do |app|
@@ -22,7 +21,7 @@ module ForemanOmaha
22
21
 
23
22
  initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |_app|
24
23
  Foreman::Plugin.register :foreman_omaha do
25
- requires_foreman '>= 1.24'
24
+ requires_foreman '>= 3.0'
26
25
 
27
26
  apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
28
27
 
@@ -95,7 +94,14 @@ module ForemanOmaha
95
94
  add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:omaha_facet) }
96
95
 
97
96
  # add renderer extensions
97
+ extend_template_helpers ForemanOmaha::TemplateRendererHelper
98
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
99
105
  end
100
106
 
101
107
  # Extend built in permissions
@@ -107,19 +113,20 @@ module ForemanOmaha
107
113
 
108
114
  # Include concerns in this config.to_prepare block
109
115
  config.to_prepare do
110
- begin
111
- ::FactImporter.register_fact_importer(:foreman_omaha, ForemanOmaha::FactImporter)
112
- ::FactParser.register_fact_parser(:foreman_omaha, ForemanOmaha::FactParser)
113
-
114
- ::Host::Managed.include(ForemanOmaha::HostExtensions)
115
- ::Host::Managed.include(ForemanOmaha::OmahaFacetHostExtensions)
116
- ::HostsHelper.include(ForemanOmaha::HostsHelperExtensions)
117
- ::Foreman::Renderer::Scope::Base.include(ForemanOmaha::Renderer::Scope::Macros::Omaha)
118
- ::Types::Query.include(Types::Extensions::ForemanOmaha::QueryExtensions)
119
- ::Types::Host.include(Types::Extensions::ForemanOmaha::HostExtensions)
120
- rescue StandardError => e
121
- 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)
122
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})"
123
130
  end
124
131
 
125
132
  rake_tasks do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanOmaha
4
- VERSION = '4.0.1'
4
+ VERSION = '5.0.0'
5
5
  end
@@ -100,7 +100,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
100
100
 
101
101
  test 'hosts with a registered smart proxy on should create a report successfully' do
102
102
  Setting[:restrict_registered_smart_proxies] = true
103
- Setting[:require_ssl_smart_proxies] = false
103
+ Setting[:require_ssl_smart_proxies] = false if Gem::Version.new(SETTINGS[:version].notag) < Gem::Version.new('3.1')
104
104
 
105
105
  proxy = FactoryBot.create(:smart_proxy, :omaha)
106
106
  host = URI.parse(proxy.url).host
@@ -38,6 +38,11 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
38
38
 
39
39
  context '#operatingsystem' do
40
40
  let(:os) { importer.operatingsystem }
41
+ let(:expected_os_default_templates) do
42
+ OsDefaultTemplate.joins(:provisioning_template)
43
+ .where(operatingsystem: os)
44
+ .where(templates: { name: Setting[:default_host_init_config_template] })
45
+ end
41
46
 
42
47
  context 'without distribution fact' do
43
48
  setup do
@@ -60,7 +65,7 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
60
65
  assert_equal 'stable', os.release_name
61
66
  assert_empty os.ptables
62
67
  assert_empty os.media
63
- assert_empty os.os_default_templates
68
+ assert_same_elements os.os_default_templates, expected_os_default_templates
64
69
  end
65
70
  end
66
71
 
@@ -78,7 +83,7 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
78
83
  assert_equal 'stable', os.release_name
79
84
  assert_empty os.ptables
80
85
  assert_empty os.media
81
- assert_empty os.os_default_templates
86
+ assert_same_elements os.os_default_templates, expected_os_default_templates
82
87
  end
83
88
  end
84
89
 
@@ -88,23 +93,28 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
88
93
  :major => '899',
89
94
  :minor => '17.0',
90
95
  :title => 'CoreOS 899.17.0')
91
- @previous = FactoryBot.create(:coreos,
92
- :with_associations,
93
- :with_provision,
94
- :major => '1010',
95
- :minor => '5.0',
96
- :title => 'CoreOS 1010.5.0')
96
+
97
+ previous.reload
98
+ end
99
+
100
+ let(:previous) do
101
+ FactoryBot.create(:coreos,
102
+ :with_associations,
103
+ :with_provision,
104
+ :major => '1010',
105
+ :minor => '5.0',
106
+ :title => 'CoreOS 1010.5.0')
97
107
  end
98
108
 
99
109
  test 'should copy attributes from previous os version' do
100
110
  assert_equal '1068', os.major
101
111
  assert_equal '9.0', os.minor
102
- assert_equal @previous.ptables, os.ptables
103
- assert_equal @previous.architectures, os.architectures
104
- assert_equal @previous.media, os.media
105
- assert_equal @previous.os_default_templates.map(&:provisioning_template), os.os_default_templates.map(&:provisioning_template)
106
- assert_equal @previous.os_default_templates.map(&:template_kind), os.os_default_templates.map(&:template_kind)
107
- assert_equal @previous.provisioning_templates, os.provisioning_templates
112
+ assert_equal previous.ptables, os.ptables
113
+ assert_equal previous.architectures, os.architectures
114
+ assert_equal previous.media, os.media
115
+ assert_same_elements previous.os_default_templates.map(&:template_kind), os.os_default_templates.map(&:template_kind)
116
+ assert_same_elements previous.os_default_templates.map(&:provisioning_template), os.os_default_templates.map(&:provisioning_template)
117
+ assert_same_elements previous.provisioning_templates, os.provisioning_templates
108
118
  end
109
119
  end
110
120
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_omaha
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2022-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-matchheight-rails
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.80.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.80.0
55
55
  - !ruby/object:Gem::Dependency
@@ -113,17 +113,15 @@ files:
113
113
  - app/controllers/omaha_groups_controller.rb
114
114
  - app/controllers/omaha_hosts_controller.rb
115
115
  - app/controllers/omaha_reports_controller.rb
116
- - app/graphql/types/extensions/foreman_omaha/host_extensions.rb
117
- - app/graphql/types/extensions/foreman_omaha/query_extensions.rb
118
- - app/graphql/types/omaha_group.rb
119
- - app/graphql/types/omaha_report.rb
120
- - app/graphql/types/omaha_report_status_enum.rb
116
+ - app/graphql/concerns/foreman_omaha/types/host_extensions.rb
117
+ - app/graphql/foreman_omaha/types/omaha_group.rb
118
+ - app/graphql/foreman_omaha/types/omaha_report.rb
119
+ - app/graphql/foreman_omaha/types/omaha_report_status_enum.rb
121
120
  - app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb
122
121
  - app/helpers/foreman_omaha/application_helper.rb
123
122
  - app/helpers/foreman_omaha/omaha_groups_helper.rb
124
123
  - app/helpers/omaha_hosts_helper.rb
125
124
  - app/helpers/omaha_reports_helper.rb
126
- - app/lib/foreman_omaha/renderer/scope/macros/omaha.rb
127
125
  - app/models/concerns/foreman_omaha/host_extensions.rb
128
126
  - app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb
129
127
  - app/models/foreman_omaha/fact_name.rb
@@ -140,6 +138,7 @@ files:
140
138
  - app/services/foreman_omaha/group_version_breakdown.rb
141
139
  - app/services/foreman_omaha/omaha_report_importer.rb
142
140
  - app/services/foreman_omaha/status_mapper.rb
141
+ - app/services/foreman_omaha/template_renderer_helper.rb
143
142
  - app/views/api/v2/omaha_groups/base.json.rabl
144
143
  - app/views/api/v2/omaha_groups/index.json.rabl
145
144
  - app/views/api/v2/omaha_groups/main.json.rabl
@@ -220,8 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
219
  - !ruby/object:Gem::Version
221
220
  version: '0'
222
221
  requirements: []
223
- rubyforge_project:
224
- rubygems_version: 2.7.6.2
222
+ rubygems_version: 3.1.6
225
223
  signing_key:
226
224
  specification_version: 4
227
225
  summary: This plug-in adds support for the Omaha procotol to The Foreman.
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Types
4
- module Extensions
5
- module ForemanOmaha
6
- module HostExtensions
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- has_many :omaha_reports, Types::OmahaReport
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Types
4
- module Extensions
5
- module ForemanOmaha
6
- module QueryExtensions
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- record_field :omaha_group, Types::OmahaGroup
11
- collection_field :omaha_groups, Types::OmahaGroup
12
-
13
- record_field :omaha_report, Types::OmahaReport
14
- collection_field :omaha_reports, Types::OmahaReport
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Types
4
- class OmahaGroup < BaseObject
5
- model_class ::ForemanOmaha::OmahaGroup
6
- description 'An Omaha Group'
7
-
8
- global_id_field :id
9
- timestamps
10
- field :name, String
11
- field :uuid, String
12
-
13
- has_many :hosts, Types::Host
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Types
4
- class OmahaReport < BaseObject
5
- model_class ::ForemanOmaha::OmahaReport
6
- description 'An Omaha Report'
7
-
8
- global_id_field :id
9
- timestamps
10
- field :status, Types::OmahaReportStatusEnum
11
- field :omaha_version, String
12
-
13
- belongs_to :host, Types::Host
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Types
4
- class OmahaReportStatusEnum < BaseEnum
5
- ForemanOmaha::OmahaFacet::VALID_OMAHA_STATUSES.each do |status|
6
- value status
7
- end
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ForemanOmaha
4
- module Renderer
5
- module Scope
6
- module Macros
7
- module Omaha
8
- def transpile_container_linux_config(input)
9
- ForemanOmaha::ContainerLinuxConfigTranspiler.new(input).run!
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end