foreman_puppet 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6a528bcec7516d10a4b94f455b9ba0eae4ce8ce978d4a242e504d1b73e430b
4
- data.tar.gz: 44593d006e0f911a1c43f75ee23cfd949b38ff4766e7cd43c291c528c20a0a97
3
+ metadata.gz: 83861f53b9f2944dda945591b245097569b4477df77ed2760f42cb1d92bd3ed0
4
+ data.tar.gz: 620b8fb7524015970cd4aa1e42ea130483434ccb0af7474a1a4ca23ca8d8199f
5
5
  SHA512:
6
- metadata.gz: 6ee6bee3076a1550b35427f9df89361d5d0bf96e205916999f2f0631e69c1d22d2b2afa31d0d511a43b6f3ea8f68ec0a62dda08ff84c35451de9f36cbcf87059
7
- data.tar.gz: fa627b81d596bfe7501a335546cf16fcf66c95f7dbd3f3c807bf4c1b99cb8cc3ba3a4688729f2f9a4e2bf2e0b66f749fdba065362e5673f3f940e44bfdb6c403
6
+ metadata.gz: 9ac189449b5b6f819e82ee4f14dbccfdf0da012dd0a8345441225b76f062912a9b3f184bc7f2c87715dd5e460d1deadc6943f45e060a4bf109d8d3ba87ce8bc7
7
+ data.tar.gz: 13157df73faa3eb07f8e1299ad9367bd09d6292e45ff59741d2c6e108542bb239ad25ba04eb8fae97125b54cba6f452248c91b9bddffda1c0829b2e8953fdb57
@@ -9,7 +9,7 @@ module ForemanPuppet
9
9
  # ------ Host(group) Form Helpers -----
10
10
 
11
11
  def overridable_puppet_lookup_keys(klass, obj)
12
- klass.class_params.override.where(environment_classes: { environment_id: obj.environment_id })
12
+ klass.class_params.override.where(environment_classes: { environment_id: obj.environment })
13
13
  end
14
14
 
15
15
  def hidden_puppet_lookup_value_fields(lookup_key, lookup_value, disabled)
@@ -0,0 +1,9 @@
1
+ class MigrateHostClassPermission < ActiveRecord::Migration[6.0]
2
+ def up
3
+ Permission.where(resource_type: 'HostClass').update_all(resource_type: 'ForemanPuppet::HostClass')
4
+ end
5
+
6
+ def down
7
+ # no can do
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class MigrateEnvironmentIgnoreType < ActiveRecord::Migration[6.0]
2
+ def up
3
+ taxonomies = Taxonomy.unscoped.where("ignore_types LIKE '%Environment%'")
4
+ environment_ids = ForemanPuppet::Environment.unscoped.pluck(:id)
5
+
6
+ taxonomies.each do |tax|
7
+ new_types = tax.ignore_types.reject { |type| type == 'Environment' }
8
+ tax.update_columns(ignore_types: new_types)
9
+ taxable_rows = environment_ids.map do |env_id|
10
+ { taxable_id: env_id, taxable_type: 'ForemanPuppet::Environment', taxonomy_id: tax.id }
11
+ end
12
+ TaxableTaxonomy.insert_all(taxable_rows) if taxable_rows.any?
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,8 @@
1
1
  class CreateHostgroupsPuppetclasses < ActiveRecord::Migration[6.0]
2
2
  def up
3
- create_table :hostgroups_puppetclasses, id: false, if_not_exists: true do |t|
3
+ # this table is later renamed into hostgroup_classes and thus we don't want to create it if it exists under the later name
4
+ return if table_exists?(:hostgroups_puppetclasses) || table_exists?(:hostgroup_classes)
5
+ create_table :hostgroups_puppetclasses, id: false do |t|
4
6
  t.references :hostgroup, foreign_key: true, null: false
5
7
  t.references :puppetclass, foreign_key: true, null: false
6
8
  end
@@ -147,7 +147,8 @@ Foreman::Plugin.register :foreman_puppet do
147
147
  permission :import_puppetclasses, { 'foreman_puppet/puppetclasses' => %i[import_environments obsolete_and_new],
148
148
  'foreman_puppet/api/v2/environments' => [:import_puppetclasses] },
149
149
  resource_type: 'ForemanPuppet::Puppetclass'
