puppet-syntax 3.3.0 → 4.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: 7ab13111ffaa03decb11bef1d05aada83ed94f63e3fe2d9b40413fe1c5a1072e
4
- data.tar.gz: 29f88eb7f120c0aeb17ad95ab562edd936b7d63540d0c2f24c058c3f691e37ae
3
+ metadata.gz: 680101f8a3cfb9d6c9c389e8c89f6514107f45ea6a20d067ca82724613ba47de
4
+ data.tar.gz: 89685e36048969d15ef866c21637be9c41fe89fc71ad3e05298399f0b7192622
5
5
  SHA512:
6
- metadata.gz: ef76471a592b1ba5affe655b657c7b1d40f02cf65ad81fd384d3be489bbc810852622a8fcb28cba197d8cbf8f494215c803be261791a3d8ddbb0460949ab5b00
7
- data.tar.gz: ea4f9da1b8ca9f16d96c639f22213193c1224900d6cbbc480c7063de7580edc1426b31f88b800b1ea1085b3a0fb5eaba58bd816cb73fc7f907f6c15f839d865f
6
+ metadata.gz: a4b33477972e17a5fd5274bf5767a6ce310a3381359404b1d060f0cf63a7507efd8f4896bf52aad1758f392a7618f64eb0dc30a0b5607406d7c5e7375ab23133
7
+ data.tar.gz: 5495e81fe81b45bf9e99579320407d9e64cc70fb14cba686e52ad87439feb87a708d1b6230c50e5eafff9afcce3fd620dc57e403628776af4bb06e3404bf6b74
@@ -0,0 +1,17 @@
1
+ version: 2
2
+ updates:
3
+ # raise PRs for gem updates
4
+ - package-ecosystem: bundler
5
+ directory: "/"
6
+ schedule:
7
+ interval: daily
8
+ time: "13:00"
9
+ open-pull-requests-limit: 10
10
+
11
+ # Maintain dependencies for GitHub Actions
12
+ - package-ecosystem: github-actions
13
+ directory: "/"
14
+ schedule:
15
+ interval: daily
16
+ time: "13:00"
17
+ open-pull-requests-limit: 10
@@ -10,7 +10,7 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
  if: github.repository_owner == 'voxpupuli'
12
12
  steps:
13
- - uses: actions/checkout@v2
13
+ - uses: actions/checkout@v4
14
14
  - name: Install Ruby 3.1
15
15
  uses: ruby/setup-ruby@v1
16
16
  with:
@@ -18,7 +18,7 @@ jobs:
18
18
  env:
19
19
  BUNDLE_WITHOUT: release
20
20
  - name: Build gem
21
- run: gem build *.gemspec
21
+ run: gem build --strict --verbose *.gemspec
22
22
  - name: Publish gem to rubygems.org
23
23
  run: gem push *.gem
24
24
  env:
@@ -9,56 +9,47 @@ env:
9
9
  BUNDLE_WITHOUT: development:release
10
10
 
11
11
  jobs:
12
+ rubocop:
13
+ env:
14
+ BUNDLE_WITHOUT: release
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Install Ruby ${{ matrix.ruby }}
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: "3.1"
22
+ bundler-cache: true
23
+ - name: Run Rubocop
24
+ run: bundle exec rake rubocop
12
25
  test:
13
26
  runs-on: ubuntu-latest
14
27
  strategy:
15
28
  fail-fast: false
16
29
  matrix:
17
30
  ruby:
31
+ - "3.2"
18
32
  - "3.1"
19
33
  - "3.0"
20
34
  - "2.7"
21
- - "2.6"
22
- - "2.5"
23
- - "2.4"
24
35
  puppet:
36
+ - "~> 8.0"
25
37
  - "~> 7.0"
26
- - "~> 6.29"
27
- - "~> 5.5.10"
28
38
  - "https://github.com/puppetlabs/puppet.git#main"
29
39
  exclude:
30
- - ruby: "2.6"
31
- puppet: "~> 7.0"
32
- - ruby: "2.5"
33
- puppet: "~> 7.0"
34
- - ruby: "2.4"
35
- puppet: "~> 7.0"
36
-
37
- - ruby: "3.1"
38
- puppet: "~> 6.29"
39
40
  - ruby: "3.0"
