foreman_puppet 6.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/app/models/concerns/foreman_puppet/extensions/host.rb +0 -7
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +21 -5
- data/app/models/foreman_puppet/config_group.rb +1 -1
- data/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb +6 -1
- data/lib/foreman_puppet/version.rb +1 -1
- data/package.json +0 -3
- data/test/models/foreman_puppet/host_test.rb +13 -5
- data/webpack/src/foreman_puppet_host_form.js +3 -0
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68939e16cae1564207cb39add5c7fec7cac4e94c8ebf118dc61621197907a745
|
4
|
+
data.tar.gz: 5058a3df645b3c30aa9d0845b47c7a07286fa1c87aa261b582a6153e1533965b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d03b3cf704fb1c44d598f2cdd07f0eb4a42bcbd5f588083b8c47ae8ac91f3c60ed809104321f4942f2adfa4601126883dc973cb9181bcd469136f94c1ccdc748
|
7
|
+
data.tar.gz: 10dceada6b636553d2b29ca4e7e76965e6235ba3227765e0a71ea1144d86d09e332ae2aab22c22d3554f81cef933c50a8d2979d818234ff261588b3cdd8736cd
|
data/README.md
CHANGED
@@ -33,7 +33,8 @@ Some features will remain in core:
|
|
33
33
|
|
34
34
|
|Foreman version|Plugin version|Notes |
|
35
35
|
|---------------|--------------|------------------------------------------|
|
36
|
-
| >= 3.
|
36
|
+
| >= 3.7 | ~> 6.0 | Required |
|
37
|
+
| ~> 3.5, 3.6 | ~> 5.0 | Required |
|
37
38
|
| ~> 3.4 | ~> 4.1 | Required |
|
38
39
|
| ~> 3.3 | ~> 4.0 | Required |
|
39
40
|
| ~> 3.2 | ~> 3.0 | Required |
|
@@ -51,7 +52,7 @@ You can manually install this plugin using:
|
|
51
52
|
|
52
53
|
```sh
|
53
54
|
# On RedHat/CentOS
|
54
|
-
|
55
|
+
dnf install rubygem-foreman_puppet
|
55
56
|
|
56
57
|
# On Debian
|
57
58
|
apt install ruby-foreman-puppet
|
@@ -77,7 +78,7 @@ Fork and send a Pull Request. Thanks!
|
|
77
78
|
|
78
79
|
## Copyright
|
79
80
|
|
80
|
-
Copyright (c) *
|
81
|
+
Copyright (c) *2020-2023* *The Foreman developers*
|
81
82
|
|
82
83
|
This program is free software: you can redistribute it and/or modify
|
83
84
|
it under the terms of the GNU General Public License as published by
|
@@ -13,8 +13,6 @@ module ForemanPuppet
|
|
13
13
|
include_in_clone puppet: %i[config_groups host_config_groups host_classes]
|
14
14
|
|
15
15
|
scoped_search relation: :environment, on: :name, complete_value: true, rename: :environment
|
16
|
-
scoped_search relation: :puppetclasses, on: :name, complete_value: true, rename: :class, only_explicit: true, operators: ['= ', '~ '],
|
17
|
-
ext_method: :search_by_deprecated_class
|
18
16
|
scoped_search relation: :puppetclasses, on: :name, complete_value: true, rename: :puppetclass, only_explicit: true, operators: ['= ', '~ '],
|
19
17
|
ext_method: :search_by_puppetclass
|
20
18
|
scoped_search relation: :config_groups, on: :name, complete_value: true, rename: :config_group, only_explicit: true, operators: ['= ', '~ '],
|
@@ -22,11 +20,6 @@ module ForemanPuppet
|
|
22
20
|
end
|
23
21
|
|
24
22
|
class_methods do
|
25
|
-
def search_by_deprecated_class(key, operator, value)
|
26
|
-
Foreman::Deprecation.deprecation_warning('3.2', 'search by `class` has been deprecated, please search by `puppetclass` instead')
|
27
|
-
search_by_puppetclass(key, operator, value)
|
28
|
-
end
|
29
|
-
|
30
23
|
def search_by_puppetclass(_key, operator, value)
|
31
24
|
conditions = sanitize_sql_for_conditions(["puppetclasses.name #{operator} ?", value_to_sql(operator, value)])
|
32
25
|
config_group_ids = ForemanPuppet::ConfigGroup.joins(:puppetclasses).where(conditions).pluck(:id)
|
@@ -16,7 +16,12 @@ module ForemanPuppet
|
|
16
16
|
|
17
17
|
# will need through relation to work properly
|
18
18
|
scoped_search relation: :environment, on: :name, complete_value: true, rename: :environment, only_explicit: true
|
19
|
-
scoped_search relation: :puppetclasses, on: :name,
|
19
|
+
scoped_search relation: :puppetclasses, on: :name,
|
20
|
+
complete_value: true,
|
21
|
+
rename: :puppetclass,
|
22
|
+
only_explicit: true,
|
23
|
+
operators: ['= ', '~ '],
|
24
|
+
ext_method: :search_by_puppetclass
|
20
25
|
scoped_search relation: :config_groups, on: :name,
|
21
26
|
complete_value: true,
|
22
27
|
rename: :config_group,
|
@@ -29,11 +34,22 @@ module ForemanPuppet
|
|
29
34
|
module PatchedClassMethods
|
30
35
|
def search_by_config_group(_key, operator, value)
|
31
36
|
conditions = sanitize_sql_for_conditions(["config_groups.name #{operator} ?", value_to_sql(operator, value)])
|
32
|
-
hostgroup_ids = ::Hostgroup.
|
37
|
+
hostgroup_ids = ::Hostgroup.joins(puppet: :config_groups).where(conditions).map(&:subtree_ids).flatten.uniq
|
38
|
+
|
39
|
+
conds = 'hostgroups.id < 0'
|
40
|
+
conds = "hostgroups.id IN(#{hostgroup_ids.join(',')})" if hostgroup_ids.present?
|
41
|
+
|
42
|
+
{ conditions: conds }
|
43
|
+
end
|
44
|
+
|
45
|
+
def search_by_puppetclass(_key, operator, value)
|
46
|
+
conditions = sanitize_sql_for_conditions(["puppetclasses.name #{operator} ?", value_to_sql(operator, value)])
|
47
|
+
hostgroup_ids = ::Hostgroup.joins(puppet: :puppetclasses).where(conditions).map(&:subtree_ids)
|
48
|
+
|
49
|
+
conds = []
|
50
|
+
conds << "hostgroups.id IN (#{hostgroup_ids.join(',')})" if hostgroup_ids.present?
|
33
51
|
|
34
|
-
|
35
|
-
opts = "hostgroups.id IN(#{hostgroup_ids.join(',')})" if hostgroup_ids.present?
|
36
|
-
{ conditions: opts }
|
52
|
+
{ conditions: conds.join(' OR ').presence || 'hostgroups.id < 0' }
|
37
53
|
end
|
38
54
|
end
|
39
55
|
end
|
@@ -17,7 +17,7 @@ module ForemanPuppet
|
|
17
17
|
validates :name, presence: true, uniqueness: true
|
18
18
|
|
19
19
|
scoped_search on: :name, complete_value: true
|
20
|
-
scoped_search relation: :puppetclasses, on: :name, complete_value: true, rename: :
|
20
|
+
scoped_search relation: :puppetclasses, on: :name, complete_value: true, rename: :puppetclass, only_explicit: true, operators: ['= ', '~ ']
|
21
21
|
|
22
22
|
default_scope -> { order('config_groups.name') }
|
23
23
|
|
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
<%
|
2
|
+
id = "selected_puppetclass_#{klass.id}"
|
3
|
+
css = [dom_class(klass, 'selected'), cycle('even', 'odd')]
|
4
|
+
css << 'unavailable' unless klass.environments.include?(obj.try(:environment).presence || @environment)
|
5
|
+
%>
|
6
|
+
<%= content_tag :li, id: id, class: css do %>
|
2
7
|
<%= link_to_remove_puppetclass(klass, obj) %>
|
3
8
|
<%= hidden_field_tag "#{resource_type}[puppetclass_ids][]", klass.id %>
|
4
9
|
<% end %>
|
data/package.json
CHANGED
@@ -9,8 +9,6 @@
|
|
9
9
|
"test:watch": "tfm-test --plugin --watchAll",
|
10
10
|
"test:current": "tfm-test --plugin --watch",
|
11
11
|
"publish-coverage": "tfm-publish-coverage",
|
12
|
-
"stories": "tfm-stories --plugin",
|
13
|
-
"stories:build": "tfm-build-stories --plugin",
|
14
12
|
"create-react-component": "yo react-domain"
|
15
13
|
},
|
16
14
|
"repository": {
|
@@ -29,7 +27,6 @@
|
|
29
27
|
"@theforeman/builder": ">= 10.1.0",
|
30
28
|
"@theforeman/eslint-plugin-foreman": ">= 10.1.0",
|
31
29
|
"@theforeman/find-foreman": ">= 10.1.0",
|
32
|
-
"@theforeman/stories": ">= 10.1.0",
|
33
30
|
"@theforeman/test": ">= 10.1.0",
|
34
31
|
"@theforeman/vendor-dev": ">= 10.1.0",
|
35
32
|
"babel-eslint": "^10.0.3",
|
@@ -48,23 +48,31 @@ module ForemanPuppet
|
|
48
48
|
assert_equal results, results2
|
49
49
|
end
|
50
50
|
|
51
|
+
test 'deprecated search by class throws error' do
|
52
|
+
exception = assert_raises(Exception) do
|
53
|
+
host
|
54
|
+
Host.search_for("class = #{host.puppet.puppetclass_names.first}")
|
55
|
+
end
|
56
|
+
assert_equal("Field 'class' not recognized for searching!", exception.message)
|
57
|
+
end
|
58
|
+
|
51
59
|
test 'can be found by puppetclass' do
|
52
60
|
host
|
53
|
-
result = Host.search_for("
|
61
|
+
result = Host.search_for("puppetclass = #{host.puppet.puppetclass_names.first}")
|
54
62
|
assert_includes result, host
|
55
63
|
end
|
56
64
|
|
57
65
|
test 'search by puppetclass returns only host within that puppetclass' do
|
58
66
|
host
|
59
67
|
puppetclass = FactoryBot.create(:puppetclass)
|
60
|
-
result = Host.search_for("
|
68
|
+
result = Host.search_for("puppetclass = #{puppetclass.name}")
|
61
69
|
assert_not_includes result, host
|
62
70
|
end
|
63
71
|
|
64
72
|
test 'search hosts by inherited puppetclass from a hostgroup' do
|
65
73
|
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass)
|
66
74
|
host_with_hg = FactoryBot.create(:host, hostgroup: hostgroup)
|
67
|
-
result = Host.search_for("
|
75
|
+
result = Host.search_for("puppetclass = #{hostgroup.puppet.puppetclass_names.first}")
|
68
76
|
assert_includes result, host_with_hg
|
69
77
|
end
|
70
78
|
|
@@ -72,7 +80,7 @@ module ForemanPuppet
|
|
72
80
|
parent_hg = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass)
|
73
81
|
hg = FactoryBot.create(:hostgroup, parent: parent_hg)
|
74
82
|
host = FactoryBot.create(:host, hostgroup: hg)
|
75
|
-
result = Host.search_for("
|
83
|
+
result = Host.search_for("puppetclass = #{parent_hg.puppet.puppetclass_names.first}")
|
76
84
|
assert_equal 1, result.count
|
77
85
|
assert_includes result, host
|
78
86
|
end
|
@@ -82,7 +90,7 @@ module ForemanPuppet
|
|
82
90
|
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
83
91
|
config_group = FactoryBot.create(:config_group, :with_puppetclass)
|
84
92
|
hostgroup.puppet.config_groups << config_group
|
85
|
-
result = Host.search_for("
|
93
|
+
result = Host.search_for("puppetclass = #{config_group.puppetclass_names.first}")
|
86
94
|
assert_equal 1, result.count
|
87
95
|
assert_includes result, host
|
88
96
|
end
|
@@ -82,6 +82,9 @@ export function updatePuppetclasses(element) {
|
|
82
82
|
export function reloadPuppetclassParams() {
|
83
83
|
const hostId = $('form.hostresource-form').data('id');
|
84
84
|
const url = $('#puppet_klasses_parameters').data('url');
|
85
|
+
if (!url) {
|
86
|
+
return;
|
87
|
+
}
|
85
88
|
let data = window.serializeForm().replace('method=patch', 'method=post');
|
86
89
|
if (url.match('hostgroups')) {
|
87
90
|
data += `&hostgroup_id=${hostId}`;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Allow assigning Puppet environments and classes to the Foreman Hosts.
|
15
15
|
email:
|
@@ -436,76 +436,76 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
436
436
|
- !ruby/object:Gem::Version
|
437
437
|
version: '0'
|
438
438
|
requirements: []
|
439
|
-
rubygems_version: 3.
|
439
|
+
rubygems_version: 3.1.6
|
440
440
|
signing_key:
|
441
441
|
specification_version: 4
|
442
442
|
summary: Add Puppet features to Foreman
|
443
443
|
test_files:
|
444
444
|
- test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb
|
445
|
-
- test/controllers/foreman_puppet/api/v2/environments_controller_test.rb
|
446
445
|
- test/controllers/foreman_puppet/api/v2/host_classes_controller_test.rb
|
447
446
|
- test/controllers/foreman_puppet/api/v2/hostgroup_classes_controller_test.rb
|
448
447
|
- test/controllers/foreman_puppet/api/v2/hostgroups_controller_test.rb
|
449
|
-
- test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb
|
450
448
|
- test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb
|
451
|
-
- test/controllers/foreman_puppet/api/v2/override_values_controller_test.rb
|
452
449
|
- test/controllers/foreman_puppet/api/v2/provisioning_templates_controller_test.rb
|
453
450
|
- test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb
|
454
|
-
- test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb
|
455
451
|
- test/controllers/foreman_puppet/api/v2/smart_proxies_controller_test.rb
|
456
452
|
- test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb
|
453
|
+
- test/controllers/foreman_puppet/api/v2/environments_controller_test.rb
|
454
|
+
- test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb
|
455
|
+
- test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb
|
456
|
+
- test/controllers/foreman_puppet/api/v2/override_values_controller_test.rb
|
457
457
|
- test/controllers/foreman_puppet/config_groups_controller_test.rb
|
458
|
-
- test/controllers/foreman_puppet/environments_controller_test.rb
|
459
458
|
- test/controllers/foreman_puppet/hostgroups_controller_test.rb
|
460
|
-
- test/controllers/foreman_puppet/hosts_controller_test.rb
|
461
459
|
- test/controllers/foreman_puppet/puppet_smart_proxies_controller_test.rb
|
462
460
|
- test/controllers/foreman_puppet/puppetclass_lookup_keys_controller_test.rb
|
463
461
|
- test/controllers/foreman_puppet/puppetclasses_controller_test.rb
|
462
|
+
- test/controllers/foreman_puppet/environments_controller_test.rb
|
463
|
+
- test/controllers/foreman_puppet/hosts_controller_test.rb
|
464
464
|
- test/controllers/provisioning_templates_controller_test.rb
|
465
465
|
- test/factories/foreman_puppet_factories.rb
|
466
466
|
- test/factories/host_puppet_enhancements.rb
|
467
467
|
- test/factories/proxy_puppet_enhancements.rb
|
468
468
|
- test/graphql/mutations/hosts/create_mutation_test.rb
|
469
|
-
- test/graphql/queries/environment_query_test.rb
|
470
469
|
- test/graphql/queries/environments_query_test.rb
|
471
470
|
- test/graphql/queries/host_puppet_query_test.rb
|
472
471
|
- test/graphql/queries/hostgroup_puppet_query_test.rb
|
473
472
|
- test/graphql/queries/location_query_test.rb
|
474
473
|
- test/graphql/queries/organization_query_test.rb
|
475
|
-
- test/graphql/queries/puppetclass_query_test.rb
|
476
474
|
- test/graphql/queries/puppetclasses_query_test.rb
|
475
|
+
- test/graphql/queries/environment_query_test.rb
|
476
|
+
- test/graphql/queries/puppetclass_query_test.rb
|
477
477
|
- test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb
|
478
|
-
- test/helpers/foreman_puppet/puppetclass_lookup_keys_helper_test.rb
|
479
478
|
- test/helpers/foreman_puppet/puppetclasses_helper_test.rb
|
479
|
+
- test/helpers/foreman_puppet/puppetclass_lookup_keys_helper_test.rb
|
480
480
|
- test/integration/foreman_puppet/dashboard_js_test.rb
|
481
481
|
- test/integration/foreman_puppet/environment_js_test.rb
|
482
|
-
- test/integration/foreman_puppet/host_js_test.rb
|
483
482
|
- test/integration/foreman_puppet/hostgroup_js_test.rb
|
484
483
|
- test/integration/foreman_puppet/puppetclass_js_test.rb
|
485
484
|
- test/integration/foreman_puppet/smartclass_parameter_js_test.rb
|
486
|
-
- test/
|
485
|
+
- test/integration/foreman_puppet/host_js_test.rb
|
487
486
|
- test/models/foreman_puppet/config_group_class_test.rb
|
488
487
|
- test/models/foreman_puppet/config_group_test.rb
|
489
488
|
- test/models/foreman_puppet/environment_test.rb
|
490
489
|
- test/models/foreman_puppet/host_config_group_test.rb
|
491
|
-
- test/models/foreman_puppet/host_puppet_facet_test.rb
|
492
|
-
- test/models/foreman_puppet/host_test.rb
|
493
490
|
- test/models/foreman_puppet/hostgroup_puppet_facet_test.rb
|
494
491
|
- test/models/foreman_puppet/hostgroup_test.rb
|
495
492
|
- test/models/foreman_puppet/lookup_value_test.rb
|
496
|
-
- test/models/foreman_puppet/provisioning_template_test.rb
|
497
493
|
- test/models/foreman_puppet/puppetclass_lookup_key_test.rb
|
498
|
-
- test/models/foreman_puppet/puppetclass_test.rb
|
499
494
|
- test/models/foreman_puppet/report_test.rb
|
500
495
|
- test/models/foreman_puppet/smart_proxy_test.rb
|
501
496
|
- test/models/foreman_puppet/user_test.rb
|
502
|
-
- test/
|
497
|
+
- test/models/foreman_puppet/provisioning_template_test.rb
|
498
|
+
- test/models/foreman_puppet/puppetclass_test.rb
|
499
|
+
- test/models/foreman_puppet/host_puppet_facet_test.rb
|
500
|
+
- test/models/foreman_puppet/host_test.rb
|
503
501
|
- test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb
|
504
502
|
- test/services/foreman_puppet/host_info_providers/puppet_info_test.rb
|
505
503
|
- test/services/foreman_puppet/input_type/puppet_parameter_input_test.rb
|
506
|
-
- test/
|
504
|
+
- test/services/foreman_puppet/host_counter_test.rb
|
507
505
|
- test/unit/foreman_puppet/access_permissions_test.rb
|
508
|
-
- test/unit/foreman_puppet/global_id_test.rb
|
509
506
|
- test/unit/foreman_puppet/puppet_class_importer_test.rb
|
510
507
|
- test/unit/foreman_puppet/template_rendering_test.rb
|
508
|
+
- test/unit/foreman_puppet/global_id_test.rb
|
511
509
|
- test/unit/foreman_puppet_test.rb
|
510
|
+
- test/test_puppet_helper.rb
|
511
|
+
- test/integration_puppet_helper.rb
|