rspec-hiera-puppet 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -1
- data/lib/hiera/backend/rspec_backend.rb +9 -1
- data/lib/rspec-hiera-puppet/puppet.rb +12 -105
- data/lib/rspec-hiera-puppet/version.rb +1 -1
- data/rspec-hiera-puppet.gemspec +3 -3
- metadata +14 -14
data/README.md
CHANGED
@@ -6,7 +6,7 @@ class Hiera
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def lookup(key, scope, order_override, resolution_type)
|
9
|
-
answer =
|
9
|
+
answer = nil
|
10
10
|
|
11
11
|
Hiera.debug("Looking up #{key} in RSpec backend")
|
12
12
|
|
@@ -26,6 +26,12 @@ class Hiera
|
|
26
26
|
next
|
27
27
|
end
|
28
28
|
|
29
|
+
# Extra logging that we found the key. This can be outputted
|
30
|
+
# multiple times if the resolution type is array or hash but that
|
31
|
+
# should be expected as the logging will then tell the user ALL the
|
32
|
+
# places where the key is found.
|
33
|
+
Hiera.debug("Found #{key} in #{source}")
|
34
|
+
|
29
35
|
# for array resolution we just append to the array whatever
|
30
36
|
# we find, we then goes onto the next file and keep adding to
|
31
37
|
# the array
|
@@ -35,9 +41,11 @@ class Hiera
|
|
35
41
|
case resolution_type
|
36
42
|
when :array
|
37
43
|
raise Exception, "Hiera type mismatch: expected Array and got #{new_answer.class}" unless new_answer.kind_of? Array or new_answer.kind_of? String
|
44
|
+
answer ||= []
|
38
45
|
answer << new_answer
|
39
46
|
when :hash
|
40
47
|
raise Exception, "Hiera type mismatch: expected Hash and got #{new_answer.class}" unless new_answer.kind_of? Hash
|
48
|
+
answer ||= {}
|
41
49
|
answer = new_answer.merge answer
|
42
50
|
else
|
43
51
|
answer = new_answer
|
@@ -18,126 +18,33 @@ class Puppet::Parser::Compiler
|
|
18
18
|
|
19
19
|
def register_function_hiera(spec)
|
20
20
|
Puppet::Parser::Functions.newfunction(:hiera, :type => :rvalue) do |*args|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
# where as calling from templates should work like this:
|
26
|
-
# scope.function_lookup("foo", "bar")
|
27
|
-
#
|
28
|
-
# Therefore, declare this function with args '*args' to accept any number
|
29
|
-
# of arguments and deal with puppet's special calling mechanism now:
|
30
|
-
if args[0].is_a?(Array)
|
31
|
-
args = args[0]
|
32
|
-
end
|
33
|
-
|
34
|
-
key = args[0]
|
35
|
-
default = args[1]
|
36
|
-
override = args[2]
|
37
|
-
|
38
|
-
require 'hiera'
|
39
|
-
require 'hiera/scope'
|
40
|
-
|
41
|
-
hiera = Hiera.new(:config => spec.hiera_config.merge(:logger => 'puppet'))
|
42
|
-
|
43
|
-
if self.respond_to?("[]")
|
44
|
-
hiera_scope = self
|
45
|
-
else
|
46
|
-
hiera_scope = Hiera::Scope.new(self)
|
47
|
-
end
|
48
|
-
|
49
|
-
answer = hiera.lookup(key, default, hiera_scope, override, :priority)
|
50
|
-
|
51
|
-
raise(Puppet::ParseError, "Could not find data item #{key} in any Hiera data file and no default supplied") if answer.nil?
|
52
|
-
|
53
|
-
return answer
|
21
|
+
require 'hiera_puppet'
|
22
|
+
key, default, override = HieraPuppet.parse_args(args)
|
23
|
+
HieraPuppet.lookup(key, default, self, override, :priority)
|
54
24
|
end
|
55
25
|
end
|
56
26
|
|
57
27
|
def register_function_hiera_array(spec)
|
58
28
|
Puppet::Parser::Functions.newfunction(:hiera_array, :type => :rvalue) do |*args|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
key = args[0]
|
64
|
-
default = args[1]
|
65
|
-
override = args[2]
|
66
|
-
|
67
|
-
require 'hiera'
|
68
|
-
require 'hiera/scope'
|
69
|
-
|
70
|
-
hiera = Hiera.new(:config => spec.hiera_config.merge(:logger => 'puppet'))
|
71
|
-
|
72
|
-
if self.respond_to?("[]")
|
73
|
-
hiera_scope = self
|
74
|
-
else
|
75
|
-
hiera_scope = Hiera::Scope.new(self)
|
76
|
-
end
|
77
|
-
|
78
|
-
answer = hiera.lookup(key, default, hiera_scope, override, :array)
|
79
|
-
|
80
|
-
raise(Puppet::ParseError, "Could not find data item #{key} in any Hiera data file and no default supplied") if answer.empty?
|
81
|
-
|
82
|
-
answer
|
29
|
+
require 'hiera_puppet'
|
30
|
+
key, default, override = HieraPuppet.parse_args(args)
|
31
|
+
HieraPuppet.lookup(key, default, self, override, :array)
|
83
32
|
end
|
84
33
|
end
|
85
34
|
|
86
35
|
def register_function_hiera_hash(spec)
|
87
36
|
Puppet::Parser::Functions.newfunction(:hiera_hash, :type => :rvalue) do |*args|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
raise(Puppet::ParseError, "Please supply a parameter to perform a Hiera lookup") if args.empty?
|
93
|
-
|
94
|
-
key = args[0]
|
95
|
-
default = args[1]
|
96
|
-
override = args[2]
|
97
|
-
|
98
|
-
require 'hiera'
|
99
|
-
require 'hiera/scope'
|
100
|
-
|
101
|
-
hiera = Hiera.new(:config => spec.hiera_config.merge(:logger => 'puppet'))
|
102
|
-
|
103
|
-
if self.respond_to?("{}")
|
104
|
-
hiera_scope = self
|
105
|
-
else
|
106
|
-
hiera_scope = Hiera::Scope.new(self)
|
107
|
-
end
|
108
|
-
|
109
|
-
answer = hiera.lookup(key, default, hiera_scope, override, :hash)
|
110
|
-
|
111
|
-
raise(Puppet::ParseError, "Could not find data item #{key} in any Hiera data file and no default supplied") if answer.empty?
|
112
|
-
|
113
|
-
answer
|
37
|
+
require 'hiera_puppet'
|
38
|
+
key, default, override = HieraPuppet.parse_args(args)
|
39
|
+
HieraPuppet.lookup(key, default, self, override, :hash)
|
114
40
|
end
|
115
41
|
end
|
116
42
|
|
117
43
|
def register_function_hiera_include(spec)
|
118
44
|
Puppet::Parser::Functions.newfunction(:hiera_include) do |*args|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
key = args[0]
|
124
|
-
default = args[1]
|
125
|
-
override = args[2]
|
126
|
-
|
127
|
-
require 'hiera'
|
128
|
-
require 'hiera/scope'
|
129
|
-
|
130
|
-
hiera = Hiera.new(:config => spec.hiera_config.merge(:logger => 'puppet'))
|
131
|
-
|
132
|
-
if self.respond_to?("[]")
|
133
|
-
hiera_scope = self
|
134
|
-
else
|
135
|
-
hiera_scope = Hiera::Scope.new(self)
|
136
|
-
end
|
137
|
-
|
138
|
-
answer = hiera.lookup(key, default, hiera_scope, override, :array)
|
139
|
-
|
140
|
-
raise(Puppet::ParseError, "Could not find data item #{key} in any Hiera data file and no default supplied") if answer.empty?
|
45
|
+
require 'hiera_puppet'
|
46
|
+
key, default, override = HieraPuppet.parse_args(args)
|
47
|
+
answer = HieraPuppet.lookup(key, default, self, override, :array)
|
141
48
|
|
142
49
|
method = Puppet::Parser::Functions.function(:include)
|
143
50
|
send(method, answer)
|
data/rspec-hiera-puppet.gemspec
CHANGED
@@ -15,9 +15,9 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Rspec::Hiera::Puppet::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency('puppet', '>=
|
19
|
-
gem.add_dependency('hiera', '>= 0
|
20
|
-
gem.add_dependency('hiera-puppet', '>= 0
|
18
|
+
gem.add_dependency('puppet', '>= 3.0')
|
19
|
+
gem.add_dependency('hiera', '>= 1.0')
|
20
|
+
gem.add_dependency('hiera-puppet', '>= 1.0')
|
21
21
|
gem.add_dependency('rspec')
|
22
22
|
gem.add_dependency('rspec-puppet')
|
23
23
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-hiera-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Franz Aigner
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-10-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: puppet
|
@@ -25,11 +25,11 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 7
|
29
29
|
segments:
|
30
|
-
-
|
31
|
-
-
|
32
|
-
version: "
|
30
|
+
- 3
|
31
|
+
- 0
|
32
|
+
version: "3.0"
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -40,11 +40,11 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
hash:
|
43
|
+
hash: 15
|
44
44
|
segments:
|
45
|
+
- 1
|
45
46
|
- 0
|
46
|
-
|
47
|
-
version: "0.3"
|
47
|
+
version: "1.0"
|
48
48
|
type: :runtime
|
49
49
|
version_requirements: *id002
|
50
50
|
- !ruby/object:Gem::Dependency
|
@@ -55,11 +55,11 @@ dependencies:
|
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
58
|
+
hash: 15
|
59
59
|
segments:
|
60
|
+
- 1
|
60
61
|
- 0
|
61
|
-
|
62
|
-
version: "0.3"
|
62
|
+
version: "1.0"
|
63
63
|
type: :runtime
|
64
64
|
version_requirements: *id003
|
65
65
|
- !ruby/object:Gem::Dependency
|