hiera-ic-yaml 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiera/backend/ic_yaml_backend.rb +18 -1
- data/lib/hiera/filenocache.rb +30 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2eb8fc26221b717523240df9a5ce580512d3833
|
4
|
+
data.tar.gz: fa8dcce2e04c09b7a0a77399465627cf094b0888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70bd0b711ba80a5798fe684df940ec7760818fa1d4af1a7d07baf9e4a8b19aeb71841c5f24bbf74d46842bc4ae7900c2f219189167a1466929a53937d2a8649
|
7
|
+
data.tar.gz: 1d46def3c92544684ba0b04d9f17c5972ae5228594010237f81918220eb07f8585d048c00cad953f45d440d3be8a9fa4df66f45d6c3b256428b1ef687402744a
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'hiera/filenocache'
|
2
|
+
require 'hiera/filecache'
|
3
|
+
|
1
4
|
class Hiera
|
2
5
|
module Backend
|
3
6
|
class Ic_yaml_backend
|
@@ -5,7 +8,7 @@ class Hiera
|
|
5
8
|
require 'yaml'
|
6
9
|
Hiera.debug("Hiera IC YAML backend starting")
|
7
10
|
|
8
|
-
@cache = cache ||
|
11
|
+
@cache = cache || create_filecache()
|
9
12
|
end
|
10
13
|
|
11
14
|
def ic_yaml_config()
|
@@ -62,6 +65,20 @@ class Hiera
|
|
62
65
|
return '__imports__'
|
63
66
|
end
|
64
67
|
|
68
|
+
def create_filecache()
|
69
|
+
config = ic_yaml_config()
|
70
|
+
|
71
|
+
if !config.has_key?('cacheable') && !config.has_key?(:cacheable)
|
72
|
+
return Hiera::Filecache.new
|
73
|
+
end
|
74
|
+
|
75
|
+
if config[:cacheable] || config[:cacheable]
|
76
|
+
return Hiera::Filecache.new
|
77
|
+
end
|
78
|
+
|
79
|
+
return Hiera::Filenocache.new
|
80
|
+
end
|
81
|
+
|
65
82
|
def parameters_key()
|
66
83
|
config = ic_yaml_config()
|
67
84
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Hiera
|
2
|
+
class Filenocache
|
3
|
+
|
4
|
+
def read(path, expected_type = Object, default=nil, &block)
|
5
|
+
read_file(path, expected_type, &block)
|
6
|
+
rescue TypeError => detail
|
7
|
+
Hiera.debug("#{detail.message}, setting defaults")
|
8
|
+
default
|
9
|
+
rescue => detail
|
10
|
+
error = "Reading data from #{path} failed: #{detail.class}: #{detail}"
|
11
|
+
if default.nil?
|
12
|
+
raise detail
|
13
|
+
else
|
14
|
+
Hiera.debug(error)
|
15
|
+
default
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def read_file(path, expected_type = Object)
|
20
|
+
data = File.read(path)
|
21
|
+
result = block_given? ? yield(data) : data
|
22
|
+
|
23
|
+
if !result.is_a?(expected_type)
|
24
|
+
raise TypeError, "Data retrieved from #{path} is #{data.class} not #{expected_type}"
|
25
|
+
end
|
26
|
+
|
27
|
+
result
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiera-ic-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio B. Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Hiera yaml backend that support imports and parameters
|
14
14
|
email: fabio.bat.silva@gmail.com
|
@@ -17,6 +17,7 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/hiera/backend/ic_yaml_backend.rb
|
20
|
+
- lib/hiera/filenocache.rb
|
20
21
|
homepage: http://github.com/instaclick/hiera-ic-yaml
|
21
22
|
licenses: []
|
22
23
|
metadata: {}
|