puppet-syntax 3.0.0 → 3.2.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 +4 -4
- data/.github/workflows/release.yml +32 -0
- data/.github/workflows/test.yml +68 -0
- data/CHANGELOG.md +30 -0
- data/Gemfile +3 -3
- data/README.md +16 -4
- data/lib/puppet-syntax/manifests.rb +2 -2
- data/lib/puppet-syntax/tasks/puppet-syntax.rb +11 -3
- data/lib/puppet-syntax/templates.rb +47 -16
- data/lib/puppet-syntax/version.rb +1 -1
- data/puppet-syntax.gemspec +0 -1
- data/spec/fixtures/test_module/manifests/schedule_notice.pp +5 -0
- data/spec/puppet-syntax/manifests_spec.rb +8 -0
- data/spec/puppet-syntax/tasks/puppet-syntax_spec.rb +1 -1
- data/spec/puppet-syntax/templates_spec.rb +28 -20
- metadata +7 -18
- data/.travis.yml +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2d390b306423921b0dd89e24373f6e59ae0235777324e478194d4edf2fa3026
|
|
4
|
+
data.tar.gz: 205c580df12c234a6ecb48f29fdee3a0ba2f933f0ddb5384489fcbe8d53ae923
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bbd443ce59ee2fc0e943f75378c05972521c29bf95bdc53378478a423b63f036ab0fff7ab34c7385555eb65fa79e289d66a64bc0ba735ec3049f91b063663b99
|
|
7
|
+
data.tar.gz: 1448871b536af6ecbec32f25fc16867a6c637c4cab80138773d188857db0b7f456116e6a7db981b95c8504dfe53a30f4f39253cfcb8213e2db9657c14f6ead45
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- '*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
if: github.repository_owner == 'voxpupuli'
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v2
|
|
14
|
+
- name: Install Ruby 3.1
|
|
15
|
+
uses: ruby/setup-ruby@v1
|
|
16
|
+
with:
|
|
17
|
+
ruby-version: '3.1'
|
|
18
|
+
env:
|
|
19
|
+
BUNDLE_WITHOUT: release
|
|
20
|
+
- name: Build gem
|
|
21
|
+
run: gem build *.gemspec
|
|
22
|
+
- name: Publish gem to rubygems.org
|
|
23
|
+
run: gem push *.gem
|
|
24
|
+
env:
|
|
25
|
+
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
|
|
26
|
+
- name: Setup GitHub packages access
|
|
27
|
+
run: |
|
|
28
|
+
mkdir -p ~/.gem
|
|
29
|
+
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
|
|
30
|
+
chmod 0600 ~/.gem/credentials
|
|
31
|
+
- name: Publish gem to GitHub packages
|
|
32
|
+
run: gem push --key github --host https://rubygems.pkg.github.com/{{ github.repository_owner }} *.gem
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request: {}
|
|
5
|
+
push:
|
|
6
|
+
branches: master
|
|
7
|
+
|
|
8
|
+
env:
|
|
9
|
+
BUNDLE_WITHOUT: development:release
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
ruby:
|
|
18
|
+
- "3.1"
|
|
19
|
+
- "3.0"
|
|
20
|
+
- "2.7"
|
|
21
|
+
- "2.6"
|
|
22
|
+
- "2.5"
|
|
23
|
+
- "2.4"
|
|
24
|
+
puppet:
|
|
25
|
+
- "~> 7.0"
|
|
26
|
+
- "~> 6.5"
|
|
27
|
+
- "~> 5.5.10"
|
|
28
|
+
- "https://github.com/puppetlabs/puppet.git#main"
|
|
29
|
+
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.5"
|
|
39
|
+
- ruby: "3.0"
|
|
40
|
+
puppet: "~> 6.5"
|
|
41
|
+
|
|
42
|
+
- ruby: "3.1"
|
|
43
|
+
puppet: "~> 5.5.10"
|
|
44
|
+
- ruby: "3.0"
|
|
45
|
+
puppet: "~> 5.5.10"
|
|
46
|
+
- 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"
|
|
54
|
+
puppet: "https://github.com/puppetlabs/puppet.git#main"
|
|
55
|
+
- ruby: "2.4"
|
|
56
|
+
puppet: "https://github.com/puppetlabs/puppet.git#main"
|
|
57
|
+
name: "Ruby ${{ matrix.ruby }} - Puppet ${{ matrix.puppet }}"
|
|
58
|
+
env:
|
|
59
|
+
PUPPET_VERSION: ${{ matrix.puppet }}
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v3
|
|
62
|
+
- name: Install Ruby ${{ matrix.ruby }}
|
|
63
|
+
uses: ruby/setup-ruby@v1
|
|
64
|
+
with:
|
|
65
|
+
ruby-version: ${{ matrix.ruby }}
|
|
66
|
+
bundler-cache: true
|
|
67
|
+
- name: Run tests
|
|
68
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [v3.2.0](https://github.com/voxpupuli/puppet-syntax/tree/v3.2.0) (2022-05-16)
|
|
6
|
+
|
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v3.1.0...v3.2.0)
|
|
8
|
+
|
|
9
|
+
**Implemented enhancements:**
|
|
10
|
+
|
|
11
|
+
- Remove AppVeyor testing [\#94](https://github.com/voxpupuli/puppet-syntax/issues/94)
|
|
12
|
+
- Convert from Travis CI to GitHub Actions [\#130](https://github.com/voxpupuli/puppet-syntax/pull/130) ([ekohl](https://github.com/ekohl))
|
|
13
|
+
|
|
14
|
+
## [v3.1.0](https://github.com/voxpupuli/puppet-syntax/tree/v3.1.0) (2020-06-24)
|
|
15
|
+
|
|
16
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v3.0.1...v3.1.0)
|
|
17
|
+
|
|
18
|
+
**Implemented enhancements:**
|
|
19
|
+
|
|
20
|
+
- print actual template errors on $stderr [\#125](https://github.com/voxpupuli/puppet-syntax/pull/125) ([foxxx0](https://github.com/foxxx0))
|
|
21
|
+
|
|
22
|
+
**Merged pull requests:**
|
|
23
|
+
|
|
24
|
+
- Add ruby2.7 testing, replacing multiple obsolete puppet6 versions [\#124](https://github.com/voxpupuli/puppet-syntax/pull/124) ([DavidS](https://github.com/DavidS))
|
|
25
|
+
|
|
26
|
+
## [v3.0.1](https://github.com/voxpupuli/puppet-syntax/tree/v3.0.1) (2020-05-27)
|
|
27
|
+
|
|
28
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v3.0.0...v3.0.1)
|
|
29
|
+
|
|
30
|
+
**Merged pull requests:**
|
|
31
|
+
|
|
32
|
+
- Avoid failure on schedule metaparameter warning [\#122](https://github.com/voxpupuli/puppet-syntax/pull/122) ([ffapitalle](https://github.com/ffapitalle))
|
|
33
|
+
|
|
5
34
|
## [v3.0.0](https://github.com/voxpupuli/puppet-syntax/tree/v3.0.0) (2020-05-09)
|
|
6
35
|
|
|
7
36
|
[Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.6.1...v3.0.0)
|
|
@@ -42,6 +71,7 @@ All notable changes to this project will be documented in this file.
|
|
|
42
71
|
|
|
43
72
|
**Merged pull requests:**
|
|
44
73
|
|
|
74
|
+
- Test on ruby 2.6 [\#111](https://github.com/voxpupuli/puppet-syntax/pull/111) ([alexjfisher](https://github.com/alexjfisher))
|
|
45
75
|
- Adding KMS tags to allowed EYAML methods [\#105](https://github.com/voxpupuli/puppet-syntax/pull/105) ([craigwatson](https://github.com/craigwatson))
|
|
46
76
|
|
|
47
77
|
## [v2.5.0](https://github.com/voxpupuli/puppet-syntax/tree/v2.5.0) (2019-07-07)
|
data/Gemfile
CHANGED
|
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
|
|
|
5
5
|
# `git://somewhere.git#branch`. You can also use a file source location, which
|
|
6
6
|
# is specified as `file://some/location/on/disk`.
|
|
7
7
|
def location_for(place_or_version, fake_version = nil)
|
|
8
|
-
if place_or_version =~ /^(
|
|
8
|
+
if place_or_version =~ /^(https[:@][^#]*)#(.*)/
|
|
9
9
|
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
|
|
10
10
|
elsif place_or_version =~ /^file:\/\/(.*)/
|
|
11
11
|
['>= 0', { :path => File.expand_path($1), :require => false }]
|
|
@@ -19,12 +19,12 @@ gemspec
|
|
|
19
19
|
|
|
20
20
|
# Override gemspec for CI matrix builds.
|
|
21
21
|
# But only if the environment variable is set
|
|
22
|
-
gem 'puppet', *location_for(ENV['PUPPET_VERSION']
|
|
22
|
+
gem 'puppet', *location_for(ENV['PUPPET_VERSION']) if ENV['PUPPET_VERSION']
|
|
23
23
|
|
|
24
24
|
group :test do
|
|
25
25
|
gem 'rspec'
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
group :release do
|
|
29
|
-
gem 'github_changelog_generator',
|
|
29
|
+
gem 'github_changelog_generator', require: false
|
|
30
30
|
end
|
data/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
[](https://github.com/voxpupuli/puppet-syntax/blob/master/LICENSE.txt)
|
|
4
|
+
[](https://github.com/voxpupuli/puppet-syntax/actions/workflows/syntax.yml)
|
|
5
|
+
[](https://rubygems.org/gems/puppet-syntax)
|
|
6
|
+
[](https://rubygems.org/gems/puppet-syntax)
|
|
4
7
|
|
|
5
8
|
# Puppet::Syntax
|
|
6
9
|
|
|
@@ -14,7 +17,7 @@ Puppet::Syntax is supported with:
|
|
|
14
17
|
- Puppet >= 5.0 that provides the `validate` face.
|
|
15
18
|
- Ruby >= 2.4
|
|
16
19
|
|
|
17
|
-
For the specific versions that we test against, see the [
|
|
20
|
+
For the specific versions that we test against, see the [GitHub Actions workflow](.github/workflows/test.yml).
|
|
18
21
|
|
|
19
22
|
## Installation
|
|
20
23
|
|
|
@@ -159,3 +162,12 @@ parser enabled.
|
|
|
159
162
|
3. Commit your changes (`git commit -am 'Add some feature'`).
|
|
160
163
|
4. Push to the branch (`git push origin my-new-feature`).
|
|
161
164
|
5. Create new Pull Request.
|
|
165
|
+
|
|
166
|
+
## Making a new Release
|
|
167
|
+
|
|
168
|
+
* Update version in `lib/puppet-syntax/version.rb`
|
|
169
|
+
* Run the changelog rake task (bundle exec rake changelog)
|
|
170
|
+
* Create a PR
|
|
171
|
+
* Get it reviewed and merged
|
|
172
|
+
* update the local repo, create a signed git tag, prefixed with a v, matching the new version (git tag -s v1.2.3)
|
|
173
|
+
* GitHub action will publish to GitHub Packages and Rubygems
|
|
@@ -41,9 +41,9 @@ module PuppetSyntax
|
|
|
41
41
|
e =~ /^You cannot collect( exported resources)? without storeconfigs being set/
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
# tag
|
|
44
|
+
# tag and schedule parameters in class raise warnings notice in output that prevent from succeed
|
|
45
45
|
output.reject! { |e|
|
|
46
|
-
e =~ /^tag is a metaparam; this value will inherit to all contained resources in the /
|
|
46
|
+
e =~ /^(tag|schedule) is a metaparam; this value will inherit to all contained resources in the /
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
deprecations = output.select { |e|
|
|
@@ -7,6 +7,7 @@ module PuppetSyntax
|
|
|
7
7
|
def filelist(paths)
|
|
8
8
|
excludes = PuppetSyntax.exclude_paths
|
|
9
9
|
excludes.push('pkg/**/*')
|
|
10
|
+
excludes.push('vendor/**/*')
|
|
10
11
|
files = FileList[paths]
|
|
11
12
|
files.reject! { |f| File.directory?(f) }
|
|
12
13
|
files.exclude(*excludes)
|
|
@@ -48,9 +49,16 @@ module PuppetSyntax
|
|
|
48
49
|
$stderr.puts "---> #{t.name}"
|
|
49
50
|
|
|
50
51
|
c = PuppetSyntax::Templates.new
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
result = c.check(filelist_templates)
|
|
53
|
+
unless result[:warnings].empty?
|
|
54
|
+
$stdout.puts "WARNINGS:"
|
|
55
|
+
$stdout.puts result[:warnings].join("\n")
|
|
56
|
+
end
|
|
57
|
+
unless result[:errors].empty?
|
|
58
|
+
$stderr.puts "ERRORS:"
|
|
59
|
+
$stderr.puts result[:errors].join("\n")
|
|
60
|
+
exit 1
|
|
61
|
+
end
|
|
54
62
|
end
|
|
55
63
|
|
|
56
64
|
desc 'Syntax check Hiera config files'
|
|
@@ -9,41 +9,72 @@ module PuppetSyntax
|
|
|
9
9
|
|
|
10
10
|
# We now have to redirect STDERR in order to capture warnings.
|
|
11
11
|
$stderr = warnings = StringIO.new()
|
|
12
|
-
|
|
12
|
+
result = { warnings: [], errors: [] }
|
|
13
13
|
|
|
14
14
|
filelist.each do |file|
|
|
15
15
|
if File.extname(file) == '.epp' or PuppetSyntax.epp_only
|
|
16
|
-
|
|
16
|
+
tmp = validate_epp(file)
|
|
17
17
|
elsif File.extname(file) == '.erb'
|
|
18
|
-
|
|
18
|
+
tmp = validate_erb(file)
|
|
19
19
|
end
|
|
20
|
+
result.merge!(tmp) { |k, a, b| a.concat(b) } unless tmp.nil?
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
$stderr = STDERR
|
|
23
|
-
|
|
24
|
-
errors.map! { |e| e.to_s }
|
|
24
|
+
result[:warnings] << warnings.string unless warnings.string.empty?
|
|
25
25
|
|
|
26
|
-
errors
|
|
26
|
+
result[:errors].map! { |e| e.to_s }
|
|
27
|
+
result[:warnings].map! { |w| w.to_s }
|
|
28
|
+
|
|
29
|
+
result
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
def validate_epp(filename)
|
|
30
33
|
require 'puppet/pops'
|
|
31
|
-
|
|
34
|
+
result = { warnings: [], errors: [] }
|
|
35
|
+
formatter = Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle.new
|
|
36
|
+
evaluating_parser = Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new()
|
|
37
|
+
parser = evaluating_parser.parser()
|
|
32
38
|
begin
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
parse_result = parser.parse_file(filename)
|
|
40
|
+
validation_result = evaluating_parser.validate(parse_result.model)
|
|
41
|
+
|
|
42
|
+
# print out any warnings
|
|
43
|
+
validation_result.warnings.each do |warn|
|
|
44
|
+
message = formatter.format_message(warn)
|
|
45
|
+
file = warn.file
|
|
46
|
+
line = warn.source_pos.line
|
|
47
|
+
column = warn.source_pos.pos
|
|
48
|
+
result[:warnings] << "#{file}:#{line}:#{column}: #{message}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# collect errors and return them in order to indicate validation failure
|
|
52
|
+
validation_result.errors.each do |err|
|
|
53
|
+
message = formatter.format_message(err)
|
|
54
|
+
file = err.file
|
|
55
|
+
line = err.source_pos.line
|
|
56
|
+
column = err.source_pos.pos
|
|
57
|
+
result[:errors] << "#{file}:#{line}:#{column}: #{message}"
|
|
58
|
+
end
|
|
59
|
+
rescue Puppet::ParseError, SyntaxError => exc
|
|
60
|
+
result[:errors] << exc
|
|
61
|
+
rescue => exc
|
|
62
|
+
result[:errors] << exc
|
|
37
63
|
end
|
|
38
64
|
|
|
39
|
-
|
|
65
|
+
result
|
|
40
66
|
end
|
|
41
67
|
|
|
42
68
|
def validate_erb(filename)
|
|
43
|
-
|
|
69
|
+
result = { warnings: [], errors: [] }
|
|
44
70
|
|
|
45
71
|
begin
|
|
46
|
-
|
|
72
|
+
template = File.read(filename)
|
|
73
|
+
erb = if RUBY_VERSION >= '2.6'
|
|
74
|
+
ERB.new(template, trim_mode: '-')
|
|
75
|
+
else
|
|
76
|
+
ERB.new(template, nil, '-')
|
|
77
|
+
end
|
|
47
78
|
erb.filename = filename
|
|
48
79
|
erb.result
|
|
49
80
|
rescue NameError => error
|
|
@@ -53,10 +84,10 @@ module PuppetSyntax
|
|
|
53
84
|
# This is normal because we don't have the variables that would
|
|
54
85
|
# ordinarily be bound by the parent Puppet manifest.
|
|
55
86
|
rescue SyntaxError => error
|
|
56
|
-
errors << error
|
|
87
|
+
result[:errors] << error
|
|
57
88
|
end
|
|
58
89
|
|
|
59
|
-
|
|
90
|
+
result
|
|
60
91
|
end
|
|
61
92
|
end
|
|
62
93
|
end
|
data/puppet-syntax.gemspec
CHANGED
|
@@ -24,6 +24,14 @@ describe PuppetSyntax::Manifests do
|
|
|
24
24
|
expect(has_errors).to eq(false)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
it 'should return nothing from a valid file with a class using schedule parameter' do
|
|
28
|
+
files = fixture_manifests('schedule_notice.pp')
|
|
29
|
+
output, has_errors = subject.check(files)
|
|
30
|
+
|
|
31
|
+
expect(output).to eq([])
|
|
32
|
+
expect(has_errors).to eq(false)
|
|
33
|
+
end
|
|
34
|
+
|
|
27
35
|
it 'should return an error from an invalid file' do
|
|
28
36
|
files = fixture_manifests('fail_error.pp')
|
|
29
37
|
output, has_errors = subject.check(files)
|
|
@@ -18,7 +18,7 @@ describe 'PuppetSyntax rake tasks' do
|
|
|
18
18
|
it 'should generate FileList of manifests relative to Rakefile' do
|
|
19
19
|
list = PuppetSyntax::RakeTask.new.filelist_manifests
|
|
20
20
|
expect(list).to include(known_pp)
|
|
21
|
-
expect(list.count).to eq
|
|
21
|
+
expect(list.count).to eq 9
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it 'should generate FileList of templates relative to Rakefile' do
|
|
@@ -18,91 +18,99 @@ describe PuppetSyntax::Templates do
|
|
|
18
18
|
files = fixture_templates('pass.erb')
|
|
19
19
|
res = subject.check(files)
|
|
20
20
|
|
|
21
|
-
expect(res).to match([])
|
|
21
|
+
expect(res[:warnings]).to match([])
|
|
22
|
+
expect(res[:errors]).to match([])
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
it 'should ignore NameErrors from unbound variables' do
|
|
25
26
|
files = fixture_templates('pass_unbound_var.erb')
|
|
26
27
|
res = subject.check(files)
|
|
27
28
|
|
|
28
|
-
expect(res).to match([])
|
|
29
|
+
expect(res[:warnings]).to match([])
|
|
30
|
+
expect(res[:errors]).to match([])
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
it 'should catch SyntaxError' do
|
|
32
34
|
files = fixture_templates('fail_error.erb')
|
|
33
35
|
res = subject.check(files)
|
|
34
36
|
|
|
35
|
-
expect(res.size).to eq(1)
|
|
36
|
-
expect(res[0]).to match(/2: syntax error, unexpected/)
|
|
37
|
+
expect(res[:errors].size).to eq(1)
|
|
38
|
+
expect(res[:errors][0]).to match(/2: syntax error, unexpected/)
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
it 'should catch Ruby warnings' do
|
|
40
42
|
files = fixture_templates('fail_warning.erb')
|
|
41
43
|
res = subject.check(files)
|
|
42
44
|
|
|
43
|
-
expect(res.size).to eq(1)
|
|
44
|
-
expect(res[0]).to match(conditional_warning_regex)
|
|
45
|
+
expect(res[:warnings].size).to eq(1)
|
|
46
|
+
expect(res[:warnings][0]).to match(conditional_warning_regex)
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
it 'should read more than one valid file' do
|
|
48
50
|
files = fixture_templates(['pass.erb', 'pass_unbound_var.erb'])
|
|
49
51
|
res = subject.check(files)
|
|
50
52
|
|
|
51
|
-
expect(res).to match([])
|
|
53
|
+
expect(res[:warnings]).to match([])
|
|
54
|
+
expect(res[:errors]).to match([])
|
|
52
55
|
end
|
|
53
56
|
|
|
54
57
|
it 'should continue after finding an error in the first file' do
|
|
55
58
|
files = fixture_templates(['fail_error.erb', 'fail_warning.erb'])
|
|
56
59
|
res = subject.check(files)
|
|
57
60
|
|
|
58
|
-
expect(res.size).to eq(
|
|
59
|
-
expect(res[
|
|
60
|
-
expect(res[
|
|
61
|
+
expect(res[:warnings].size).to eq(1)
|
|
62
|
+
expect(res[:errors].size).to eq(1)
|
|
63
|
+
expect(res[:errors][0]).to match(/2: syntax error, unexpected/)
|
|
64
|
+
expect(res[:warnings][0]).to match(conditional_warning_regex)
|
|
61
65
|
end
|
|
62
66
|
|
|
63
67
|
it 'should ignore a TypeError' do
|
|
64
68
|
files = fixture_templates('typeerror_shouldwin.erb')
|
|
65
69
|
res = subject.check(files)
|
|
66
70
|
|
|
67
|
-
expect(res).to match([])
|
|
71
|
+
expect(res[:warnings]).to match([])
|
|
72
|
+
expect(res[:errors]).to match([])
|
|
68
73
|
end
|
|
69
74
|
|
|
70
75
|
it 'should ignore files without .erb extension' do
|
|
71
76
|
files = fixture_templates('ignore.tpl')
|
|
72
77
|
res = subject.check(files)
|
|
73
78
|
|
|
74
|
-
expect(res).to match([])
|
|
79
|
+
expect(res[:warnings]).to match([])
|
|
80
|
+
expect(res[:errors]).to match([])
|
|
75
81
|
end
|
|
76
82
|
|
|
77
83
|
it 'should return nothing from a valid file' do
|
|
78
84
|
files = fixture_templates('pass.epp')
|
|
79
85
|
res = subject.check(files)
|
|
80
86
|
|
|
81
|
-
expect(res).to match([])
|
|
87
|
+
expect(res[:warnings]).to match([])
|
|
88
|
+
expect(res[:errors]).to match([])
|
|
82
89
|
end
|
|
83
90
|
|
|
84
91
|
it 'should catch SyntaxError' do
|
|
85
92
|
files = fixture_templates('fail_error.epp')
|
|
86
93
|
res = subject.check(files)
|
|
87
94
|
|
|
88
|
-
expect(res.size).to eq(1)
|
|
89
|
-
expect(res[0]).to match(/This Type-Name has no effect/)
|
|
95
|
+
expect(res[:errors].size).to eq(1)
|
|
96
|
+
expect(res[:errors][0]).to match(/This Type-Name has no effect/)
|
|
90
97
|
end
|
|
91
98
|
|
|
92
99
|
it 'should read more than one valid file' do
|
|
93
100
|
files = fixture_templates(['pass.epp', 'pass_also.epp'])
|
|
94
101
|
res = subject.check(files)
|
|
95
102
|
|
|
96
|
-
expect(res).to match([])
|
|
103
|
+
expect(res[:warnings]).to match([])
|
|
104
|
+
expect(res[:errors]).to match([])
|
|
97
105
|
end
|
|
98
106
|
|
|
99
107
|
it 'should continue after finding an error in the first file' do
|
|
100
108
|
files = fixture_templates(['fail_error.epp', 'fail_error_also.epp'])
|
|
101
109
|
res = subject.check(files)
|
|
102
110
|
|
|
103
|
-
expect(res.size).to eq(2)
|
|
104
|
-
expect(res[0]).to match(/This Type-Name has no effect/)
|
|
105
|
-
expect(res[1]).to match(/Syntax error at '}' \(file: \S*\/fail_error_also.epp, line: 2, column: 4\)/)
|
|
111
|
+
expect(res[:errors].size).to eq(2)
|
|
112
|
+
expect(res[:errors][0]).to match(/This Type-Name has no effect/)
|
|
113
|
+
expect(res[:errors][1]).to match(/Syntax error at '}' \(file: \S*\/fail_error_also.epp, line: 2, column: 4\)/)
|
|
106
114
|
end
|
|
107
115
|
|
|
108
116
|
context "when the 'epp_only' options is set" do
|
|
@@ -114,7 +122,7 @@ describe PuppetSyntax::Templates do
|
|
|
114
122
|
files = fixture_templates('pass.erb')
|
|
115
123
|
res = subject.check(files)
|
|
116
124
|
|
|
117
|
-
expect(res.size).to eq(1)
|
|
125
|
+
expect(res[:errors].size).to eq(1)
|
|
118
126
|
end
|
|
119
127
|
end
|
|
120
128
|
end
|
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: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vox Pupuli
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-05-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -66,20 +66,6 @@ dependencies:
|
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: gem_publisher
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '1.3'
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '1.3'
|
|
83
69
|
description: Syntax checks for Puppet manifests and templates
|
|
84
70
|
email:
|
|
85
71
|
- voxpupuli@groups.io
|
|
@@ -87,8 +73,9 @@ executables: []
|
|
|
87
73
|
extensions: []
|
|
88
74
|
extra_rdoc_files: []
|
|
89
75
|
files:
|
|
76
|
+
- ".github/workflows/release.yml"
|
|
77
|
+
- ".github/workflows/test.yml"
|
|
90
78
|
- ".gitignore"
|
|
91
|
-
- ".travis.yml"
|
|
92
79
|
- CHANGELOG.md
|
|
93
80
|
- Gemfile
|
|
94
81
|
- HISTORY.md
|
|
@@ -118,6 +105,7 @@ files:
|
|
|
118
105
|
- spec/fixtures/test_module/manifests/future_syntax.pp
|
|
119
106
|
- spec/fixtures/test_module/manifests/pass.pp
|
|
120
107
|
- spec/fixtures/test_module/manifests/pass_storeconfigs.pp
|
|
108
|
+
- spec/fixtures/test_module/manifests/schedule_notice.pp
|
|
121
109
|
- spec/fixtures/test_module/manifests/tag_notice.pp
|
|
122
110
|
- spec/fixtures/test_module/manifests/test_app.pp
|
|
123
111
|
- spec/fixtures/test_module/templates/fail_error.epp
|
|
@@ -155,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
155
143
|
- !ruby/object:Gem::Version
|
|
156
144
|
version: '0'
|
|
157
145
|
requirements: []
|
|
158
|
-
rubygems_version: 3.
|
|
146
|
+
rubygems_version: 3.3.7
|
|
159
147
|
signing_key:
|
|
160
148
|
specification_version: 4
|
|
161
149
|
summary: Syntax checks for Puppet manifests, templates, and Hiera YAML
|
|
@@ -176,6 +164,7 @@ test_files:
|
|
|
176
164
|
- spec/fixtures/test_module/manifests/future_syntax.pp
|
|
177
165
|
- spec/fixtures/test_module/manifests/pass.pp
|
|
178
166
|
- spec/fixtures/test_module/manifests/pass_storeconfigs.pp
|
|
167
|
+
- spec/fixtures/test_module/manifests/schedule_notice.pp
|
|
179
168
|
- spec/fixtures/test_module/manifests/tag_notice.pp
|
|
180
169
|
- spec/fixtures/test_module/manifests/test_app.pp
|
|
181
170
|
- spec/fixtures/test_module/templates/fail_error.epp
|
data/.travis.yml
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
dist: bionic
|
|
3
|
-
language: ruby
|
|
4
|
-
# Workaround https://github.com/bundler/bundler/issues/3558
|
|
5
|
-
before_install: gem install bundler
|
|
6
|
-
install: bundle install --jobs 4 --retry 2 --without development release
|
|
7
|
-
script: bundle exec rake
|
|
8
|
-
rvm:
|
|
9
|
-
- 2.4.4
|
|
10
|
-
- 2.5.1
|
|
11
|
-
- 2.6.5
|
|
12
|
-
env:
|
|
13
|
-
- PUPPET_VERSION="~> 5.5.10"
|
|
14
|
-
- PUPPET_VERSION="~> 6.1.0"
|
|
15
|
-
- PUPPET_VERSION="~> 6.2.0"
|
|
16
|
-
- PUPPET_VERSION="~> 6.5.0"
|
|
17
|
-
- PUPPET_VERSION=">= 0"
|
|
18
|
-
- PUPPET_VERSION="git://github.com/puppetlabs/puppet.git#master"
|
|
19
|
-
matrix:
|
|
20
|
-
allow_failures:
|
|
21
|
-
- env: PUPPET_VERSION=">= 0"
|
|
22
|
-
- env: PUPPET_VERSION="git://github.com/puppetlabs/puppet.git#master"
|
|
23
|
-
deploy:
|
|
24
|
-
provider: rubygems
|
|
25
|
-
api_key:
|
|
26
|
-
secure: "kwxryZZ/t9EkWuYxhz3G1v+U3ZK4WdsiN0UFHDjijnAGPxqe/n+oBcNA8hOiNhjZeTFo8bADEZkL7JtdKQo9RvgStipyaS5gDHB/C1c4LOBWv4Tga21NNCAuBcE2CDtAH3+TzrZV5vv2+SpOrhKZpzZoAoR6PR1MWVWMUie/rE0="
|
|
27
|
-
gem: puppet-syntax
|
|
28
|
-
on:
|
|
29
|
-
rvm: 2.5.1
|
|
30
|
-
condition: '"$PUPPET_VERSION" = "~> 5.5.10"'
|
|
31
|
-
tags: true
|
|
32
|
-
all_branches: true
|
|
33
|
-
repo: voxpupuli/puppet-syntax
|
|
34
|
-
notifications:
|
|
35
|
-
email: false
|
|
36
|
-
irc:
|
|
37
|
-
on_success: always
|
|
38
|
-
on_failure: always
|
|
39
|
-
channels:
|
|
40
|
-
- "chat.freenode.org#voxpupuli-notifications"
|