puppet-syntax 4.1.1 → 5.0.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: a9f7f1ca6475068159902b6dbe227d6ac486336d2fc2ad1c8b00e38b71082597
4
- data.tar.gz: 725e830cc518515bf10605391de65a324eb7caafc38c37f32f252cafe1f18ace
3
+ metadata.gz: fa1f289751fd476cf68888ea7332859a070fd13da470cb62e1d3c71d8afc1291
4
+ data.tar.gz: 44a4d1f9652ef9b40d1ee6318321073d2a46d393aa4b043aa4bab225db542a2f
5
5
  SHA512:
6
- metadata.gz: a677df82c7a0a758a8184bb8158a422105be48f9552d21bec36f9c1f5f0e67380559318f3dbc6dda464ea18d9e8ed4b515ac68416220bcaf826e2816790f98cf
7
- data.tar.gz: 6f9849ab4f2f99ab59f0dbdcff21b31e8c76e0bdc8920c8cf0edabe2d4882e07d4f29e7cdd6b8a4a32e8539b19a7a1b6b4cfa8002e666835ba92ac0358110eb2
6
+ metadata.gz: eb28b604491202ead9128626b736462b5aa16761fce9437f45e3d890aecfdaf6737c3d4b823c14864c84b07f425ab642859408dd210fb31d91f81ed6e38db9c8
7
+ data.tar.gz: 8830caf03c537c2a229a2686ea5fbfe729d6a73525d1078a27f0b1c0317d13bc81802415ffd3004fa9486486d9df2d9c52bf0d5f941079a83b43a0b30632c76c
@@ -9,10 +9,12 @@ env:
9
9
  BUNDLE_WITHOUT: development:release
10
10
 
11
11
  jobs:
12
- rubocop:
12
+ rubocop_and_matrix:
13
13
  env:
14
14
  BUNDLE_WITHOUT: release
15
- runs-on: ubuntu-latest
15
+ runs-on: ubuntu-24.04
16
+ outputs:
17
+ ruby: ${{ steps.ruby.outputs.versions }}
16
18
  steps:
17
19
  - uses: actions/checkout@v4
18
20
  - name: Install Ruby ${{ matrix.ruby }}
@@ -22,16 +24,16 @@ jobs:
22
24
  bundler-cache: true
23
25
  - name: Run Rubocop
24
26
  run: bundle exec rake rubocop
27
+ - id: ruby
28
+ uses: voxpupuli/ruby-version@v1
29
+
25
30
  test:
26
31
  runs-on: ubuntu-latest
32
+ needs: rubocop_and_matrix
27
33
  strategy:
28
34
  fail-fast: false
29
35
  matrix:
30
- ruby:
31
- - "3.2"
32
- - "3.1"
33
- - "3.0"
34
- - "2.7"
36
+ ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
35
37
  puppet:
36
38
  - "~> 8.0"
37
39
  - "~> 7.0"
@@ -62,7 +64,7 @@ jobs:
62
64
 
63
65
  tests:
64
66
  needs:
65
- - rubocop
67
+ - rubocop_and_matrix
66
68
  - test
67
69
  runs-on: ubuntu-latest
68
70
  name: Test suite
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-03-08 16:09:27 UTC using RuboCop version 1.61.0.
3
+ # on 2025-05-09 08:19:08 UTC using RuboCop version 1.67.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -29,19 +29,13 @@ Lint/SuppressedException:
29
29
  Exclude:
30
30
  - 'Rakefile'
31
31
 
32
- # Offense count: 1
33
- # This cop supports unsafe autocorrection (--autocorrect-all).
34
- # Configuration parameters: AutoCorrect.
35
- Lint/UselessAssignment:
36
- Exclude:
37
- - 'lib/puppet-syntax/templates.rb'
38
-
39
32
  # Offense count: 4
40
33
  # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
41
34
  # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
42
35
  # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
43
36
  Naming/FileName:
44
37
  Exclude:
38
+ - 'Rakefile.rb'
45
39
  - 'lib/puppet-syntax.rb'
46
40
  - 'lib/puppet-syntax/tasks/puppet-syntax.rb'
