puppet-lint-legacy_facts-check 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b882589a54a6bf4e353d926c036211ccd1a354eba43902cef5fa9596978e6be
4
- data.tar.gz: 6fd9ce9d4330c000b0e68261522a78770678c544db6c5f35c83547cf5524247b
3
+ metadata.gz: 90c39fb6507da85f5d4bcd1d17587a2bdfb210fe0519c614cc2832bd04d5fda4
4
+ data.tar.gz: 6312725c235f5e05212b5897b47a327557e40d6a674317dacda10c4fdd7c094a
5
5
  SHA512:
6
- metadata.gz: 1bac5d13a682d9ba27723624d547a9452df2c6f64fd0b71b3b9ea0250bd31f2e02dcd5cf4766ba99591d0eaa6c9c5d2fc1c8676d53062a0c946c697ea39c2522
7
- data.tar.gz: 37782343cfba21ca9105ce72617c2c0ee0ad6513dce8336f1f6b45cb9dda9ae96d5a9cb148bd8a0d5dd4b7923521451a0219f1635c11a531364d11395d022625
6
+ metadata.gz: fb8cecf281e0eb2d27fe46b29de3812c4ad89ef36498cb416ef3c536cd6acaeb4e8d8a7974c3d49e26264d7c610b1d61e735bc848b507251f039780926f94b6a
7
+ data.tar.gz: 8797b37fef673e69b04d139f2e2fb93d53d80706b60591e41e114091bd41adfc6b8b74989c8c9b05fffe1bcdf87b2ad6b6b3e542ada20f053ed513d6fd6d1427
@@ -102,6 +102,9 @@ PuppetLint.new_check(:legacy_facts) do
102
102
  end
103
103
 
104
104
  def fix(problem)
105
+ # This probably should never occur, but if it does then bail out:
106
+ raise PuppetLint::NoFix if problem[:token].raw and problem[:token].value != problem[:token].raw
107
+
105
108
  if problem[:token].value.start_with?('::') then
106
109
  fact_name = problem[:token].value.sub(/^::/, '')
107
110
  elsif problem[:token].value.start_with?("facts['") then
@@ -126,5 +129,7 @@ PuppetLint.new_check(:legacy_facts) do
126
129
  problem[:token].value = "facts['solaris_zones']['zones']['" << m['name'] << "']['" << m['attribute'] << "']"
127
130
  end
128
131
  end
132
+
133
+ problem[:token].raw = problem[:token].value unless problem[:token].raw.nil?
129
134
  end
130
135
  end
@@ -90,6 +90,14 @@ describe 'legacy_facts' do
90
90
  expect(problems).to have(1).problem
91
91
  end
92
92
  end
93
+
94
+ context "fact variable in interpolated string \"${::osfamily}\"" do
95
+ let(:code) { '"start ${::osfamily} end"' }
96
+
97
+ it 'should only detect a single problem' do
98
+ expect(problems).to have(1).problem
99
+ end
100
+ end
93
101
  end
94
102
 
95
103
 
@@ -251,5 +259,17 @@ describe 'legacy_facts' do
251
259
  expect(manifest).to eq("$facts['ssh']['rsa']['key']")
252
260
  end
253
261
  end
262
+
263
+ context "fact variable in interpolated string \"${::osfamily}\"" do
264
+ let(:code) { '"start ${::osfamily} end"' }
265
+
266
+ it 'should only detect a single problem' do
267
+ expect(problems).to have(1).problem
268
+ end
269
+
270
+ it 'should use the facts hash' do
271
+ expect(manifest).to eq('"start '"${facts['os']['family']}"' end"')
272
+ end
273
+ end
254
274
  end
255
275
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-legacy_facts-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark McKinstry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-12 00:00:00.000000000 Z
11
+ date: 2018-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint