Skip to content

Commit

Permalink
Ignore classifier_data hierarchies (#497)
Browse files Browse the repository at this point in the history
* Ignore `classifier_data` hierarchies

Signed-off-by: David Roetzel <[email protected]>

* Fix test

Signed-off-by: David Roetzel <[email protected]>

---------

Signed-off-by: David Roetzel <[email protected]>
  • Loading branch information
oneiros authored Dec 30, 2024
1 parent e3d54d4 commit 3761eed
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/models/hiera_data/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ def load_content
end

def initialize_hierarchies
@hierarchies = content['hierarchy'].map do |hierarchy|
Hierarchy.new(
raw_hash: content['defaults'].merge(hierarchy),
base_path: @base_path
)
@hierarchies = content['hierarchy'].filter_map do |hierarchy|
unless hierarchy['data_hash'] == 'classifier_data'
Hierarchy.new(
raw_hash: content['defaults'].merge(hierarchy),
base_path: @base_path
)
end
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/files/puppet/environments/enterprise/hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
version: 5

hierarchy:
- name: Classifier Configuration Data
data_hash: classifier_data
1 change: 1 addition & 0 deletions test/models/environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class EnvironmentTest < ActiveSupport::TestCase
development
dynamic_datadir
empty_defaults
enterprise
eyaml
globs
hdm
Expand Down
9 changes: 9 additions & 0 deletions test/models/hiera_data/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,14 @@ def base_path
Pathname.new(Rails.configuration.hdm["config_dir"]).join("environments", "empty_defaults")
end
end

class ConfigWithClassifierDataHierarchyTest < ActiveSupport::TestCase
test "`classifier_data` hierarchy is being ignored" do
base_path = Pathname.new(Rails.configuration.hdm["config_dir"]).join("environments", "enterprise")
config = HieraData::Config.new(base_path.join("hiera.yaml"))

assert_equal [], config.hierarchies
end
end
end
end

0 comments on commit 3761eed

Please sign in to comment.