foreman_host_extra_validator 0.1.0 → 0.2.1

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: 1d036c7bd2e21429b39a6167f5f978c1af7b38a0f36d59fdd2837ab4a6811960
4
- data.tar.gz: 5c5c8dbc081a24a6f37fae3a81c15f6243e4188e143139c79731a5fef097e651
3
+ metadata.gz: 8f63f5ef9b4443c4a4fa5de029faf95a398b04de7872698dc031ca4ce92c6763
4
+ data.tar.gz: 6586b166074731b6178d7b80eecc8f4284319e0233db05c29eb5e91498afe723
5
5
  SHA512:
6
- metadata.gz: 274523920b8f3a7f6adcfaa5c17621a40cbcb10033c15f3abcd368a462e575ad49defd87c3dbe5dbd6dfa29d97cf02e36a8c8baf050cfab53c05c4eba0c6128a
7
- data.tar.gz: 48f52bb0e608d559c6478051a6ee2e17557aaf9729eab1c07c7bd1ad431bf47e2cae9e027cae3070b35f1c474c597184a604c12e5f6f05a4f1781f8e36aead79
6
+ metadata.gz: 289de1db84110f537572bb1b0dc9dc1cc156d6d61d7bccf20af34ed73d81261b3880fd528012bdb146822bbb8e205644b30048e2432eba19d60ae7380ede931e
7
+ data.tar.gz: 408256808741d275497f67c73f8ea9e97522fe35617954996769a845e20c05e18d4c2044f98970f7eaa0e1762e826a3f287852c9631850b31c484911a24d4052
@@ -0,0 +1,5 @@
1
+ class FixExtraValidationSettingsCategoryToDsl < ActiveRecord::Migration[6.0]
2
+ def up
3
+ Setting.where(category: 'Setting::ForemanHostExtraValidator').update_all(category: 'Setting')
4
+ end
5
+ end
@@ -4,26 +4,33 @@ module ForemanHostExtraValidator
4
4
 
5
5
  config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
6
6
 
7
- initializer 'foreman_host_extra_validator.load_default_settings', :before => :load_config_initializers do |_app|
8
- require_dependency File.expand_path('../../app/models/setting/foreman_host_extra_validator.rb', __dir__) if begin
9
- Setting.table_exists?
10
- rescue
11
- (false)
12
- end
7
+ # Add any db migrations
8
+ initializer 'foreman_host_extra_validator.load_app_instance_data' do |app|
9
+ ForemanHostExtraValidator::Engine.paths['db/migrate'].existent.each do |path|
10
+ app.config.paths['db/migrate'] << path
11
+ end
13
12
  end
14
13
 
15
14
  initializer 'foreman_host_extra_validator.register_plugin', :before => :finisher_hook do |_app|
16
15
  Foreman::Plugin.register :foreman_host_extra_validator do
17
- requires_foreman '>= 1.18'
16
+ requires_foreman '>= 3.0.0'
17
+
18
+ settings do
19
+ category(:host_extra_validator, N_('Host Extra Validator')) do
20
+ setting('host_name_validation_regex',
21
+ description: N_('Default regex the name of a host is validated against'),
22
+ type: :string,
23
+ default: '^[a-zA-Z0-9\-_]+$',
24
+ full_name: N_('Regular expresssion'))
25
+ end
26
+ end
18
27
  end
19
28
  end
20
29
 
21
30
  config.to_prepare do
22
- begin
23
- Host::Managed.send(:include, ForemanHostExtraValidator::HostExtensions)
24
- rescue => e
25
- Rails.logger.warn "ForemanHostExtraValidator: skipping engine hook (#{e})\n#{e.backtrace}"
26
- end
31
+ Host::Managed.include ForemanHostExtraValidator::HostExtensions
32
+ rescue => e
33
+ Rails.logger.warn "ForemanHostExtraValidator: skipping engine hook (#{e})\n#{e.backtrace}"
27
34
  end
28
35
 
29
36
  initializer 'foreman_host_extra_validator.register_gettext', after: :load_config_initializers do |_app|
@@ -1,3 +1,3 @@
1
1
  module ForemanHostExtraValidator
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -2,7 +2,6 @@ require 'test_plugin_helper'
2
2
 
3
3
  class ForemanHostExtraValidatorTest < ActiveSupport::TestCase
4
4
  setup do
5
- Setting::ForemanHostExtraValidator.load_defaults
6
5
  disable_orchestration
7
6
  User.current = FactoryBot.build(:user, :admin)
8
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_host_extra_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-02 00:00:00.000000000 Z
11
+ date: 2022-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -49,7 +49,7 @@ files:
49
49
  - README.md
50
50
  - Rakefile
51
51
  - app/models/concerns/foreman_host_extra_validator/host_extensions.rb
52
- - app/models/setting/foreman_host_extra_validator.rb
52
+ - db/migrate/20220923181701_fix_extra_validation_settings_category_to_dsl.rb
53
53
  - lib/foreman_host_extra_validator.rb
54
54
  - lib/foreman_host_extra_validator/engine.rb
55
55
  - lib/foreman_host_extra_validator/version.rb
@@ -65,7 +65,7 @@ homepage: https://github.com/theforeman/foreman_host_extra_validator
65
65
  licenses:
66
66
  - GPL-3.0
67
67
  metadata: {}
68
- post_install_message:
68
+ post_install_message:
69
69
  rdoc_options: []
70
70
  require_paths:
71
71
  - lib
@@ -80,11 +80,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
- rubyforge_project:
84
- rubygems_version: 2.7.3
85
- signing_key:
83
+ rubygems_version: 3.3.7
84
+ signing_key:
86
85
  specification_version: 4
87
86
  summary: This plugin adds extra validations to a host.
88
87
  test_files:
89
- - test/unit/foreman_host_extra_validator_test.rb
90
88
  - test/test_plugin_helper.rb
89
+ - test/unit/foreman_host_extra_validator_test.rb
@@ -1,16 +0,0 @@
1
- class Setting
2
- class ForemanHostExtraValidator < ::Setting
3
- def self.load_defaults
4
- # Check the table exists
5
- return unless super
6
-
7
- self.transaction do
8
- [
9
- self.set('host_name_validation_regex', _('Default regex the name of a host is validated against'), '^[a-zA-Z0-9\-_]+$')
10
- ].compact.each { |s| self.create! s.update(:category => 'Setting::ForemanHostExtraValidator') }
11
- end
12
-
13
- true
14
- end
15
- end
16
- end