hiera 3.2.0 → 3.12.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 +7 -0
- data/README.md +3 -1
- data/bin/hiera +0 -18
- data/lib/hiera/backend.rb +5 -1
- data/lib/hiera/config.rb +8 -2
- data/lib/hiera/filecache.rb +1 -1
- data/lib/hiera/util/win32.rb +40 -0
- data/lib/hiera/util.rb +2 -10
- data/lib/hiera/version.rb +1 -1
- data/lib/hiera.rb +1 -0
- data/spec/spec_helper.rb +0 -7
- data/spec/unit/config_spec.rb +4 -0
- data/spec/unit/filecache_spec.rb +30 -0
- data/spec/unit/fixtures/badconfig/config/hiera.yaml +6 -0
- data/spec/unit/fixtures/badconfig/data/common.yaml +2 -0
- metadata +65 -79
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3dbd1b0fbf149ea64380d19c6c4c8cf717919cab09e4bc31307e05ed2d4b2179
|
4
|
+
data.tar.gz: 1050d6650d3c80ca699eabfc5723ba92396831f046d63d66d94c64c396ad11ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88f75b0ab33bea213421bdf6724823a0800b791dd46be27a08962343b7f18dbc3f0b876926aa2303629dd1976f83e7e2414633dbe43f2dea9cc48430c695bacb
|
7
|
+
data.tar.gz: 2c93636b84c9b886b14931dd4caec21395e8e30413678364554ebe1a1c0f34417651f6339c5f34c640c385f4da6ee72a58cd6602400c4415aa4e422202e05674
|
data/README.md
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
|
5
5
|
A simple pluggable Hierarchical Database.
|
6
6
|
|
7
|
-
|
7
|
+
**This project is deprecated in favor of Hiera version 5 which is implementation in Puppet.**
|
8
|
+
|
8
9
|
**Tutorials:** Check the docs directory for tutorials.
|
9
10
|
|
10
11
|
## Why?
|
@@ -321,3 +322,4 @@ commercial customers. Please see the following page for more details:
|
|
321
322
|
|
322
323
|
* Thomas Hallgren
|
323
324
|
* Henrik Lindberg
|
325
|
+
|
data/bin/hiera
CHANGED
@@ -41,24 +41,6 @@ initial_scopes = Array.new
|
|
41
41
|
# Loads the scope from YAML or JSON files
|
42
42
|
def load_scope(source, type=:yaml)
|
43
43
|
case type
|
44
|
-
when :mcollective
|
45
|
-
begin
|
46
|
-
require 'mcollective'
|
47
|
-
|
48
|
-
include MCollective::RPC
|
49
|
-
|
50
|
-
util = rpcclient("rpcutil")
|
51
|
-
util.progress = false
|
52
|
-
nodestats = util.custom_request("inventory", {}, source, {"identity" => source}).first
|
53
|
-
|
54
|
-
raise "Failed to retrieve facts for node #{source}: #{nodestats[:statusmsg]}" unless nodestats[:statuscode] == 0
|
55
|
-
|
56
|
-
scope = nodestats[:data][:facts]
|
57
|
-
rescue Exception => e
|
58
|
-
STDERR.puts "MCollective lookup failed: #{e.class}: #{e}"
|
59
|
-
exit 1
|
60
|
-
end
|
61
|
-
|
62
44
|
when :yaml
|
63
45
|
raise "Cannot find scope #{type} file #{source}" unless File.exist?(source)
|
64
46
|
|
data/lib/hiera/backend.rb
CHANGED
@@ -89,7 +89,11 @@ class Hiera
|
|
89
89
|
|
90
90
|
hierarchy.flatten.map do |source|
|
91
91
|
source = interpolate_config(source, scope, override)
|
92
|
-
|
92
|
+
if source == "" or source =~ /(^\/|\/\/|\/$)/
|
93
|
+
Hiera.debug("Ignoring bad definition in :hierarchy: \'#{source}\'")
|
94
|
+
else
|
95
|
+
yield(source)
|
96
|
+
end
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
data/lib/hiera/config.rb
CHANGED
@@ -26,7 +26,13 @@ class Hiera::Config
|
|
26
26
|
raise detail
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
if config
|
30
|
+
version = config['version'] || config[:version] || 3
|
31
|
+
if version >= 4
|
32
|
+
raise "v#{version} hiera.yaml is only to be used inside an environment or a module and cannot be given to the global hiera"
|
33
|
+
end
|
34
|
+
@config.merge! config
|
35
|
+
end
|
30
36
|
else
|
31
37
|
raise "Config file #{source} not found"
|
32
38
|
end
|
@@ -42,7 +48,7 @@ class Hiera::Config
|
|
42
48
|
@config[:logger] = "console"
|
43
49
|
Hiera.logger = "console"
|
44
50
|
end
|
45
|
-
|
51
|
+
|
46
52
|
self.validate!
|
47
53
|
|
48
54
|
@config
|
data/lib/hiera/filecache.rb
CHANGED
@@ -49,7 +49,7 @@ class Hiera
|
|
49
49
|
# in processing will be propagated to the caller
|
50
50
|
def read_file(path, expected_type = Object)
|
51
51
|
if stale?(path)
|
52
|
-
data = File.read(path)
|
52
|
+
data = File.read(path, :encoding => 'BOM|UTF-8')
|
53
53
|
@cache[path][:data] = block_given? ? yield(data) : data
|
54
54
|
|
55
55
|
if !@cache[path][:data].is_a?(expected_type)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Hiera
|
2
|
+
module Util
|
3
|
+
module Win32
|
4
|
+
if !!File::ALT_SEPARATOR
|
5
|
+
require 'fiddle/import'
|
6
|
+
require 'fiddle/types'
|
7
|
+
|
8
|
+
# import, dlload, include and typealias must be ordered this way
|
9
|
+
extend Fiddle::Importer
|
10
|
+
dlload 'shell32'
|
11
|
+
include Fiddle::Win32Types # adds HWND, HANDLE, DWORD type aliases
|
12
|
+
typealias 'LPWSTR', 'wchar_t*'
|
13
|
+
typealias 'LONG', 'long'
|
14
|
+
typealias 'HRESULT','LONG'
|
15
|
+
|
16
|
+
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
|
17
|
+
# HRESULT SHGetFolderPath(
|
18
|
+
# _In_ HWND hwndOwner,
|
19
|
+
# _In_ int nFolder,
|
20
|
+
# _In_ HANDLE hToken,
|
21
|
+
# _In_ DWORD dwFlags,
|
22
|
+
# _Out_ LPTSTR pszPath
|
23
|
+
# );
|
24
|
+
extern 'HRESULT SHGetFolderPathW(HWND, int, HANDLE, DWORD, LPWSTR)'
|
25
|
+
|
26
|
+
COMMON_APPDATA = 0x0023
|
27
|
+
S_OK = 0x0
|
28
|
+
MAX_PATH = 260;
|
29
|
+
|
30
|
+
def self.get_common_appdata
|
31
|
+
# null terminated MAX_PATH string in wchar (i.e. 2 bytes per char)
|
32
|
+
buffer = 0.chr * ((MAX_PATH + 1) * 2)
|
33
|
+
result = SHGetFolderPathW(0, COMMON_APPDATA, 0, 0, buffer)
|
34
|
+
raise "Could not find COMMON_APPDATA path - HRESULT: #{result}" unless result == S_OK
|
35
|
+
buffer.force_encoding(Encoding::UTF_16LE).encode(Encoding::UTF_8).strip
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/hiera/util.rb
CHANGED
@@ -13,15 +13,7 @@ class Hiera
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def microsoft_windows?
|
16
|
-
|
17
|
-
|
18
|
-
begin
|
19
|
-
require 'win32/dir'
|
20
|
-
true
|
21
|
-
rescue LoadError => err
|
22
|
-
warn "Cannot run on Microsoft Windows without the win32-dir gem: #{err}"
|
23
|
-
false
|
24
|
-
end
|
16
|
+
!!file_alt_separator
|
25
17
|
end
|
26
18
|
|
27
19
|
def config_dir
|
@@ -49,7 +41,7 @@ class Hiera
|
|
49
41
|
end
|
50
42
|
|
51
43
|
def common_appdata
|
52
|
-
|
44
|
+
@common_appdata ||= Hiera::Util::Win32.get_common_appdata()
|
53
45
|
end
|
54
46
|
|
55
47
|
def split_key(key)
|
data/lib/hiera/version.rb
CHANGED
data/lib/hiera.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -9,13 +9,6 @@ require 'tmpdir'
|
|
9
9
|
RSpec.configure do |config|
|
10
10
|
config.mock_with :mocha
|
11
11
|
|
12
|
-
if Hiera::Util.microsoft_windows? && RUBY_VERSION =~ /^1\./
|
13
|
-
require 'win32console'
|
14
|
-
config.output_stream = $stdout
|
15
|
-
config.error_stream = $stderr
|
16
|
-
config.formatters.each { |f| f.instance_variable_set(:@output, $stdout) }
|
17
|
-
end
|
18
|
-
|
19
12
|
config.after :suite do
|
20
13
|
# Log the spec order to a file, but only if the LOG_SPEC_ORDER environment variable is
|
21
14
|
# set. This should be enabled on Jenkins runs, as it can be used with Nick L.'s bisect
|
data/spec/unit/config_spec.rb
CHANGED
@@ -12,6 +12,10 @@ class Hiera
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
+
it 'should raise an error if the configuration version is greater than 3' do
|
16
|
+
expect { Hiera.new(:config => File.join(HieraSpec::FIXTURE_DIR, 'badconfig', 'config', 'hiera.yaml')) }.to raise_error(/v4 hiera\.yaml is only to be used inside an environment or a module/)
|
17
|
+
end
|
18
|
+
|
15
19
|
it "should raise an error for missing config files" do
|
16
20
|
File.expects(:exist?).with("/nonexisting").returns(false)
|
17
21
|
YAML.expects(:load_file).with("/nonexisting").never
|
data/spec/unit/filecache_spec.rb
CHANGED
@@ -84,6 +84,36 @@ class Hiera
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
it "sets the encoding to UTF-8 when reading a file" do
|
88
|
+
begin
|
89
|
+
original_encoding = Encoding.default_external
|
90
|
+
Encoding.default_external = Encoding::ISO_8859_1
|
91
|
+
|
92
|
+
Dir.mktmpdir do |dir|
|
93
|
+
file = File.join(dir, "testing")
|
94
|
+
write_file(file, "my data")
|
95
|
+
expect(@cache.read_file(file).encoding).to eq(Encoding::UTF_8)
|
96
|
+
end
|
97
|
+
ensure
|
98
|
+
Encoding.default_external = original_encoding
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it "reads a file with unicode characters" do
|
103
|
+
begin
|
104
|
+
original_encoding = Encoding.default_external
|
105
|
+
Encoding.default_external = Encoding::ISO_8859_1
|
106
|
+
|
107
|
+
Dir.mktmpdir do |dir|
|
108
|
+
file = File.join(dir, "testing")
|
109
|
+
write_file(file, "\u2603")
|
110
|
+
expect(@cache.read_file(file)).to eq("\u2603")
|
111
|
+
end
|
112
|
+
ensure
|
113
|
+
Encoding.default_external = original_encoding
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
87
117
|
it "rereads data when the file changes" do
|
88
118
|
Dir.mktmpdir do |dir|
|
89
119
|
file = File.join(dir, "testing")
|
metadata
CHANGED
@@ -1,32 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
5
|
-
prerelease:
|
4
|
+
version: 3.12.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Puppet Labs
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: json_pure
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
30
13
|
description: A pluggable data store for hierarcical data
|
31
14
|
email: info@puppetlabs.com
|
32
15
|
executables:
|
@@ -34,103 +17,106 @@ executables:
|
|
34
17
|
extensions: []
|
35
18
|
extra_rdoc_files: []
|
36
19
|
files:
|
20
|
+
- COPYING
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
37
23
|
- bin/hiera
|
38
|
-
- lib/hiera
|
39
|
-
- lib/hiera/
|
40
|
-
- lib/hiera/error.rb
|
41
|
-
- lib/hiera/fallback_logger.rb
|
42
|
-
- lib/hiera/recursive_guard.rb
|
43
|
-
- lib/hiera/backend/yaml_backend.rb
|
24
|
+
- lib/hiera.rb
|
25
|
+
- lib/hiera/backend.rb
|
44
26
|
- lib/hiera/backend/json_backend.rb
|
27
|
+
- lib/hiera/backend/yaml_backend.rb
|
45
28
|
- lib/hiera/config.rb
|
29
|
+
- lib/hiera/console_logger.rb
|
30
|
+
- lib/hiera/error.rb
|
31
|
+
- lib/hiera/fallback_logger.rb
|
46
32
|
- lib/hiera/filecache.rb
|
47
33
|
- lib/hiera/interpolate.rb
|
48
|
-
- lib/hiera/
|
34
|
+
- lib/hiera/noop_logger.rb
|
49
35
|
- lib/hiera/puppet_logger.rb
|
36
|
+
- lib/hiera/recursive_guard.rb
|
50
37
|
- lib/hiera/util.rb
|
51
|
-
- lib/hiera/
|
52
|
-
- lib/hiera.rb
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
- spec/unit/
|
57
|
-
- spec/unit/
|
58
|
-
- spec/unit/
|
59
|
-
- spec/unit/
|
38
|
+
- lib/hiera/util/win32.rb
|
39
|
+
- lib/hiera/version.rb
|
40
|
+
- spec/spec_helper.rb
|
41
|
+
- spec/unit/backend/json_backend_spec.rb
|
42
|
+
- spec/unit/backend/yaml_backend_spec.rb
|
43
|
+
- spec/unit/backend_spec.rb
|
44
|
+
- spec/unit/config_spec.rb
|
45
|
+
- spec/unit/console_logger_spec.rb
|
46
|
+
- spec/unit/fallback_logger_spec.rb
|
47
|
+
- spec/unit/filecache_spec.rb
|
48
|
+
- spec/unit/fixtures/badconfig/config/hiera.yaml
|
49
|
+
- spec/unit/fixtures/badconfig/data/common.yaml
|
50
|
+
- spec/unit/fixtures/interpolate/config/hiera.yaml
|
60
51
|
- spec/unit/fixtures/interpolate/config/hiera_iplm_hiera.yaml
|
61
52
|
- spec/unit/fixtures/interpolate/config/hiera_iplm_hiera_bad.yaml
|
62
|
-
- spec/unit/fixtures/interpolate/config/hiera.yaml
|
63
|
-
- spec/unit/fixtures/interpolate/data/niltest.yaml
|
64
|
-
- spec/unit/fixtures/interpolate/data/complex.yaml
|
65
|
-
- spec/unit/fixtures/interpolate/data/frontend.json
|
66
|
-
- spec/unit/fixtures/interpolate/data/role.json
|
67
53
|
- spec/unit/fixtures/interpolate/data/bad_interpolation.yaml
|
54
|
+
- spec/unit/fixtures/interpolate/data/complex.yaml
|
68
55
|
- spec/unit/fixtures/interpolate/data/dotted_keys.yaml
|
69
|
-
- spec/unit/fixtures/interpolate/data/weird_keys.yaml
|
70
56
|
- spec/unit/fixtures/interpolate/data/empty_interpolation.yaml
|
57
|
+
- spec/unit/fixtures/interpolate/data/frontend.json
|
58
|
+
- spec/unit/fixtures/interpolate/data/niltest.yaml
|
71
59
|
- spec/unit/fixtures/interpolate/data/recursive.yaml
|
72
|
-
- spec/unit/
|
73
|
-
- spec/unit/
|
74
|
-
- spec/unit/
|
75
|
-
- spec/unit/
|
76
|
-
- spec/unit/
|
60
|
+
- spec/unit/fixtures/interpolate/data/role.json
|
61
|
+
- spec/unit/fixtures/interpolate/data/weird_keys.yaml
|
62
|
+
- spec/unit/fixtures/override/config/hiera.yaml
|
63
|
+
- spec/unit/fixtures/override/data/alternate.yaml
|
64
|
+
- spec/unit/fixtures/override/data/common.yaml
|
65
|
+
- spec/unit/hiera_spec.rb
|
66
|
+
- spec/unit/interpolate_spec.rb
|
77
67
|
- spec/unit/puppet_logger_spec.rb
|
78
|
-
- spec/unit/console_logger_spec.rb
|
79
|
-
- spec/unit/version_spec.rb
|
80
|
-
- spec/unit/fallback_logger_spec.rb
|
81
68
|
- spec/unit/util_spec.rb
|
82
|
-
- spec/unit/
|
83
|
-
- spec/spec_helper.rb
|
69
|
+
- spec/unit/version_spec.rb
|
84
70
|
homepage: https://github.com/puppetlabs/hiera
|
85
71
|
licenses: []
|
72
|
+
metadata: {}
|
86
73
|
post_install_message:
|
87
74
|
rdoc_options: []
|
88
75
|
require_paths:
|
89
76
|
- lib
|
90
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
78
|
requirements:
|
93
|
-
- -
|
79
|
+
- - ">="
|
94
80
|
- !ruby/object:Gem::Version
|
95
81
|
version: '0'
|
96
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
83
|
requirements:
|
99
|
-
- -
|
84
|
+
- - ">="
|
100
85
|
- !ruby/object:Gem::Version
|
101
86
|
version: '0'
|
102
87
|
requirements: []
|
103
|
-
|
104
|
-
rubygems_version: 1.8.23
|
88
|
+
rubygems_version: 3.1.6
|
105
89
|
signing_key:
|
106
|
-
specification_version:
|
90
|
+
specification_version: 4
|
107
91
|
summary: Light weight hierarchical data store
|
108
92
|
test_files:
|
109
|
-
- spec/
|
110
|
-
- spec/unit/
|
111
|
-
- spec/unit/
|
112
|
-
- spec/unit/
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
- spec/unit/backend/json_backend_spec.rb
|
95
|
+
- spec/unit/backend/yaml_backend_spec.rb
|
96
|
+
- spec/unit/backend_spec.rb
|
97
|
+
- spec/unit/config_spec.rb
|
98
|
+
- spec/unit/console_logger_spec.rb
|
99
|
+
- spec/unit/fallback_logger_spec.rb
|
100
|
+
- spec/unit/filecache_spec.rb
|
101
|
+
- spec/unit/fixtures/badconfig/config/hiera.yaml
|
102
|
+
- spec/unit/fixtures/badconfig/data/common.yaml
|
103
|
+
- spec/unit/fixtures/interpolate/config/hiera.yaml
|
113
104
|
- spec/unit/fixtures/interpolate/config/hiera_iplm_hiera.yaml
|
114
105
|
- spec/unit/fixtures/interpolate/config/hiera_iplm_hiera_bad.yaml
|
115
|
-
- spec/unit/fixtures/interpolate/config/hiera.yaml
|
116
|
-
- spec/unit/fixtures/interpolate/data/niltest.yaml
|
117
|
-
- spec/unit/fixtures/interpolate/data/complex.yaml
|
118
|
-
- spec/unit/fixtures/interpolate/data/frontend.json
|
119
|
-
- spec/unit/fixtures/interpolate/data/role.json
|
120
106
|
- spec/unit/fixtures/interpolate/data/bad_interpolation.yaml
|
107
|
+
- spec/unit/fixtures/interpolate/data/complex.yaml
|
121
108
|
- spec/unit/fixtures/interpolate/data/dotted_keys.yaml
|
122
|
-
- spec/unit/fixtures/interpolate/data/weird_keys.yaml
|
123
109
|
- spec/unit/fixtures/interpolate/data/empty_interpolation.yaml
|
110
|
+
- spec/unit/fixtures/interpolate/data/frontend.json
|
111
|
+
- spec/unit/fixtures/interpolate/data/niltest.yaml
|
124
112
|
- spec/unit/fixtures/interpolate/data/recursive.yaml
|
125
|
-
- spec/unit/
|
126
|
-
- spec/unit/
|
127
|
-
- spec/unit/
|
128
|
-
- spec/unit/
|
129
|
-
- spec/unit/
|
113
|
+
- spec/unit/fixtures/interpolate/data/role.json
|
114
|
+
- spec/unit/fixtures/interpolate/data/weird_keys.yaml
|
115
|
+
- spec/unit/fixtures/override/config/hiera.yaml
|
116
|
+
- spec/unit/fixtures/override/data/alternate.yaml
|
117
|
+
- spec/unit/fixtures/override/data/common.yaml
|
118
|
+
- spec/unit/hiera_spec.rb
|
119
|
+
- spec/unit/interpolate_spec.rb
|
130
120
|
- spec/unit/puppet_logger_spec.rb
|
131
|
-
- spec/unit/console_logger_spec.rb
|
132
|
-
- spec/unit/version_spec.rb
|
133
|
-
- spec/unit/fallback_logger_spec.rb
|
134
121
|
- spec/unit/util_spec.rb
|
135
|
-
- spec/unit/
|
136
|
-
- spec/spec_helper.rb
|
122
|
+
- spec/unit/version_spec.rb
|