Skip to content

Commit a7a967b

Browse files
committed
Create a hiera 3 to hiera 5 update
1 parent 02bad72 commit a7a967b

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
:backends:
3+
- yaml
4+
:yaml:
5+
:datadir: /var/lib/puppet/environments/%{::environment}/data
6+
:hierarchy:
7+
- nodes/%{::fqdn}
8+
- common
9+
:merge_behavior: deeper
10+
:logger: console

spec/octocatalog-diff/integration/hiera5_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,56 @@
8080
end
8181
end
8282

83+
# May be used to catalog-diff an upgrade from Hiera 3 to Hiera 5
84+
context 'with --from-hiera-config and --to-hiera-config' do
85+
it 'should succeed in building the catalog and have proper diffs' do
86+
argv = [
87+
'-n', 'rspec-node.github.net',
88+
'--from-hiera-config', 'config/hiera3-global.yaml',
89+
'--from-hiera-path', 'data',
90+
'--to-hiera-config', 'config/hiera5-global.yaml',
91+
'--to-hiera-path-strip', '/var/lib/puppet'
92+
]
93+
hash = {
94+
spec_fact_file: 'facts.yaml',
95+
spec_repo: 'hiera5'
96+
}
97+
result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
98+
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
99+
expect(result.diffs.size).to eq(3)
100+
101+
diff1 = {
102+
diff_type: '~',
103+
type: 'File',
104+
title: '/tmp/special',
105+
structure: %w(parameters content),
106+
old_value: 'Should not be displayed from common',
107+
new_value: 'Greets from special'
108+
}
109+
expect(OctocatalogDiff::Spec.diff_match?(result.diffs, diff1)).to eq(true)
110+
111+
diff2 = {
112+
diff_type: '~',
113+
type: 'File',
114+
title: '/tmp/nodes',
115+
structure: %w(parameters content),
116+
old_value: 'Greets from data/nodes',
117+
new_value: 'Greets from nodes'
118+
}
119+
expect(OctocatalogDiff::Spec.diff_match?(result.diffs, diff2)).to eq(true)
120+
121+
diff3 = {
122+
diff_type: '~',
123+
type: 'File',
124+
title: '/tmp/common',
125+
structure: %w(parameters content),
126+
old_value: 'Greets from data/common',
127+
new_value: 'Greets from common'
128+
}
129+
expect(OctocatalogDiff::Spec.diff_match?(result.diffs, diff3)).to eq(true)
130+
end
131+
end
132+
83133
# May be used to catalog-diff a migration from a global hiera file to an environment level one
84134
context 'with --from-hiera-config' do
85135
it 'should succeed in building the catalog and have proper diffs' do

0 commit comments

Comments
 (0)