dop_common 0.15.0 → 0.15.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 -1
- data/Gemfile +2 -0
- data/lib/dop_common/version.rb +1 -1
- data/lib/hiera/backend/dop_backend.rb +10 -3
- data/spec/fixtures/hiera/hiera.yaml +6 -0
- data/spec/fixtures/simple_plan.yaml +5 -0
- data/spec/hiera/backend/dop_backend_spec.rb +45 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07527d17d603f0e24a7ac08b22e97a4d6b8d68c7
|
4
|
+
data.tar.gz: e3db1d8a02b4a4b8c6ed3ca1f7a5d718d9a3ae3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec7e26b4587ededd9eb60174fb9e81d7e4c4f992a23a4cb0bf96230f6ed048b7008fe53dd73fc0b4cb8f783cdbb78e2eba4862bfab30a8645d94b2399694908d
|
7
|
+
data.tar.gz: a261d97e99b4a56976f1e12bb8eed7044e86798cd358f6fe2d271313eb17c4c5c0d801bc2dc715abf6f2905838350bba9292fc7d65863688b80a6b0d23e3c378
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to dop_common will be documented in this file.
|
3
3
|
|
4
|
-
## [0.15.
|
4
|
+
## [0.15.1]
|
5
|
+
### Fixed
|
6
|
+
- Fix the default plan store path for the hiera plugin and add some more tests
|
7
|
+
|
8
|
+
## [0.15.0] - 2017-05-26
|
5
9
|
### Added
|
6
10
|
- Some small API addition to the log stuff to get the current log file
|
7
11
|
|
data/Gemfile
CHANGED
data/lib/dop_common/version.rb
CHANGED
@@ -19,14 +19,17 @@ class Hiera
|
|
19
19
|
if Config[:dop].kind_of?(Hash)
|
20
20
|
@plan_store_dir ||= Config[:dop][:plan_store_dir]
|
21
21
|
end
|
22
|
-
|
22
|
+
# this is the fixed default path since the puppet master runs with the
|
23
|
+
# puppet user but wants to read from the default dop cache and not from
|
24
|
+
# the user specific one.
|
25
|
+
@plan_store_dir ||= '/var/lib/dop/cache/'
|
23
26
|
|
24
27
|
@plan_store = DopCommon::PlanStore.new(@plan_store_dir)
|
25
28
|
@plan_cache = DopCommon::PlanCache.new(@plan_store)
|
26
29
|
Hiera.debug('DOP Plan Cache Loaded')
|
27
30
|
end
|
28
31
|
|
29
|
-
def lookup(key, scope, order_override, resolution_type, context =
|
32
|
+
def lookup(key, scope, order_override, resolution_type, context = {})
|
30
33
|
node_name = scope['::clientcert']
|
31
34
|
plan = @plan_cache.plan_by_node(node_name)
|
32
35
|
|
@@ -49,7 +52,11 @@ class Hiera
|
|
49
52
|
Hiera.debug("Looking for data source #{source}")
|
50
53
|
begin
|
51
54
|
data = plan.configuration.lookup(source, key, scope)
|
52
|
-
|
55
|
+
if Hiera::Backend.method(:parse_answer).arity == -4
|
56
|
+
new_answer = Hiera::Backend.parse_answer(data, scope, extra_data, context)
|
57
|
+
else
|
58
|
+
new_answer = Hiera::Backend.parse_answer(data, scope, extra_data)
|
59
|
+
end
|
53
60
|
found = true
|
54
61
|
|
55
62
|
case resolution_type.is_a?(Hash) ? :hash : resolution_type
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hiera'
|
3
|
+
require 'hiera/backend/dop_backend'
|
4
|
+
|
5
|
+
describe Hiera::Backend::Dop_backend do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@tmpdir = Dir.mktmpdir
|
9
|
+
@plan_store = DopCommon::PlanStore.new(@tmpdir)
|
10
|
+
@plan_cache = DopCommon::PlanCache.new(@plan_store)
|
11
|
+
@plan_store.add(plan)
|
12
|
+
config = YAML.load_file(hiera_conf)
|
13
|
+
config.merge!({:dop => {:plan_store_dir => @tmpdir}})
|
14
|
+
@hiera = Hiera.new(:config => config)
|
15
|
+
end
|
16
|
+
|
17
|
+
after :each do
|
18
|
+
FileUtils.remove_entry_secure(@tmpdir)
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:hiera_conf) { 'spec/fixtures/hiera/hiera.yaml' }
|
22
|
+
let(:plan) { 'spec/fixtures/simple_plan.yaml' }
|
23
|
+
let(:plan_name) { 'simple_plan' }
|
24
|
+
let(:plan_dir) { File.join(@tmpdir, plan_name) }
|
25
|
+
let(:versions_dir) { File.join(plan_dir, 'versions') }
|
26
|
+
let(:node_name) { 'linux01.example.com' }
|
27
|
+
let(:var) { 'somevar' }
|
28
|
+
let(:scope) { {'::clientcert' => node_name} }
|
29
|
+
|
30
|
+
describe '#lookup' do
|
31
|
+
subject { @hiera.lookup(var, nil, scope) }
|
32
|
+
|
33
|
+
context 'There is a plan in the store with the data' do
|
34
|
+
it { is_expected.to eq('someval') }
|
35
|
+
end
|
36
|
+
|
37
|
+
#context 'val is not set in the plan' do
|
38
|
+
# let(:var) { 'someothervar' }
|
39
|
+
# it { is_expected.to be(nil) }
|
40
|
+
#end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dop_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Zuber
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashdiff
|
@@ -278,6 +278,7 @@ files:
|
|
278
278
|
- spec/example_plans_spec.rb
|
279
279
|
- spec/fixtures/example_ssh_key
|
280
280
|
- spec/fixtures/example_ssh_key.pub
|
281
|
+
- spec/fixtures/hiera/hiera.yaml
|
281
282
|
- spec/fixtures/incl/root_part.yaml
|
282
283
|
- spec/fixtures/incl/some_list.yaml
|
283
284
|
- spec/fixtures/other_plan_same_nodes.yaml
|
@@ -286,6 +287,7 @@ files:
|
|
286
287
|
- spec/fixtures/simple_plan.yaml
|
287
288
|
- spec/fixtures/simple_plan_invalid.yaml
|
288
289
|
- spec/fixtures/simple_plan_modified.yaml
|
290
|
+
- spec/hiera/backend/dop_backend_spec.rb
|
289
291
|
- spec/spec_helper.rb
|
290
292
|
homepage: ''
|
291
293
|
licenses:
|
@@ -342,6 +344,7 @@ test_files:
|
|
342
344
|
- spec/example_plans_spec.rb
|
343
345
|
- spec/fixtures/example_ssh_key
|
344
346
|
- spec/fixtures/example_ssh_key.pub
|
347
|
+
- spec/fixtures/hiera/hiera.yaml
|
345
348
|
- spec/fixtures/incl/root_part.yaml
|
346
349
|
- spec/fixtures/incl/some_list.yaml
|
347
350
|
- spec/fixtures/other_plan_same_nodes.yaml
|
@@ -350,4 +353,5 @@ test_files:
|
|
350
353
|
- spec/fixtures/simple_plan.yaml
|
351
354
|
- spec/fixtures/simple_plan_invalid.yaml
|
352
355
|
- spec/fixtures/simple_plan_modified.yaml
|
356
|
+
- spec/hiera/backend/dop_backend_spec.rb
|
353
357
|
- spec/spec_helper.rb
|