puppet-lint-nine-check 0.5.0 → 0.6.0

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
2
  SHA256:
3
- metadata.gz: c4708a12e4b0252d046a69e52f62ca9296daab1e6f0d356a16f712df5d56df5b
4
- data.tar.gz: a903c154bc715a5dfd8c21a77eccff6ceb2baaeeaf4412a794d4b6bcea83bf44
3
+ metadata.gz: 6b17f0f00ef8f387090bb661db7760091cd2d0c2f59ac1d4b99f2c76e59f86f3
4
+ data.tar.gz: 8067c71c2f9e97e19f16dd3ed0baa7e58216148a5ad6ef131d218f965b0b2f4c
5
5
  SHA512:
6
- metadata.gz: b56ffb029e88553a11a87a9c4f819cb54e985dc19e62e50032f4c5b8c2ab5efce592073405a809ed53d153aa26087fb67bb3e0553789256b16facf196cf33fee
7
- data.tar.gz: 677c848e83b23cbc1b2488e922b75a6471e31145a9ac6c7961be63442369cfba9bc3308d8a8b387df76048f5dac936b380fa3305ad885ab719903d947ec87d57
6
+ metadata.gz: b7fac1f845f03de996108428233bc2e349daeba55e2e1450923013da4c23620e391ba953116a96fcf06025d168d8ab3ba706b781f2737684ab6500ba89b5901e
7
+ data.tar.gz: 2ecefee96e6c970a9d9328bc5565179f4ed3a4fa757ab4103d373fd96b66219b51a20bb9d224129056894b0d009ae12136dfb7fb9429d96a8ecd11d9d1a22507
@@ -0,0 +1,53 @@
1
+ # https://github.com/deanwilson/puppet-lint-absolute_template_path-check/blob/fa2d1e9a75e566c483b62ea7ff5df0bb9756ad8a/lib/puppet-lint/plugins/absolute_template_path.rb
2
+ #
3
+ # The MIT License (MIT)
4
+ #
5
+ # Copyright (c) 2014 Dean Wilson
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ PuppetLint.new_check(:absolute_template_path) do
26
+ def check
27
+ resource_indexes.each do |resource|
28
+ next unless resource[:type].value == "file"
29
+
30
+ content_tokens = resource[:param_tokens].select { |pt| pt.value == "content" }
31
+
32
+ content_tokens.each do |content_token|
33
+ value_token = content_token.next_code_token.next_code_token
34
+
35
+ next unless value_token.value.start_with? "template"
36
+
37
+ template_path = value_token.next_code_token.next_code_token.value
38
+
39
+ next unless template_path.start_with? "/" # skip relative paths
40
+
41
+ # if we made it here it's a file resource with a template parameter
42
+ # that begins with an absolute path, so raise a lint issue for it.
43
+ notify :warning, {
44
+ message: "template module paths should be relative, not absolute",
45
+ line: value_token.line,
46
+ column: value_token.column,
47
+ param_token: content_token,
48
+ value_token: value_token
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,77 @@
1
+ require "spec_helper"
2
+
3
+ describe "absolute_template_path" do
4
+ let(:msg) { "template module paths should be relative, not absolute" }
5
+
6
+ context "when the manifest has no file resources" do
7
+ let(:code) do
8
+ <<-TEST_CLASS
9
+ class no_file_resource {
10
+ host { "syslog":
11
+ ip => "10.10.10.10",
12
+ }
13
+ }
14
+ TEST_CLASS
15
+ end
16
+
17
+ it "does not detect any problems" do
18
+ expect(problems.size).to eq(0)
19
+ end
20
+ end
21
+
22
+ context "with file resource but no template call" do
23
+ context "when the template has a relative module path" do
24
+ let(:code) do
25
+ <<-TEST_CLASS
26
+ class template_tester {
27
+ file { "/tmp/template":
28
+ content => "A static string",
29
+ }
30
+ }
31
+ TEST_CLASS
32
+ end
33
+
34
+ it "detects no problems" do
35
+ expect(problems.size).to eq(0)
36
+ end
37
+ end
38
+ end
39
+
40
+ context "with fix disabled" do
41
+ context "when the template has a relative module path" do
42
+ let(:code) do
43
+ <<-TEST_CLASS
44
+ class template_tester {
45
+ file { "/tmp/template":
46
+ content => template("example/template.erb"),
47
+ }
48
+ }
49
+ TEST_CLASS
50
+ end
51
+
52
+ it "detects no problems" do
53
+ expect(problems.size).to eq(0)
54
+ end
55
+ end
56
+
57
+ context "when the template has an absolute module path" do
58
+ let(:code) do
59
+ <<-TEST_CLASS
60
+ class template_tester {
61
+ file { "/tmp/template":
62
+ content => template("/etc/puppet/modules/example/template.erb"),
63
+ }
64
+ }
65
+ TEST_CLASS
66
+ end
67
+
68
+ it "detects a single problem" do
69
+ expect(problems.size).to eq(1)
70
+ end
71
+
72
+ it "creates a warning" do
73
+ expect(problems).to contain_warning(msg).on_line(3).in_column(26)
74
+ end
75
+ end
76
+ end
77
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-nine-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nine Internet Solutions AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-25 00:00:00.000000000 Z
11
+ date: 2026-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
@@ -131,6 +131,7 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - LICENSE
133
133
  - README.md
134
+ - lib/puppet-lint/plugins/absolute_template_path.rb
134
135
  - lib/puppet-lint/plugins/class_alignment.rb
135
136
  - lib/puppet-lint/plugins/class_alignment/helper.rb
136
137
  - lib/puppet-lint/plugins/class_alignment_params_newline.rb
@@ -141,6 +142,7 @@ files:
141
142
  - lib/puppet-lint/plugins/template_file_extension.rb
142
143
  - lib/puppet-lint/plugins/trailing_newline.rb
143
144
  - lib/puppet-lint/plugins/world_writable_files.rb
145
+ - spec/puppet-lint/plugins/absolute_template_path_spec.rb
144
146
  - spec/puppet-lint/plugins/class_alignment_equals_spec.rb
145
147
  - spec/puppet-lint/plugins/class_alignment_params_newline_spec.rb
146
148
  - spec/puppet-lint/plugins/class_alignment_params_spec.rb