47
41
  - 'spec/puppet-syntax/tasks/puppet-syntax_spec.rb'
@@ -88,16 +82,6 @@ RSpec/DescribedClass:
88
82
  RSpec/ExampleLength:
89
83
  Max: 17
90
84
 
91
- # Offense count: 4
92
- # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
93
- # Include: **/*_spec*rb*, **/spec/**/*
94
- RSpec/FilePath:
95
- Exclude:
96
- - 'spec/puppet-syntax/hiera_spec.rb'
97
- - 'spec/puppet-syntax/manifests_spec.rb'
98
- - 'spec/puppet-syntax/templates_spec.rb'
99
- - 'spec/puppet-syntax_spec.rb'
100
-
101
85
  # Offense count: 29
102
86
  RSpec/MultipleExpectations:
103
87
  Max: 11
@@ -134,12 +118,6 @@ RSpec/SubjectDeclaration:
134
118
  - 'spec/puppet-syntax/manifests_spec.rb'
135
119
  - 'spec/puppet-syntax/templates_spec.rb'
136
120
 
137
- # Offense count: 1
138
- # This cop supports safe autocorrection (--autocorrect).
139
- Rake/Desc:
140
- Exclude:
141
- - 'Rakefile'
142
-
143
121
  # Offense count: 1
144
122
  # This cop supports unsafe autocorrection (--autocorrect-all).
145
123
  # Configuration parameters: EnforcedStyle.
@@ -244,7 +222,7 @@ Style/SymbolProc:
244
222
  - 'lib/puppet-syntax/manifests.rb'
245
223
  - 'lib/puppet-syntax/templates.rb'
246
224
 
247
- # Offense count: 3
225
+ # Offense count: 4
248
226
  # This cop supports safe autocorrection (--autocorrect).
249
227
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
250
228
  # URISchemes: http, https
data/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [v5.0.0](https://github.com/voxpupuli/puppet-syntax/tree/v5.0.0) (2025-05-23)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v4.1.1...v5.0.0)
8
+
9
+ **Breaking changes:**
10
+
11
+ - Set default exclude paths [\#181](https://github.com/voxpupuli/puppet-syntax/pull/181) ([bastelfreak](https://github.com/bastelfreak))
12
+ - Enable Hiera syntax check [\#167](https://github.com/voxpupuli/puppet-syntax/pull/167) ([bastelfreak](https://github.com/bastelfreak))
13
+
14
+ **Implemented enhancements:**
15
+
16
+ - Detect Hiera files that are not valid hashes [\#184](https://github.com/voxpupuli/puppet-syntax/pull/184) ([bastelfreak](https://github.com/bastelfreak))
17
+ - CI: Switch to voxpupuli/ruby-version@v1 & Add Ruby 3.4 support [\#180](https://github.com/voxpupuli/puppet-syntax/pull/180) ([bastelfreak](https://github.com/bastelfreak))
18
+
19
+ **Merged pull requests:**
20
+
21
+ - Drop unused pry & rb-readline dev dependencies [\#182](https://github.com/voxpupuli/puppet-syntax/pull/182) ([bastelfreak](https://github.com/bastelfreak))
22
+ - Cleanup Rakefile; remove legacy tasks [\#173](https://github.com/voxpupuli/puppet-syntax/pull/173) ([bastelfreak](https://github.com/bastelfreak))
23
+
5
24
  ## [v4.1.1](https://github.com/voxpupuli/puppet-syntax/tree/v4.1.1) (2024-04-04)
6
25
 
7
26
  [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v4.1.0...v4.1.1)
data/Gemfile CHANGED
@@ -20,6 +20,11 @@ gemspec
20
20
  # Override gemspec for CI matrix builds.
21
21
  # But only if the environment variable is set
22
22
  gem 'puppet', *location_for(ENV['PUPPET_VERSION']) if ENV['PUPPET_VERSION']
23
+ # Puppet on Ruby 3.3 / 3.4 has some missing dependencies
24
+ gem 'base64', '~> 0.2' if RUBY_VERSION >= '3.4'
25
+ gem 'getoptlong', '~> 0.2' if RUBY_VERSION >= '3.4'
26
+ gem 'racc', '~> 1.8' if RUBY_VERSION >= '3.3'
27
+ gem 'syslog', '~> 0.3' if RUBY_VERSION >= '3.4'
23
28
 
24
29
  group :test do
25
30
  gem 'rspec'
data/Rakefile CHANGED
@@ -1,12 +1,6 @@
1
1
  require 'rspec/core/rake_task'
2
2
  RSpec::Core::RakeTask.new('spec')
3
3
 
4
- task :publish_gem do
5
- require 'gem_publisher'
6
- gem = GemPublisher.publish_if_updated('puppet-syntax.gemspec', :rubygems)
7
- puts "Published #{gem}" if gem
8
- end
9
-
10
4
  task default: [:spec]
11
5
  begin
12
6
  require 'github_changelog_generator/task'
@@ -23,12 +17,7 @@ rescue LoadError
23
17
  end
24
18
 
25
19
  begin
26
- require 'rubocop/rake_task'
20
+ require 'voxpupuli/rubocop/rake'
27
21
  rescue LoadError
28
- # RuboCop is an optional group
29
- else
30
- RuboCop::RakeTask.new(:rubocop) do |task|
31
- # These make the rubocop experience maybe slightly less terrible
32
- task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
33
- end
22
+ # the voxpupuli-rubocop gem is optional
34
23
  end
@@ -92,6 +92,11 @@ module PuppetSyntax
92
92
  end
93
93
  next unless yamldata
94
94
 
95
+ unless yamldata.is_a?(Hash)
96
+ errors << "ERROR: #{hiera_file} doesn't contain a valid Hash, datatype is #{yamldata.class}"
97
+ next
98
+ end
99
+
95
100
  yamldata.each do |k, v|
96
101
  if PuppetSyntax.check_hiera_keys
97
102
  key_msg = check_hiera_key(k)
@@ -69,14 +69,10 @@ module PuppetSyntax
69
69
 
70
70
  begin
71
71
  template = File.read(filename)
72
- erb = if RUBY_VERSION >= '2.6'
73
- ERB.new(template, trim_mode: '-')
74
- else
75
- ERB.new(template, trim_mode: '-')
76
- end
72
+ erb = ERB.new(template, trim_mode: '-')
77
73
  erb.filename = filename
78
74
  erb.result
79
- rescue NameError => e
75
+ rescue NameError
80
76
  # This is normal because we don't have the variables that would
81
77
  # ordinarily be bound by the parent Puppet manifest.
82
78
  rescue TypeError
@@ -1,3 +1,3 @@
1
1
  module PuppetSyntax
2
- VERSION = '4.1.1'
2
+ VERSION = '5.0.0'
3
3
  end
data/lib/puppet-syntax.rb CHANGED
@@ -5,7 +5,12 @@ module PuppetSyntax
5
5
  autoload :Manifests, 'puppet-syntax/manifests'
6
6
  autoload :Templates, 'puppet-syntax/templates'
7
7
 
8
- @exclude_paths = []
8
+ @exclude_paths = [
9
+ 'spec/fixtures/**/*',
10
+ 'pkg/**/*',
11
+ 'vendor/**/*',
12
+ '.vendor/**/*',
13
+ ]
9
14
  @hieradata_paths = [
10
15
  '**/data/**/*.*{yaml,yml}',
11
16
  'hieradata/**/*.*{yaml,yml}',
@@ -19,8 +24,8 @@ module PuppetSyntax
19
24
  '**/templates/**/*.epp',
20
25
  ]
21
26
  @fail_on_deprecation_notices = true
22
- @check_hiera_keys = false
23
- @check_hiera_data = false
27
+ @check_hiera_keys = true
28
+ @check_hiera_data = true
24
29
 
25
30
  class << self
26
31
  attr_accessor :exclude_paths,
@@ -21,8 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'puppet', '>= 7', '< 9'
22
22
  spec.add_dependency 'rake', '~> 13.1'
23
23
 
24
- spec.add_development_dependency 'pry', '~> 0.14.2'
25
- spec.add_development_dependency 'rb-readline', '~> 0.5.5'
26
-
27
- spec.add_development_dependency 'voxpupuli-rubocop', '~> 2.6.0'
24
+ spec.add_development_dependency 'voxpupuli-rubocop', '~> 3.1.0'
28
25
  end
@@ -0,0 +1,2 @@
1
+ prometheus::initstyle:sysv
2
+ prometheus::node_exporter::init_style:sysv
@@ -1,3 +1,3 @@
1
1
  This is plain text
2
- <% This is not valid Ruby %>
2
+ <% This is not valid Ruby( %>
3
3
  This is also plain text
@@ -21,6 +21,14 @@ describe PuppetSyntax::Hiera do
21
21
  expect(res.first).to match(expected)
22
22
  end
23
23
 
24
+ it 'returns warnings on malformed keys' do
25
+ files = fixture_hiera('hiera_key_no_value.yaml')
26
+ expected = /ERROR: #{files[0]} doesn't contain a valid Hash, datatype is/
27
+ res = subject.check(files)
28
+ expect(res.size).to eq 1
29
+ expect(res.first).to match(expected)
30
+ end
31
+
24
32
  context 'check_hiera_keys = true' do
25
33
  before do
26
34
  PuppetSyntax.check_hiera_keys = true
@@ -9,30 +9,45 @@ known_yaml_subdir = 'spec/fixtures/hiera/data/test/hiera_3.yaml'
9
9
  known_eyaml_subdir = 'spec/fixtures/hiera/data/test/hiera_4.eyaml'
10
10
 
11
11
  describe 'PuppetSyntax rake tasks' do
12
- it 'filters directories' do
13
- list = PuppetSyntax::RakeTask.new.filelist(['**/lib', known_pp])
14
- expect(list.count).to eq 1
15
- expect(list).to include(known_pp)
12
+ describe 'with default excludes' do
13
+ it 'filters directories' do
14
+ list = PuppetSyntax::RakeTask.new.filelist(['**/lib', known_pp])
15
+ expect(list.count).to eq 0
16
+ expect(list).not_to include(known_pp)
17
+ end
16
18
  end
17
19
 
18
- it 'generates FileList of manifests relative to Rakefile' do
19
- list = PuppetSyntax::RakeTask.new.filelist_manifests
20
- expect(list).to include(known_pp)
21
- expect(list.count).to eq 9
22
- end
20
+ describe 'with custom excludes' do
21
+ before do
22
+ list = PuppetSyntax.exclude_paths
23
+ PuppetSyntax.exclude_paths = list - ['spec/fixtures/**/*']
24
+ end
23
25
 
24
- it 'generates FileList of templates relative to Rakefile' do
25
- list = PuppetSyntax::RakeTask.new.filelist_templates
26
- expect(list).to include(known_erb)
27
- expect(list.count).to eq 9
28
- end
26
+ it 'filters directories' do
27
+ list = PuppetSyntax::RakeTask.new.filelist(['**/lib', known_pp])
28
+ expect(list.count).to eq 1
29
+ expect(list).to include(known_pp)
30
+ end
31
+
32
+ it 'generates FileList of manifests relative to Rakefile' do
33
+ list = PuppetSyntax::RakeTask.new.filelist_manifests
34
+ expect(list).to include(known_pp)
35
+ expect(list.count).to eq 9
36
+ end
37
+
38
+ it 'generates FileList of templates relative to Rakefile' do
39
+ list = PuppetSyntax::RakeTask.new.filelist_templates
40
+ expect(list).to include(known_erb)
41
+ expect(list.count).to eq 9
42
+ end
29
43
 
30
- it 'generates FileList of Hiera yaml files relative to Rakefile' do
31
- list = PuppetSyntax::RakeTask.new.filelist_hiera_yaml
32
- expect(list).to include(known_yaml)
33
- expect(list).to include(known_eyaml)
34
- expect(list).to include(known_yaml_subdir)
35
- expect(list).to include(known_eyaml_subdir)
36
- expect(list.count).to eq 4
44
+ it 'generates FileList of Hiera yaml files relative to Rakefile' do
45
+ list = PuppetSyntax::RakeTask.new.filelist_hiera_yaml
46
+ expect(list).to include(known_yaml)
47
+ expect(list).to include(known_eyaml)
48
+ expect(list).to include(known_yaml_subdir)
49
+ expect(list).to include(known_eyaml_subdir)
50
+ expect(list.count).to eq 4
51
+ end
37
52
  end
38
53
  end
@@ -3,11 +3,8 @@ require 'spec_helper'
3
3
  describe PuppetSyntax::Templates do
4
4
  let(:subject) { PuppetSyntax::Templates.new }
5
5
  let(:conditional_warning_regex) do
6
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
7
- /2: warning: found `= literal' in conditional/
8
- else
9
- /2: warning: found = in conditional/
10
- end
6
+ # ruby 3.4 uses '= ,ruby 2.6 to 3.3 uses `=
7
+ /2: warning: found [`']= literal' in conditional/
11
8
  end
12
9
 
13
10
  it 'expects an array of files' do
@@ -35,7 +32,7 @@ describe PuppetSyntax::Templates do
35
32
  res = subject.check(files)
36
33
 
37
34
  expect(res[:errors].size).to eq(1)
38
- expect(res[:errors][0]).to match(/2: syntax error, unexpected/)
35
+ expect(res[:errors][0]).to match(/2: syntax error/)
39
36
  end
40
37
 
41
38
  it 'catches Ruby warnings' do
@@ -60,7 +57,7 @@ describe PuppetSyntax::Templates do
60
57
 
61
58
  expect(res[:warnings].size).to eq(1)
62
59
  expect(res[:errors].size).to eq(1)
63
- expect(res[:errors][0]).to match(/2: syntax error, unexpected/)
60
+ expect(res[:errors][0]).to match(/2: syntax error/)
64
61
  expect(res[:warnings][0]).to match(conditional_warning_regex)
65
62
  end
66
63
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-syntax
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-04 00:00:00.000000000 Z
11
+ date: 2025-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -44,48 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '13.1'
47
- - !ruby/object:Gem::Dependency
48
- name: pry
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: 0.14.2
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: 0.14.2
61
- - !ruby/object:Gem::Dependency
62
- name: rb-readline
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: 0.5.5
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: 0.5.5
75
47
  - !ruby/object:Gem::Dependency
76
48
  name: voxpupuli-rubocop
77
49
  requirement: !ruby/object:Gem::Requirement
78
50
  requirements:
79
51
  - - "~>"
80
52
  - !ruby/object:Gem::Version
81
- version: 2.6.0
53
+ version: 3.1.0
82
54
  type: :development
83
55
  prerelease: false
84
56
  version_requirements: !ruby/object:Gem::Requirement
85
57
  requirements:
86
58
  - - "~>"
87
59
  - !ruby/object:Gem::Version
88
- version: 2.6.0
60
+ version: 3.1.0
89
61
  description: Syntax checks for Puppet manifests and templates
90
62
  email:
91
63
  - voxpupuli@groups.io
@@ -121,6 +93,7 @@ files:
121
93
  - spec/fixtures/hiera/hiera_badkey.yaml
122
94
  - spec/fixtures/hiera/hiera_good.yaml
123
95
  - spec/fixtures/hiera/hiera_key_empty.yaml
96
+ - spec/fixtures/hiera/hiera_key_no_value.yaml
124
97
  - spec/fixtures/test_module/manifests/deprecation_notice.pp
125
98
  - spec/fixtures/test_module/manifests/fail_error.pp
126
99
  - spec/fixtures/test_module/manifests/fail_warning.pp
@@ -150,7 +123,7 @@ homepage: https://github.com/voxpupuli/puppet-syntax
150
123
  licenses:
151
124
  - MIT
152
125
  metadata: {}
153
- post_install_message:
126
+ post_install_message:
154
127
  rdoc_options: []
155
128
  require_paths:
156
129
  - lib
@@ -165,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
138
  - !ruby/object:Gem::Version
166
139
  version: '0'
167
140
  requirements: []
168
- rubygems_version: 3.3.26
169
- signing_key:
141
+ rubygems_version: 3.3.27
142
+ signing_key:
170
143
  specification_version: 4
171
144
  summary: Syntax checks for Puppet manifests, templates, and Hiera YAML
172
145
  test_files: []