40
- puppet: "~> 6.29"
41
-
42
- - ruby: "3.1"
43
- puppet: "~> 5.5.10"
44
- - ruby: "3.0"
45
- puppet: "~> 5.5.10"
41
+ puppet: "~> 8.0"
46
42
  - ruby: "2.7"
47
- puppet: "~> 5.5.10"
48
- - ruby: "2.6"
49
- puppet: "~> 5.5.10"
50
-
51
- - ruby: "2.6"
52
- puppet: "https://github.com/puppetlabs/puppet.git#main"
53
- - ruby: "2.5"
43
+ puppet: "~> 8.0"
44
+ - ruby: "3.0"
54
45
  puppet: "https://github.com/puppetlabs/puppet.git#main"
55
- - ruby: "2.4"
46
+ - ruby: "2.7"
56
47
  puppet: "https://github.com/puppetlabs/puppet.git#main"
57
48
  name: "Ruby ${{ matrix.ruby }} - Puppet ${{ matrix.puppet }}"
58
49
  env:
59
50
  PUPPET_VERSION: ${{ matrix.puppet }}
60
51
  steps:
61
- - uses: actions/checkout@v3
52
+ - uses: actions/checkout@v4
62
53
  - name: Install Ruby ${{ matrix.ruby }}
63
54
  uses: ruby/setup-ruby@v1
64
55
  with:
@@ -66,3 +57,14 @@ jobs:
66
57
  bundler-cache: true
67
58
  - name: Run tests
68
59
  run: bundle exec rake
