puppet-lint-legacy_facts-check 0.0.3 → 0.0.4
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 +5 -5
- data/lib/puppet-lint/plugins/legacy_facts.rb +2 -2
- data/spec/puppet-lint/plugins/legacy_facts_spec.rb +32 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b882589a54a6bf4e353d926c036211ccd1a354eba43902cef5fa9596978e6be
|
4
|
+
data.tar.gz: 6fd9ce9d4330c000b0e68261522a78770678c544db6c5f35c83547cf5524247b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bac5d13a682d9ba27723624d547a9452df2c6f64fd0b71b3b9ea0250bd31f2e02dcd5cf4766ba99591d0eaa6c9c5d2fc1c8676d53062a0c946c697ea39c2522
|
7
|
+
data.tar.gz: 37782343cfba21ca9105ce72617c2c0ee0ad6513dce8336f1f6b45cb9dda9ae96d5a9cb148bd8a0d5dd4b7923521451a0219f1635c11a531364d11395d022625
|
@@ -8,7 +8,7 @@ PuppetLint.new_check(:legacy_facts) do
|
|
8
8
|
/^(?<attribute>ipaddress|ipaddress6|macaddress|mtu|netmask|netmask6|network|network6)_(?<interface>.*)$/,
|
9
9
|
/^processor(?<id>[0-9]+)$/,
|
10
10
|
/^sp_(?<name>.*)$/,
|
11
|
-
/^ssh(?<algorithm
|
11
|
+
/^ssh(?<algorithm>dsa|ecdsa|ed25519|rsa)key$/,
|
12
12
|
/^ldom_(?<name>.*)$/,
|
13
13
|
/^zone_(?<name>.*)_(?<attribute>brand|iptype|name|uuid|id|path|status)$/]
|
14
14
|
|
@@ -118,7 +118,7 @@ PuppetLint.new_check(:legacy_facts) do
|
|
118
118
|
problem[:token].value = "facts['processors']['models'][" << m['id'] << "]"
|
119
119
|
elsif m = fact_name.match(/^sp_(?<name>.*)$/)
|
120
120
|
problem[:token].value = "facts['system_profiler']['" << m['name'] << "']"
|
121
|
-
elsif m = fact_name.match(/^ssh(?<algorithm
|
121
|
+
elsif m = fact_name.match(/^ssh(?<algorithm>dsa|ecdsa|ed25519|rsa)key$/)
|
122
122
|
problem[:token].value = "facts['ssh']['" << m['algorithm'] << "']['key']"
|
123
123
|
elsif m = fact_name.match(/^ldom_(?<name>.*)$/)
|
124
124
|
problem[:token].value = "facts['ldom']['" << m['name'] << "']"
|
@@ -11,6 +11,14 @@ describe 'legacy_facts' do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
context "fact variable using modern $facts['ssh']['rsa']['key'] hash" do
|
15
|
+
let(:code) { "$facts['ssh']['rsa']['key']" }
|
16
|
+
|
17
|
+
it 'should not detect any problems' do
|
18
|
+
expect(problems).to have(0).problem
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
context "fact variable using legacy $osfamily" do
|
15
23
|
let(:code) { "$osfamily" }
|
16
24
|
|
@@ -102,6 +110,14 @@ describe 'legacy_facts' do
|
|
102
110
|
end
|
103
111
|
end
|
104
112
|
|
113
|
+
context "fact variable using modern $facts['ssh']['rsa']['key'] hash" do
|
114
|
+
let(:code) { "$facts['ssh']['rsa']['key']" }
|
115
|
+
|
116
|
+
it 'should not detect any problems' do
|
117
|
+
expect(problems).to have(0).problem
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
105
121
|
context "fact variable using legacy $osfamily" do
|
106
122
|
let(:code) { "$osfamily" }
|
107
123
|
|
@@ -142,6 +158,22 @@ describe 'legacy_facts' do
|
|
142
158
|
end
|
143
159
|
end
|
144
160
|
|
161
|
+
context "fact variable using legacy $::sshrsakey" do
|
162
|
+
let(:code) { "$::sshrsakey" }
|
163
|
+
|
164
|
+
it 'should only detect a single problem' do
|
165
|
+
expect(problems).to have(1).problem
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should fix the problem' do
|
169
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(1)
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'should use the facts hash' do
|
173
|
+
expect(manifest).to eq("$facts['ssh']['rsa']['key']")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
145
177
|
context "fact variable using legacy $::memoryfree_mb" do
|
146
178
|
let(:code) { "$::memoryfree_mb" }
|
147
179
|
|
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
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark McKinstry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: |2
|
98
112
|
A pupet-lint to check you are not using legacy facts like `$::operatingsystem`
|
99
113
|
or `$facts['operatingsystem']`. You should use the new structured facts like
|
@@ -128,10 +142,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
142
|
version: '0'
|
129
143
|
requirements: []
|
130
144
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.7.8
|
132
146
|
signing_key:
|
133
147
|
specification_version: 4
|
134
148
|
summary: A puppet-lint plugin to check you are not using legacy facts like $::operatingsystem
|
135
149
|
test_files:
|
136
|
-
- spec/puppet-lint/plugins/legacy_facts_spec.rb
|
137
150
|
- spec/spec_helper.rb
|
151
|
+
- spec/puppet-lint/plugins/legacy_facts_spec.rb
|