150
- permission :edit_classes, { 'foreman_puppet/api/v2/host_classes': %i[index create destroy] },
150
+ permission :edit_classes, { :host_editing => [:edit_classes],
151
+ 'foreman_puppet/api/v2/host_classes' => %i[index create destroy] },
151
152
  resource_type: 'ForemanPuppet::HostClass'
152
153
  end
153
154
 
@@ -1,3 +1,3 @@
1
1
  module ForemanPuppet
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.0.3'.freeze
3
3
  end
@@ -0,0 +1,34 @@
1
+ require 'test_puppet_helper'
2
+
3
+ module ForemanPuppet
4
+ class PuppetclassLookupKeysHelperTest < ActionView::TestCase
5
+ include PuppetclassLookupKeysHelper
6
+
7
+ describe '#overridable_puppet_lookup_keys' do
8
+ let(:parent_puppet_var) { FactoryBot.create(:puppetclass_lookup_key) }
9
+ let(:parent_hg) { FactoryBot.create(:hostgroup, :with_puppet_enc, environment: parent_puppet_var.environments.first) }
10
+
11
+ context 'with new hostgroup' do
12
+ subject do
13
+ hg = Hostgroup.new(parent: parent_hg)
14
+ hg.build_puppet
15
+ hg
16
+ end
17
+
18
+ it 'returns inherited parameter' do
19
+ keys = overridable_puppet_lookup_keys(parent_puppet_var.param_classes.first, subject)
20
+ _(keys).must_include(parent_puppet_var)
21
+ end
22
+ end
23
+
24
+ context 'with new host' do
25
+ subject { Host.new(hostgroup: parent_hg) }
26
+
27
+ it 'returns inherited parameter' do
28
+ keys = overridable_puppet_lookup_keys(parent_puppet_var.param_classes.first, subject)
29
+ _(keys).must_include(parent_puppet_var)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
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: 2.0.2
4
+ version: 2.0.3
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: 2021-12-28 00:00:00.000000000 Z
12
+ date: 2022-02-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Allow assigning Puppet environments and classes to the Foreman Hosts.
15
15
  email:
@@ -188,6 +188,8 @@ files:
188
188
  - db/migrate/20210924103241_remove_katello_id_from_environments.foreman_puppet.rb
189
189
  - db/migrate/20211111125003_drop_puppetclasses_direct_references.foreman_puppet.rb
190
190
  - db/migrate/20211112130803_cleanup_environment_from_core_tables.foreman_puppet.rb
191
+ - db/migrate/20220201205305_migrate_host_class_permission.foreman_puppet.rb
192
+ - db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
191
193
  - db/migrate_foreman/20090722141107_create_environments.foreman_puppet.rb
192
194
  - db/migrate_foreman/20090802062223_create_puppetclasses.foreman_puppet.rb
193
195
  - db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb
@@ -292,6 +294,7 @@ files:
292
294
  - test/graphql/queries/puppetclass_query_test.rb
293
295
  - test/graphql/queries/puppetclasses_query_test.rb
294
296
  - test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb
297
+ - test/helpers/foreman_puppet/puppetclass_lookup_keys_helper_test.rb
295
298
  - test/helpers/foreman_puppet/puppetclasses_helper_test.rb
296
299
  - test/integration/foreman_puppet/dashboard_js_test.rb
297
300
  - test/integration/foreman_puppet/environment_js_test.rb
@@ -363,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
363
366
  - !ruby/object:Gem::Version
364
367
  version: '0'
365
368
  requirements: []
366
- rubygems_version: 3.1.6
369
+ rubygems_version: 3.3.4
367
370
  signing_key:
368
371
  specification_version: 4
369
372
  summary: Add Puppet features to Foreman
@@ -387,6 +390,7 @@ test_files:
387
390
  - test/graphql/queries/environment_query_test.rb
388
391
  - test/graphql/queries/hostgroup_puppet_query_test.rb
389
392
  - test/graphql/queries/environments_query_test.rb
393
+ - test/helpers/foreman_puppet/puppetclass_lookup_keys_helper_test.rb
390
394
  - test/helpers/foreman_puppet/puppetclasses_helper_test.rb
391
395
  - test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb
392
396
  - test/models/foreman_puppet/config_group_class_test.rb