60
+ - name: Build gem
61
+ run: gem build --strict --verbose *.gemspec
62
+
63
+ tests:
64
+ needs:
65
+ - rubocop
66
+ - test
67
+ runs-on: ubuntu-latest
68
+ name: Test suite
69
+ steps:
70
+ - run: echo Test suite completed
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ ---
2
+ inherit_from: .rubocop_todo.yml
3
+
4
+ inherit_gem:
5
+ voxpupuli-rubocop: rubocop.yml
6
+
7
+ Metrics:
8
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,252 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2024-02-07 19:46:27 UTC using RuboCop version 1.60.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
11
+ Lint/DuplicateBranch:
12
+ Exclude:
13
+ - 'lib/puppet-syntax/templates.rb'
14
+
15
+ # Offense count: 1
16
+ # Configuration parameters: AllowedParentClasses.
17
+ Lint/MissingSuper:
18
+ Exclude:
19
+ - 'lib/puppet-syntax/tasks/puppet-syntax.rb'
20
+
21
+ # Offense count: 1
22
+ Lint/RescueException:
23
+ Exclude:
24
+ - 'lib/puppet-syntax/hiera.rb'
25
+
26
+ # Offense count: 1
27
+ # Configuration parameters: AllowComments, AllowNil.
28
+ Lint/SuppressedException:
29
+ Exclude:
30
+ - 'Rakefile'
31
+
32
+ # Offense count: 1
33
+ # This cop supports unsafe autocorrection (--autocorrect-all).
34
+ Lint/UselessAssignment:
35
+ Exclude:
36
+ - 'lib/puppet-syntax/templates.rb'
37
+
38
+ # Offense count: 4
39
+ # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
40
+ # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
41
+ # 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
42
+ Naming/FileName:
43
+ Exclude:
44
+ - 'lib/puppet-syntax.rb'
45
+ - 'lib/puppet-syntax/tasks/puppet-syntax.rb'
46
+ - 'spec/puppet-syntax/tasks/puppet-syntax_spec.rb'
47
+ - 'spec/puppet-syntax_spec.rb'
48
+
49
+ # Offense count: 11
50
+ # This cop supports unsafe autocorrection (--autocorrect-all).
51
+ RSpec/BeEq:
52
+ Exclude:
53
+ - 'spec/puppet-syntax/manifests_spec.rb'
54
+ - 'spec/puppet-syntax_spec.rb'
55
+
56
+ # Offense count: 1
57
+ # Configuration parameters: Prefixes, AllowedPatterns.
58
+ # Prefixes: when, with, without
59
+ RSpec/ContextWording:
60
+ Exclude:
61
+ - 'spec/puppet-syntax/hiera_spec.rb'
62
+
63
+ # Offense count: 1
64
+ # Configuration parameters: IgnoredMetadata.
65
+ RSpec/DescribeClass:
66
+ Exclude:
67
+ - '**/spec/features/**/*'
68
+ - '**/spec/requests/**/*'
69
+ - '**/spec/routing/**/*'
70
+ - '**/spec/system/**/*'
71
+ - '**/spec/views/**/*'
72
+ - 'spec/puppet-syntax/tasks/puppet-syntax_spec.rb'
73
+
74
+ # Offense count: 19
75
+ # This cop supports unsafe autocorrection (--autocorrect-all).
76
+ # Configuration parameters: SkipBlocks, EnforcedStyle.
77
+ # SupportedStyles: described_class, explicit
78
+ RSpec/DescribedClass:
79
+ Exclude:
80
+ - 'spec/puppet-syntax/hiera_spec.rb'
81
+ - 'spec/puppet-syntax/manifests_spec.rb'
82
+ - 'spec/puppet-syntax/templates_spec.rb'
83
+ - 'spec/puppet-syntax_spec.rb'
84
+
85
+ # Offense count: 7
86
+ # Configuration parameters: CountAsOne.
87
+ RSpec/ExampleLength:
88
+ Max: 14
89
+
90
+ # Offense count: 4
91
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
92
+ # Include: **/*_spec*rb*, **/spec/**/*
93
+ RSpec/FilePath:
94
+ Exclude:
95
+ - 'spec/puppet-syntax/hiera_spec.rb'
96
+ - 'spec/puppet-syntax/manifests_spec.rb'
97
+ - 'spec/puppet-syntax/templates_spec.rb'
98
+ - 'spec/puppet-syntax_spec.rb'
99
+
100
+ # Offense count: 29
101
+ RSpec/MultipleExpectations:
102
+ Max: 8
103
+
104
+ # Offense count: 30
105
+ # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
106
+ # SupportedStyles: always, named_only
107
+ RSpec/NamedSubject:
108
+ Exclude:
109
+ - 'spec/puppet-syntax/hiera_spec.rb'
110
+ - 'spec/puppet-syntax/manifests_spec.rb'
111
+ - 'spec/puppet-syntax/templates_spec.rb'
112
+
113
+ # Offense count: 8
114
+ RSpec/RepeatedDescription:
115
+ Exclude:
116
+ - 'spec/puppet-syntax/templates_spec.rb'
117
+
118
+ # Offense count: 4
119
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
120
+ # Include: **/*_spec.rb
121
+ RSpec/SpecFilePathFormat:
122
+ Exclude:
123
+ - '**/spec/routing/**/*'
124
+ - 'spec/puppet-syntax/hiera_spec.rb'
125
+ - 'spec/puppet-syntax/manifests_spec.rb'
126
+ - 'spec/puppet-syntax/templates_spec.rb'
127
+ - 'spec/puppet-syntax_spec.rb'
128
+
129
+ # Offense count: 3
130
+ RSpec/SubjectDeclaration:
131
+ Exclude:
132
+ - 'spec/puppet-syntax/hiera_spec.rb'
133
+ - 'spec/puppet-syntax/manifests_spec.rb'
134
+ - 'spec/puppet-syntax/templates_spec.rb'
135
+
136
+ # Offense count: 1
137
+ # This cop supports safe autocorrection (--autocorrect).
138
+ Rake/Desc:
139
+ Exclude:
140
+ - 'Rakefile'
141
+
142
+ # Offense count: 2
143
+ # This cop supports unsafe autocorrection (--autocorrect-all).
144
+ # Configuration parameters: EnforcedStyle.
145
+ # SupportedStyles: always, conditionals
146
+ Style/AndOr:
147
+ Exclude:
148
+ - 'lib/puppet-syntax/manifests.rb'
149
+ - 'lib/puppet-syntax/templates.rb'
150
+
151
+ # Offense count: 1
152
+ # This cop supports unsafe autocorrection (--autocorrect-all).
153
+ # Configuration parameters: MinBranchesCount.
154
+ Style/CaseLikeIf:
155
+ Exclude:
156
+ - 'lib/puppet-syntax/hiera.rb'
157
+
158
+ # Offense count: 5
159
+ # Configuration parameters: AllowedConstants.
160
+ Style/Documentation:
161
+ Exclude:
162
+ - 'spec/**/*'
163
+ - 'test/**/*'
164
+ - 'lib/puppet-syntax.rb'
165
+ - 'lib/puppet-syntax/hiera.rb'
166
+ - 'lib/puppet-syntax/manifests.rb'
167
+ - 'lib/puppet-syntax/tasks/puppet-syntax.rb'
168
+ - 'lib/puppet-syntax/templates.rb'
169
+
170
+ # Offense count: 15
171
+ # This cop supports unsafe autocorrection (--autocorrect-all).
172
+ # Configuration parameters: EnforcedStyle.
173
+ # SupportedStyles: always, always_true, never
174
+ Style/FrozenStringLiteralComment:
175
+ Exclude:
176
+ - 'Gemfile'
177
+ - 'Rakefile'
178
+ - 'lib/puppet-syntax.rb'
179
+ - 'lib/puppet-syntax/hiera.rb'
180
+ - 'lib/puppet-syntax/manifests.rb'
181
+ - 'lib/puppet-syntax/tasks/puppet-syntax.rb'
182
+ - 'lib/puppet-syntax/templates.rb'
183
+ - 'lib/puppet-syntax/version.rb'
184
+ - 'puppet-syntax.gemspec'
185
+ - 'spec/puppet-syntax/hiera_spec.rb'
186
+ - 'spec/puppet-syntax/manifests_spec.rb'
187
+ - 'spec/puppet-syntax/tasks/puppet-syntax_spec.rb'
188
+ - 'spec/puppet-syntax/templates_spec.rb'
189
+ - 'spec/puppet-syntax_spec.rb'
190
+ - 'spec/spec_helper.rb'
191
+
192
+ # Offense count: 2
193
+ # This cop supports unsafe autocorrection (--autocorrect-all).
194
+ Style/IdenticalConditionalBranches:
195
+ Exclude:
196
+ - 'lib/puppet-syntax/templates.rb'
197
+
198
+ # Offense count: 1
199
+ # This cop supports unsafe autocorrection (--autocorrect-all).
200
+ # Configuration parameters: EnforcedStyle.
201
+ # SupportedStyles: literals, strict
202
+ Style/MutableConstant:
203
+ Exclude:
204
+ - 'lib/puppet-syntax/version.rb'
205
+
206
+ # Offense count: 1
207
+ # This cop supports unsafe autocorrection (--autocorrect-all).
208
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
209
+ # SupportedStyles: predicate, comparison
210
+ Style/NumericPredicate:
211
+ Exclude:
212
+ - 'spec/**/*'
213
+ - 'lib/puppet-syntax/hiera.rb'
214
+
215
+ # Offense count: 1
216
+ # This cop supports safe autocorrection (--autocorrect).
217
+ # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
218
+ # SupportedStyles: slashes, percent_r, mixed
219
+ Style/RegexpLiteral:
220
+ Exclude:
221
+ - 'spec/puppet-syntax/templates_spec.rb'
222
+
223
+ # Offense count: 1
224
+ # This cop supports unsafe autocorrection (--autocorrect-all).
225
+ Style/SelectByRegexp:
226
+ Exclude:
227
+ - 'lib/puppet-syntax/manifests.rb'
228
+
229
+ # Offense count: 1
230
+ # This cop supports unsafe autocorrection (--autocorrect-all).
231
+ # Configuration parameters: RequireEnglish, EnforcedStyle.
232
+ # SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
233
+ Style/SpecialGlobalVars:
234
+ Exclude:
235
+ - 'puppet-syntax.gemspec'
236
+
237
+ # Offense count: 4
238
+ # This cop supports unsafe autocorrection (--autocorrect-all).
239
+ # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments.
240
+ # AllowedMethods: define_method
241
+ Style/SymbolProc:
242
+ Exclude:
243
+ - 'lib/puppet-syntax/hiera.rb'
244
+ - 'lib/puppet-syntax/manifests.rb'
245
+ - 'lib/puppet-syntax/templates.rb'
246
+
247
+ # Offense count: 3
248
+ # This cop supports safe autocorrection (--autocorrect).
249
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
250
+ # URISchemes: http, https
251
+ Layout/LineLength:
252
+ Max: 211
data/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [v4.0.0](https://github.com/voxpupuli/puppet-syntax/tree/v4.0.0) (2024-02-07)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v3.3.0...v4.0.0)
8
+
9
+ **Breaking changes:**
10
+
11
+ - Drop Ruby 2.4/2.5/2.6 & Puppet 5/6 support [\#145](https://github.com/voxpupuli/puppet-syntax/pull/145) ([bastelfreak](https://github.com/bastelfreak))
12
+
13
+ **Implemented enhancements:**
14
+
15
+ - Add Ruby 3.2 / Puppet 8 support [\#147](https://github.com/voxpupuli/puppet-syntax/pull/147) ([bastelfreak](https://github.com/bastelfreak))
16
+ - support aliases in hiera yaml [\#144](https://github.com/voxpupuli/puppet-syntax/pull/144) ([akerl](https://github.com/akerl))
17
+ - Implement RuboCop [\#137](https://github.com/voxpupuli/puppet-syntax/pull/137) ([bastelfreak](https://github.com/bastelfreak))
18
+
19
+ **Fixed bugs:**
20
+
21
+ - fix "NameError: uninitialized constant Puppet::Util" [\#155](https://github.com/voxpupuli/puppet-syntax/pull/155) ([mxey](https://github.com/mxey))
22
+ - add all known hiera-eyaml methods [\#154](https://github.com/voxpupuli/puppet-syntax/pull/154) ([mxey](https://github.com/mxey))
23
+
24
+ **Merged pull requests:**
25
+
26
+ - README.md: Fix badges [\#161](https://github.com/voxpupuli/puppet-syntax/pull/161) ([bastelfreak](https://github.com/bastelfreak))
27
+ - gemspec: Add version requirements & CI: Build Gems ins strict & verbose mode [\#160](https://github.com/voxpupuli/puppet-syntax/pull/160) ([bastelfreak](https://github.com/bastelfreak))
28
+ - Update voxpupuli-rubocop requirement from ~\> 2.0.0 to ~\> 2.4.0 [\#159](https://github.com/voxpupuli/puppet-syntax/pull/159) ([dependabot[bot]](https://github.com/apps/dependabot))
29
+ - Update voxpupuli-rubocop requirement from ~\> 1.4.0 to ~\> 2.0.0 [\#152](https://github.com/voxpupuli/puppet-syntax/pull/152) ([dependabot[bot]](https://github.com/apps/dependabot))
30
+ - GCG: Add faraday-retry dep [\#149](https://github.com/voxpupuli/puppet-syntax/pull/149) ([bastelfreak](https://github.com/bastelfreak))
31
+ - Switch to voxpupuli-rubocop [\#148](https://github.com/voxpupuli/puppet-syntax/pull/148) ([bastelfreak](https://github.com/bastelfreak))
32
+ - CI: add dummy job to depend on [\#146](https://github.com/voxpupuli/puppet-syntax/pull/146) ([bastelfreak](https://github.com/bastelfreak))
33
+ - Drop Ruby 1.8 testcode [\#142](https://github.com/voxpupuli/puppet-syntax/pull/142) ([bastelfreak](https://github.com/bastelfreak))
34
+ - rubocop: fix whitespace and newline warnings [\#141](https://github.com/voxpupuli/puppet-syntax/pull/141) ([bastelfreak](https://github.com/bastelfreak))
35
+ - rubocop: fix trailing comma [\#140](https://github.com/voxpupuli/puppet-syntax/pull/140) ([bastelfreak](https://github.com/bastelfreak))
36
+
5
37
  ## [v3.3.0](https://github.com/voxpupuli/puppet-syntax/tree/v3.3.0) (2023-02-08)
6
38
 
7
39
  [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v3.2.1...v3.3.0)
data/Gemfile CHANGED
@@ -6,11 +6,11 @@ source 'https://rubygems.org'
6
6
  # is specified as `file://some/location/on/disk`.
7
7
  def location_for(place_or_version, fake_version = nil)
8
8
  if place_or_version =~ /^(https[:@][^#]*)#(.*)/
9
- [fake_version, { :git => $1, :branch => $2, :require => false }].compact
10
- elsif place_or_version =~ /^file:\/\/(.*)/
11
- ['>= 0', { :path => File.expand_path($1), :require => false }]
9
+ [fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
10
+ elsif place_or_version =~ %r{^file://(.*)}
11
+ ['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }]
12
12
  else
13
- [place_or_version, { :require => false }]
13
+ [place_or_version, { require: false }]
14
14
  end
15
15
  end
16
16
 
@@ -25,6 +25,7 @@ group :test do
25
25
  gem 'rspec'
26
26
  end
27
27
 
28
- group :release do
29
- gem 'github_changelog_generator', require: false
28
+ group :release, optional: true do
29
+ gem 'faraday-retry', '~> 2.1', require: false
30
+ gem 'github_changelog_generator', '~> 1.16.4', require: false
30
31
  end
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # puppet-syntax
2
2
 
3
3
  [![License](https://img.shields.io/github/license/voxpupuli/puppet-syntax.svg)](https://github.com/voxpupuli/puppet-syntax/blob/master/LICENSE.txt)
4
- [![Release](https://github.com/voxpupuli/puppet-syntax/actions/workflows/syntax.yml/badge.svg)](https://github.com/voxpupuli/puppet-syntax/actions/workflows/syntax.yml)
4
+ [![Release](https://github.com/voxpupuli/puppet-syntax/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/puppet-syntax/actions/workflows/release.yml)
5
+ [![Test](https://github.com/voxpupuli/puppet-syntax/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/puppet-syntax/actions/workflows/test.yml)
5
6
  [![RubyGem Version](https://img.shields.io/gem/v/puppet-syntax.svg)](https://rubygems.org/gems/puppet-syntax)
6
7
  [![RubyGem Downloads](https://img.shields.io/gem/dt/puppet-syntax.svg)](https://rubygems.org/gems/puppet-syntax)
7
8
 
data/Rakefile CHANGED
@@ -7,17 +7,28 @@ task :publish_gem do
7
7
  puts "Published #{gem}" if gem
8
8
  end
9
9
 
10
- task :default => [:spec]
10
+ task default: [:spec]
11
11
  begin
12
12
  require 'github_changelog_generator/task'
13
13
  require 'puppet-syntax/version'
14
14
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
15
15
  version = PuppetSyntax::VERSION
16
- config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/
16
+ config.future_release = "v#{version}" if /^\d+\.\d+.\d+$/.match?(version)
17
17
  config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
18
- config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog}
18
+ config.exclude_labels = %w[duplicate question invalid wontfix wont-fix modulesync skip-changelog github_actions]
19
19
  config.user = 'voxpupuli'
20
20
  config.project = 'puppet-syntax'
21
21
  end
22
22
  rescue LoadError
23
23
  end
24
+
25
+ begin
26
+ require 'rubocop/rake_task'
27
+ 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
34
+ end
@@ -3,21 +3,20 @@ require 'base64'
3
3
 
4
4
  module PuppetSyntax
5
5
  class Hiera
6
-
7
6
  def check_hiera_key(key)
8
7
  if key.is_a? Symbol
9
8
  if key.to_s.start_with?(':')
10
- return "Puppet automatic lookup will not use leading '::'"
11
- elsif key !~ /^[a-z]+$/ # we allow Hiera's own configuration
12
- return "Puppet automatic lookup will not look up symbols"
13
- end
14
- elsif key !~ /^[a-z][a-z0-9_]+(::[a-z][a-z0-9_]+)*$/
15
- if key =~ /[^:]:[^:]/
16
- # be extra helpful
17
- return "Looks like a missing colon"
18
- else
19
- return "Not a valid Puppet variable name for automatic lookup"
9
+ "Puppet automatic lookup will not use leading '::'"
10
+ elsif !/^[a-z]+$/.match?(key) # we allow Hiera's own configuration
11
+ 'Puppet automatic lookup will not look up symbols'
20
12
  end
13
+ elsif !/^[a-z][a-z0-9_]+(::[a-z][a-z0-9_]+)*$/.match?(key)
14
+ return 'Looks like a missing colon' if /[^:]:[^:]/.match?(key)
15
+
16
+ # be extra helpful
17
+
18
+ 'Not a valid Puppet variable name for automatic lookup'
19
+
21
20
  end
22
21
  end
23
22
 
@@ -33,7 +32,7 @@ module PuppetSyntax
33
32
  break if error
34
33
  end
35
34
  elsif val.is_a? Hash
36
- val.each do |k,v|
35
+ val.each do |k, v|
37
36
  error = check_eyaml_data("#{name}['#{k}']", v)
38
37
  break if error
39
38
  end
@@ -42,53 +41,54 @@ module PuppetSyntax
42
41
  end
43
42
 
44
43
  def check_eyaml_blob(val)
45
- return unless val =~ /^ENC\[/
44
+ return unless /^ENC\[/.match?(val)
46
45
 
47
46
  val.sub!('ENC[', '')
48
47
  val.gsub!(/\s+/, '')
49
- if val !~ /\]$/
50
- return "has unterminated eyaml value"
51
- else
52
- val.sub!(/\]$/, '')
53
- method, base64 = val.split(/,/)
54
- if base64 == nil
55
- base64 = method
56
- method = 'PKCS7'
57
- end
58
-
59
- return "has unknown eyaml method #{method}" unless ['PKCS7','GPG','GKMS','KMS'].include? method
60
- return "has unpadded or truncated base64 data" unless base64.length % 4 == 0
48
+ return 'has unterminated eyaml value' unless /\]$/.match?(val)
61
49
 
62
- # Base64#decode64 will silently ignore characters outside the alphabet,
63
- # so we check resulting length of binary data instead
64
- pad_length = base64.gsub(/[^=]/, '').length
65
- if Base64.decode64(base64).length != base64.length * 3/4 - pad_length
66
- return "has corrupt base64 data"
67
- end
50
+ val.sub!(/\]$/, '')
51
+ method, base64 = val.split(',')
52
+ if base64.nil?
53
+ base64 = method
54
+ method = 'PKCS7'
68
55
  end
56
+
57
+ known_methods = %w[PKCS7 GPG GKMS KMS TWOFAC SecretBox VAULT GCPKMS RSA SSHAGENT VAULT_RS cli]
58
+ return "has unknown eyaml method #{method}" unless known_methods.include? method
59
+ return 'has unpadded or truncated base64 data' unless base64.length % 4 == 0
60
+
61
+ # Base64#decode64 will silently ignore characters outside the alphabet,
62
+ # so we check resulting length of binary data instead
63
+ pad_length = base64.gsub(/[^=]/, '').length
64
+ return unless Base64.decode64(base64).length != (base64.length * 3 / 4) - pad_length
65
+
66
+ 'has corrupt base64 data'
69
67
  end
70
68
 
71
69
  def check(filelist)
72
- raise "Expected an array of files" unless filelist.is_a?(Array)
70
+ raise 'Expected an array of files' unless filelist.is_a?(Array)
73
71
 
74
72
  errors = []
75
73
 
74
+ yamlargs = (Psych::VERSION >= '4.0') ? { aliases: true } : {}
75
+
76
76
  filelist.each do |hiera_file|
77
77
  begin
78
- yamldata = YAML.load_file(hiera_file)
79
- rescue Exception => error
80
- errors << "ERROR: Failed to parse #{hiera_file}: #{error}"
78
+ yamldata = YAML.load_file(hiera_file, **yamlargs)
79
+ rescue Exception => e
80
+ errors << "ERROR: Failed to parse #{hiera_file}: #{e}"
81
81
  next
82
82
  end
83
- if yamldata
84
- yamldata.each do |k,v|
85
- if PuppetSyntax.check_hiera_keys
86
- key_msg = check_hiera_key(k)
87
- errors << "WARNING: #{hiera_file}: Key :#{k}: #{key_msg}" if key_msg
88
- end
89
- eyaml_msg = check_eyaml_data(k, v)
90
- errors << "WARNING: #{hiera_file}: #{eyaml_msg}" if eyaml_msg
83
+ next unless yamldata
84
+
85
+ yamldata.each do |k, v|
86
+ if PuppetSyntax.check_hiera_keys
87
+ key_msg = check_hiera_key(k)
88
+ errors << "WARNING: #{hiera_file}: Key :#{k}: #{key_msg}" if key_msg
91
89
  end
90
+ eyaml_msg = check_eyaml_data(k, v)
91
+ errors << "WARNING: #{hiera_file}: #{eyaml_msg}" if eyaml_msg
92
92
  end
93
93
  end
94
94