hieracles 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/bin/hc +4 -3
- data/bin/ppdb +2 -2
- data/lib/hieracles/config.rb +2 -4
- data/lib/hieracles/formats/console.rb +16 -15
- data/lib/hieracles/formats/csv.rb +6 -9
- data/lib/hieracles/formats/plain.rb +21 -13
- data/lib/hieracles/formats/yaml.rb +7 -14
- data/lib/hieracles/hiera.rb +5 -4
- data/lib/hieracles/node.rb +57 -25
- data/lib/hieracles/registry.rb +6 -3
- data/lib/hieracles/utils.rb +5 -0
- data/spec/lib/config_spec.rb +48 -32
- data/spec/lib/formats/console_spec.rb +23 -12
- data/spec/lib/formats/csv_spec.rb +24 -34
- data/spec/lib/formats/plain_spec.rb +23 -12
- data/spec/lib/formats/yaml_spec.rb +164 -96
- data/spec/lib/hiera_spec.rb +10 -12
- data/spec/lib/node_spec.rb +194 -146
- data/spec/lib/registry_spec.rb +10 -10
- metadata +2 -2
data/spec/lib/node_spec.rb
CHANGED
@@ -17,7 +17,8 @@ describe Hieracles::Node do
|
|
17
17
|
let(:extraoptions) {
|
18
18
|
options.merge({ params: 'key1=value1;key2=value2' })
|
19
19
|
}
|
20
|
-
let(:
|
20
|
+
let(:config) { Hieracles::Config.new extraoptions }
|
21
|
+
let(:node) { Hieracles::Node.new 'server.example.com', config }
|
21
22
|
let(:expected) {
|
22
23
|
{
|
23
24
|
classes: ['dev'],
|
@@ -35,12 +36,14 @@ describe Hieracles::Node do
|
|
35
36
|
end
|
36
37
|
|
37
38
|
context "when parameters are not valid" do
|
38
|
-
let(:
|
39
|
+
let(:config) { Hieracles::Config.new options }
|
40
|
+
let(:node) { Hieracles::Node.new 'server_not_there.example.com', config }
|
39
41
|
it { expect{ node }.to raise_error(RuntimeError) }
|
40
42
|
end
|
41
43
|
|
42
44
|
context "when parameters are valid" do
|
43
|
-
let(:
|
45
|
+
let(:config) { Hieracles::Config.new options }
|
46
|
+
let(:node) { Hieracles::Node.new 'server.example.com', config }
|
44
47
|
|
45
48
|
describe '.new' do
|
46
49
|
let(:expected) {
|
@@ -78,58 +81,71 @@ describe Hieracles::Node do
|
|
78
81
|
|
79
82
|
describe '.params' do
|
80
83
|
let(:expected) {
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
{
|
85
|
+
"another.more_sublevel" =>
|
86
|
+
{
|
84
87
|
value: "something",
|
85
88
|
file: 'params/farm/dev.yaml',
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
[ "another.sublevel.array",
|
90
|
-
[
|
91
|
-
{
|
92
|
-
value: ["one", "two", "three"],
|
89
|
+
overriden: false,
|
90
|
+
found_in: [
|
91
|
+
value: "something",
|
93
92
|
file: 'params/farm/dev.yaml',
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
93
|
+
]
|
94
|
+
},
|
95
|
+
"another.sublevel.array" =>
|
96
|
+
{
|
97
|
+
value: ["four", "five"],
|
98
|
+
file: '-',
|
99
|
+
overriden: true,
|
100
|
+
found_in: [
|
101
|
+
{
|
102
|
+
value: ["four", "five"],
|
103
|
+
file: 'params/nodes/server.example.com.yaml'
|
104
|
+
},
|
105
|
+
{
|
106
|
+
value: ["one", "two", "three"],
|
107
|
+
file: 'params/farm/dev.yaml'
|
108
|
+
}
|
109
|
+
]
|
110
|
+
},
|
111
|
+
"another.sublevel.thing" =>
|
112
|
+
{
|
105
113
|
value: "always",
|
106
114
|
file: 'params/nodes/server.example.com.yaml',
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
[ "common_param.subparam",
|
111
|
-
[
|
112
|
-
{
|
113
|
-
value: "override-me",
|
114
|
-
file: 'params/farm/dev.yaml',
|
115
|
-
merged: "override-me"
|
116
|
-
},
|
117
|
-
{
|
118
|
-
value: "overriden",
|
115
|
+
overriden: false,
|
116
|
+
found_in: [
|
117
|
+
value: "always",
|
119
118
|
file: 'params/nodes/server.example.com.yaml',
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
119
|
+
]
|
120
|
+
},
|
121
|
+
"common_param.subparam" =>
|
122
|
+
{
|
123
|
+
value: "overriden",
|
124
|
+
file: '-',
|
125
|
+
overriden: true,
|
126
|
+
found_in: [
|
127
|
+
{
|
128
|
+
value: "overriden",
|
129
|
+
file: 'params/nodes/server.example.com.yaml'
|
130
|
+
},
|
131
|
+
{
|
132
|
+
value: "override-me",
|
133
|
+
file: 'params/farm/dev.yaml'
|
134
|
+
},
|
135
|
+
]
|
136
|
+
},
|
137
|
+
"somefarmparam" =>
|
138
|
+
{
|
126
139
|
value: false,
|
127
140
|
file: 'params/farm/dev.yaml',
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
141
|
+
overriden: false,
|
142
|
+
found_in: [
|
143
|
+
value: false,
|
144
|
+
file: 'params/farm/dev.yaml',
|
145
|
+
]
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
133
149
|
it { expect(node.params).to eq expected }
|
134
150
|
end
|
135
151
|
|
@@ -164,7 +180,7 @@ describe Hieracles::Node do
|
|
164
180
|
it { expect(node.modules).to eq expected }
|
165
181
|
end
|
166
182
|
context "one unfound modules" do
|
167
|
-
let(:node) { Hieracles::Node.new 'server2.example.com',
|
183
|
+
let(:node) { Hieracles::Node.new 'server2.example.com', config }
|
168
184
|
let(:expected) {
|
169
185
|
{
|
170
186
|
"fake_module" => File.expand_path("spec/files/modules/fake_module"),
|
@@ -175,11 +191,11 @@ describe Hieracles::Node do
|
|
175
191
|
it { expect(node.modules).to eq expected }
|
176
192
|
end
|
177
193
|
context "no farm file found" do
|
178
|
-
let(:node) { Hieracles::Node.new 'server3.example.com',
|
194
|
+
let(:node) { Hieracles::Node.new 'server3.example.com', config }
|
179
195
|
it { expect { node.modules }.to raise_error(RuntimeError) }
|
180
196
|
end
|
181
197
|
context "multiple classes included" do
|
182
|
-
let(:node) { Hieracles::Node.new 'server4.example.com',
|
198
|
+
let(:node) { Hieracles::Node.new 'server4.example.com', config }
|
183
199
|
let(:expected) {
|
184
200
|
{
|
185
201
|
"fake_module" => File.expand_path("spec/files/modules/fake_module"),
|
@@ -232,7 +248,8 @@ describe Hieracles::Node do
|
|
232
248
|
let(:resp_facts) {
|
233
249
|
Hieracles::Puppetdb::Response.new([{ 'name' => 'datacenter', 'value' => 'tahiti' }], 1)
|
234
250
|
}
|
235
|
-
let(:
|
251
|
+
let(:config) { Hieracles::Config.new options }
|
252
|
+
let(:node) { Hieracles::Node.new 'server.example.com', config }
|
236
253
|
before {
|
237
254
|
allow_any_instance_of(Hieracles::Puppetdb::Client).
|
238
255
|
to receive(:request).
|
@@ -256,7 +273,8 @@ describe Hieracles::Node do
|
|
256
273
|
basepath: 'spec/files'
|
257
274
|
}
|
258
275
|
}
|
259
|
-
let(:
|
276
|
+
let(:config) { Hieracles::Config.new options }
|
277
|
+
let(:node) { Hieracles::Node.new 'server.example.com', config }
|
260
278
|
|
261
279
|
describe '.files' do
|
262
280
|
let(:expected) {
|
@@ -279,62 +297,76 @@ describe Hieracles::Node do
|
|
279
297
|
basepath: 'spec/files'
|
280
298
|
}
|
281
299
|
}
|
282
|
-
let(:
|
300
|
+
let(:config) { Hieracles::Config.new options }
|
301
|
+
let(:node) { Hieracles::Node.new 'server.example.com', config }
|
283
302
|
|
284
303
|
describe '.params' do
|
285
304
|
let(:expected) {
|
286
|
-
|
287
|
-
|
288
|
-
|
305
|
+
{
|
306
|
+
"another.more_sublevel" =>
|
307
|
+
{
|
289
308
|
value: "something",
|
290
309
|
file: 'params/farm/dev.yaml',
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
+
overriden: false,
|
311
|
+
found_in: [
|
312
|
+
value: "something",
|
313
|
+
file: 'params/farm/dev.yaml'
|
314
|
+
]
|
315
|
+
},
|
316
|
+
"another.sublevel.array" =>
|
317
|
+
{
|
318
|
+
value: ["four", "five", "one", "two", "three"],
|
319
|
+
file: '-',
|
320
|
+
overriden: true,
|
321
|
+
found_in: [
|
322
|
+
{
|
323
|
+
value: ["four", "five"],
|
324
|
+
file: 'params/nodes/server.example.com.yaml'
|
325
|
+
},
|
326
|
+
{
|
327
|
+
value: ["one", "two", "three"],
|
328
|
+
file: 'params/farm/dev.yaml'
|
329
|
+
}
|
330
|
+
]
|
331
|
+
},
|
332
|
+
"another.sublevel.thing" =>
|
333
|
+
{
|
310
334
|
value: "always",
|
311
335
|
file: 'params/nodes/server.example.com.yaml',
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
336
|
+
overriden: false,
|
337
|
+
found_in: [
|
338
|
+
value: "always",
|
339
|
+
file: 'params/nodes/server.example.com.yaml'
|
340
|
+
]
|
341
|
+
},
|
342
|
+
"common_param.subparam" =>
|
343
|
+
{
|
344
|
+
value: "overriden",
|
345
|
+
file: '-',
|
346
|
+
overriden: true,
|
347
|
+
found_in: [
|
348
|
+
{
|
349
|
+
value: "overriden",
|
350
|
+
file: 'params/nodes/server.example.com.yaml'
|
351
|
+
},
|
352
|
+
{
|
353
|
+
value: "override-me",
|
354
|
+
file: 'params/farm/dev.yaml'
|
355
|
+
},
|
356
|
+
]
|
357
|
+
},
|
358
|
+
"somefarmparam" =>
|
359
|
+
{
|
331
360
|
value: false,
|
332
361
|
file: 'params/farm/dev.yaml',
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
362
|
+
overriden: false,
|
363
|
+
found_in: [
|
364
|
+
value: false,
|
365
|
+
file: 'params/farm/dev.yaml',
|
366
|
+
]
|
367
|
+
}
|
368
|
+
}
|
369
|
+
}
|
338
370
|
it { expect(node.params).to eq expected }
|
339
371
|
end
|
340
372
|
|
@@ -369,65 +401,81 @@ describe Hieracles::Node do
|
|
369
401
|
basepath: 'spec/files'
|
370
402
|
}
|
371
403
|
}
|
372
|
-
let(:
|
404
|
+
let(:config) { Hieracles::Config.new options }
|
405
|
+
let(:node) { Hieracles::Node.new 'server.example.com', config }
|
406
|
+
|
373
407
|
|
374
408
|
describe '.params' do
|
375
409
|
let(:expected) {
|
376
|
-
|
377
|
-
|
378
|
-
|
410
|
+
{
|
411
|
+
"another.more_sublevel" =>
|
412
|
+
{
|
379
413
|
value: "something",
|
380
414
|
file: 'params/farm/dev.yaml',
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
415
|
+
overriden: false,
|
416
|
+
found_in: [
|
417
|
+
value: "something",
|
418
|
+
file: 'params/farm/dev.yaml'
|
419
|
+
]
|
420
|
+
},
|
421
|
+
"another.sublevel.array" =>
|
422
|
+
{
|
423
|
+
value: ["one", "two", "three", "four", "five"],
|
424
|
+
file: '-',
|
425
|
+
overriden: true,
|
426
|
+
found_in: [
|
427
|
+
{
|
428
|
+
value: ["four", "five"],
|
429
|
+
file: 'params/nodes/server.example.com.yaml'
|
430
|
+
},
|
431
|
+
{
|
432
|
+
value: ["one", "two", "three"],
|
433
|
+
file: 'params/farm/dev.yaml'
|
434
|
+
}
|
435
|
+
]
|
436
|
+
},
|
437
|
+
"another.sublevel.thing" =>
|
438
|
+
{
|
400
439
|
value: "always",
|
401
440
|
file: 'params/nodes/server.example.com.yaml',
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
441
|
+
overriden: false,
|
442
|
+
found_in: [
|
443
|
+
value: "always",
|
444
|
+
file: 'params/nodes/server.example.com.yaml'
|
445
|
+
]
|
446
|
+
},
|
447
|
+
"common_param.subparam" =>
|
448
|
+
{
|
449
|
+
value: "overriden",
|
450
|
+
file: '-',
|
451
|
+
overriden: true,
|
452
|
+
found_in: [
|
453
|
+
{
|
454
|
+
value: "overriden",
|
455
|
+
file: 'params/nodes/server.example.com.yaml'
|
456
|
+
},
|
457
|
+
{
|
458
|
+
value: "override-me",
|
459
|
+
file: 'params/farm/dev.yaml'
|
460
|
+
},
|
461
|
+
]
|
462
|
+
},
|
463
|
+
"somefarmparam" =>
|
464
|
+
{
|
421
465
|
value: false,
|
422
466
|
file: 'params/farm/dev.yaml',
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
467
|
+
overriden: false,
|
468
|
+
found_in: [
|
469
|
+
value: false,
|
470
|
+
file: 'params/farm/dev.yaml',
|
471
|
+
]
|
472
|
+
}
|
473
|
+
}
|
474
|
+
}
|
428
475
|
it { expect(node.params).to eq expected }
|
429
476
|
end
|
430
477
|
|
478
|
+
|
431
479
|
describe '.params_tree' do
|
432
480
|
let(:expected) {
|
433
481
|
{
|
data/spec/lib/registry_spec.rb
CHANGED
@@ -10,13 +10,13 @@ describe Hieracles::Registry do
|
|
10
10
|
basepath: 'spec/files'
|
11
11
|
}
|
12
12
|
end
|
13
|
+
let(:config) { Hieracles::Config.new options }
|
13
14
|
let(:expected) { [
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
it { expect(Hieracles::Registry.farms Hieracles::Config).to eq expected }
|
15
|
+
'dev',
|
16
|
+
'dev2',
|
17
|
+
'dev4'
|
18
|
+
] }
|
19
|
+
it { expect(Hieracles::Registry.farms config).to eq expected }
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '.nodes' do
|
@@ -32,8 +32,8 @@ describe Hieracles::Registry do
|
|
32
32
|
'server3.example.com',
|
33
33
|
'server4.example.com'
|
34
34
|
] }
|
35
|
-
|
36
|
-
it { expect(Hieracles::Registry.nodes
|
35
|
+
let(:config) { Hieracles::Config.new options }
|
36
|
+
it { expect(Hieracles::Registry.nodes config).to eq expected }
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '.modules' do
|
@@ -50,8 +50,8 @@ describe Hieracles::Registry do
|
|
50
50
|
'faux_module1',
|
51
51
|
'faux_module2'
|
52
52
|
] }
|
53
|
-
|
54
|
-
it { expect(Hieracles::Registry.modules
|
53
|
+
let(:config) { Hieracles::Config.new options }
|
54
|
+
it { expect(Hieracles::Registry.modules config).to eq expected }
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hieracles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mose
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|