puppet-runner 0.0.26 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 9608033a0b9eb159ab03971282ba58f6f66048dca66b7dd010d6ba8eeb19a8c1
4
- data.tar.gz: 10fa57c840b21b088c9e36c6d4415de4c90f260da7aacf4a9afb50bde6c8d420
2
+ SHA1:
3
+ metadata.gz: 0f8efcfb59ec97544f71bd48cef975038d26309d
4
+ data.tar.gz: c79062ae1be29f79cde741a014b8a66997ed1504
5
5
  SHA512:
6
- metadata.gz: 0b5a94a383db7ed9236316a79ec462af20e4de9d71d023342d44ec4dedb52bfb99d5a3f5fd7c78f9e41a488cfbfe1652c7a8809bc9ab59affe57fe90c619e9d8
7
- data.tar.gz: 87767da63ef9b57dd99de76bf5946e258be53c8f62d3d5502b4c14b0007de762625f401f7bfe2afede26346ef5c1c53f461fb73411ecf4814dcf8c9442bd9f14
6
+ metadata.gz: 9968eaf857daa85f81af9cd69bd76095a0845888787af4298383e6ed466d91c75d6d7e6e499ac56360d5d181d0daf8a0e121d9d8cafa7735b27b5c4d7f38eacd
7
+ data.tar.gz: c3d6892856cda4d15562deac8c53396694472185b8c2d17bdb9b8ea8a87c74026ffc28aa4546d679ffad2467826d398edb89fb557d948e497db010123177c7b7
data/bin/puppet-runner CHANGED
@@ -118,7 +118,7 @@ def extract_type_from_hash(input)
118
118
  end
119
119
 
120
120
  # function to resolve inter fact references, it should return the last fact name (not value)
121
- def resolve_fact(fact_name, max_depth=5, current_depth=0)
121
+ def resolve_fact(fact_name, max_depth=5, current_depth=0, return_fact_value=false)
122
122
  final_val = nil
123
123
  fact_name = fact_name.sub(/%{::/,'').sub(/}/,'')
124
124
  if max_depth == current_depth
@@ -132,7 +132,8 @@ def resolve_fact(fact_name, max_depth=5, current_depth=0)
132
132
  elsif val.instance_of?(String) and val.match(/%{::.*.}/)
133
133
  val = resolve_fact(val,max_depth, current_depth + 1)
134
134
  else
135
- val = "%{::#{fact_name}}"
135
+ # if we have not been told to return the fact value, then return the fact key, else the value wil be returned
136
+ val = "%{::#{fact_name}}" if return_fact_value == false
136
137
  end
137
138
  final_val = val
138
139
  end
@@ -333,8 +334,17 @@ if options['all'] || options['prepare']
333
334
  # find each instance of a fact within the value (it may contain multiple facts
334
335
  # i.e "TEST%{::fact1}TEST%{::fact2}"
335
336
  fact_val.gsub(/}/,"}\n").scan(/%{::.*.}/).each do | fact |
336
- # resolve the fact down to its last reference to another fact (not the end value)
337
- resolved_fact = resolve_fact(fact)
337
+ # if the fact is part of a larger string set a flag to tell resolve_fact
338
+ # to return the final fact value instead of the finalfact key!
339
+ if fact.length != fact_val.length
340
+ return_fact_value = true
341
+ else
342
+ return_fact_value = false
343
+ end
344
+
345
+ # resolve the fact down to its last reference to another fact (not the end value) if return_fact_value is false
346
+ # or down to the end value if return_fact_value is true
347
+ resolved_fact = resolve_fact(fact, 5, 0, return_fact_value)
338
348
  # if the resolved fact name is not the same as the original fact we found referenced
339
349
  # then replace the value in fact_val
340
350
  if !resolved_fact.nil? and resolved_fact != fact
@@ -344,7 +354,7 @@ if options['all'] || options['prepare']
344
354
  debug "Attempting to replace fact '#{fact_key}' with value '#{fact_val}' in compiled template"
345
355
  # replace the original fact reference in the template with the resovled value
346
356
  # this is done before global teansformation as they may change the final value again
347
- result_template = result_template.gsub(/\"\%{::#{fact_key}}\"/, "\"#{fact_val}\"")
357
+ result_template = result_template.gsub(/\%{::#{fact_key}}/, "#{fact_val}")
348
358
  end
349
359
  end
350
360
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "puppet-runner"
7
- spec.version = "0.0.26"
7
+ spec.version = "0.0.27"
8
8
  spec.authors = ["Martin Brehovsky", "Matthew Hope"]
9
9
  spec.email = ["mbrehovsky@adaptavist.com"]
10
10
  spec.summary = %q{Preprocessor for hiera config}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Brehovsky
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-05-25 00:00:00.000000000 Z
12
+ date: 2022-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -172,7 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  requirements: []
175
- rubygems_version: 3.0.8
175
+ rubyforge_project:
176
+ rubygems_version: 2.6.8
176
177
  signing_key:
177
178
  specification_version: 4
178
179
  summary: Preprocessor for hiera config