puppet-syntax 2.6.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +16 -1
- data/Gemfile +1 -4
- data/README.md +66 -51
- data/lib/puppet-syntax.rb +0 -9
- data/lib/puppet-syntax/manifests.rb +1 -5
- data/lib/puppet-syntax/tasks/puppet-syntax.rb +0 -28
- data/lib/puppet-syntax/templates.rb +0 -4
- data/lib/puppet-syntax/version.rb +1 -1
- data/puppet-syntax.gemspec +2 -0
- data/spec/puppet-syntax/manifests_spec.rb +15 -180
- data/spec/puppet-syntax/templates_spec.rb +31 -55
- data/spec/puppet-syntax_spec.rb +0 -15
- metadata +3 -4
- data/jenkins.sh +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5efa461330416f6cffe0518ff6af0c111b5c7731d0f61ad10fc52947181a5d7d
|
4
|
+
data.tar.gz: 5050d5e596af634f1280d41155e5397e9dd8e21e21cae6f9c5ed464b5ab76026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba169dc6d36d2d4fc68a661b8fbd4e1f090ecb94d978c77c692003487b82b86646e3965a42afe5e50b654aaae904ec89c4fbfb5576f4d3014adabeedaf90b7cb
|
7
|
+
data.tar.gz: b1be324753efdaa626f242d8d53ffad7e81804bb02334a8200d610a880c038f79bda94af125b7188c6d52ff4f00589cd93637614c3d5a37549bd18d3ffb15db9
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -3,7 +3,7 @@ dist: bionic
|
|
3
3
|
language: ruby
|
4
4
|
# Workaround https://github.com/bundler/bundler/issues/3558
|
5
5
|
before_install: gem install bundler
|
6
|
-
install: bundle install --jobs 4 --retry 2 --without development
|
6
|
+
install: bundle install --jobs 4 --retry 2 --without development release
|
7
7
|
script: bundle exec rake
|
8
8
|
rvm:
|
9
9
|
- 2.4.4
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,22 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [v3.0.0](https://github.com/voxpupuli/puppet-syntax/tree/v3.0.0) (2020-05-09)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.6.1...v3.0.0)
|
8
|
+
|
9
|
+
**Breaking changes:**
|
10
|
+
|
11
|
+
- Drop legacy code to support Puppet \< 5 and Ruby \< 2.4 [\#120](https://github.com/voxpupuli/puppet-syntax/pull/120) ([ekohl](https://github.com/ekohl))
|
12
|
+
|
13
|
+
**Implemented enhancements:**
|
14
|
+
|
15
|
+
- Migrate Changelog to GCG [\#93](https://github.com/voxpupuli/puppet-syntax/issues/93)
|
16
|
+
|
17
|
+
**Merged pull requests:**
|
18
|
+
|
19
|
+
- cleanup README.md / fix markdown linter warnings [\#119](https://github.com/voxpupuli/puppet-syntax/pull/119) ([bastelfreak](https://github.com/bastelfreak))
|
20
|
+
|
5
21
|
## [v2.6.1](https://github.com/voxpupuli/puppet-syntax/tree/v2.6.1) (2020-01-11)
|
6
22
|
|
7
23
|
[Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.6.0...v2.6.1)
|
@@ -26,7 +42,6 @@ All notable changes to this project will be documented in this file.
|
|
26
42
|
|
27
43
|
**Merged pull requests:**
|
28
44
|
|
29
|
-
- Test on ruby 2.6 [\#111](https://github.com/voxpupuli/puppet-syntax/pull/111) ([alexjfisher](https://github.com/alexjfisher))
|
30
45
|
- Adding KMS tags to allowed EYAML methods [\#105](https://github.com/voxpupuli/puppet-syntax/pull/105) ([craigwatson](https://github.com/craigwatson))
|
31
46
|
|
32
47
|
## [v2.5.0](https://github.com/voxpupuli/puppet-syntax/tree/v2.5.0) (2019-07-07)
|
data/Gemfile
CHANGED
@@ -21,13 +21,10 @@ gemspec
|
|
21
21
|
# But only if the environment variable is set
|
22
22
|
gem 'puppet', *location_for(ENV['PUPPET_VERSION'] || '>= 5') if ENV['PUPPET_VERSION']
|
23
23
|
|
24
|
-
# older version required for ruby 1.9 compat, as it is pulled in as dependency of puppet, this has to be carried by the module
|
25
|
-
gem 'json_pure', '<= 2.0.1'
|
26
|
-
|
27
24
|
group :test do
|
28
25
|
gem 'rspec'
|
29
26
|
end
|
30
27
|
|
31
28
|
group :release do
|
32
|
-
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator'
|
29
|
+
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator'
|
33
30
|
end
|
data/README.md
CHANGED
@@ -4,36 +4,40 @@
|
|
4
4
|
|
5
5
|
# Puppet::Syntax
|
6
6
|
|
7
|
-
Puppet::Syntax checks for correct syntax in Puppet manifests, templates, and
|
7
|
+
Puppet::Syntax checks for correct syntax in Puppet manifests, templates, and
|
8
|
+
Hiera YAML.
|
8
9
|
|
9
10
|
## Version support
|
10
11
|
|
11
12
|
Puppet::Syntax is supported with:
|
12
13
|
|
13
|
-
- Puppet >=
|
14
|
-
- Ruby >=
|
14
|
+
- Puppet >= 5.0 that provides the `validate` face.
|
15
|
+
- Ruby >= 2.4
|
15
16
|
|
16
17
|
For the specific versions that we test against, see the [TravisCI config](.travis.yml).
|
17
18
|
|
18
|
-
If you're using `puppetlabs_spec_helper/rake_tasks` and getting unexpected non-zero exit codes, upgrade to [puppetlabs_spec_helper][psh] version 0.8.0 or greater. Versions of `puppetlabs_spec_helper` prior to 0.8.0 conflicted with Puppet::Syntax.
|
19
|
-
|
20
|
-
[psh]: https://github.com/puppetlabs/puppetlabs_spec_helper
|
21
|
-
|
22
19
|
## Installation
|
23
20
|
|
24
|
-
To install Puppet::Syntax, either add it to your module's Gemfile or install
|
21
|
+
To install Puppet::Syntax, either add it to your module's Gemfile or install
|
22
|
+
the gem manually.
|
25
23
|
|
26
24
|
* To install with the Gemfile, add:
|
27
25
|
|
28
|
-
|
26
|
+
```ruby
|
27
|
+
gem 'puppet-syntax'
|
28
|
+
```
|
29
29
|
|
30
30
|
And then execute:
|
31
31
|
|
32
|
-
|
32
|
+
```sh
|
33
|
+
bundle install
|
34
|
+
```
|
33
35
|
|
34
36
|
* To install the gem yourself, run:
|
35
37
|
|
36
|
-
|
38
|
+
```sh
|
39
|
+
gem install puppet-syntax
|
40
|
+
```
|
37
41
|
|
38
42
|
## Configuration
|
39
43
|
|
@@ -41,75 +45,85 @@ To configure Puppet::Syntax, add any of the following settings to your `Rakefile
|
|
41
45
|
|
42
46
|
* To exclude certain paths from the syntax checks, set:
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
PuppetSyntax.future_parser = true
|
48
|
+
```ruby
|
49
|
+
PuppetSyntax.exclude_paths = ["vendor/**/*"]
|
50
|
+
```
|
49
51
|
|
50
52
|
* To configure specific paths for the Hiera syntax check, specify `hieradata_paths`. This is useful if you use Hiera data inside your module.
|
51
53
|
|
52
|
-
|
54
|
+
```ruby
|
55
|
+
PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"]
|
56
|
+
```
|
53
57
|
|
54
58
|
* To configure specific paths for the Puppet syntax checks or for the templates checks, specify `manifests_paths` or `templates_paths` respectively. This is useful if you want to check specific paths only.
|
55
59
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
PuppetSyntax.app_management = true
|
62
|
-
|
63
|
-
The `app_management` setting is supported with Puppet 4.3 or greater and is off by default. In Puppet 5, app_management is always enabled.
|
60
|
+
```ruby
|
61
|
+
PuppetSyntax.manifests_paths = ["**/environments/future/*.pp"]
|
62
|
+
PuppetSyntax.templates_paths = ["**/modules/**/templates/*.erb"]
|
63
|
+
```
|
64
64
|
|
65
65
|
* To ignore deprecation warnings, disable `fail_on_deprecation_notices`. By default, `puppet-syntax` fails if it encounters Puppet deprecation notices. If you are working with a legacy code base and want to ignore such non-fatal warnings, you might want to override the default behavior.
|
66
66
|
|
67
|
-
|
67
|
+
```ruby
|
68
|
+
PuppetSyntax.fail_on_deprecation_notices = false
|
69
|
+
```
|
68
70
|
|
69
71
|
* To enable a syntax check on Hiera keys, set:
|
70
72
|
|
71
|
-
|
73
|
+
```ruby
|
74
|
+
PuppetSyntax.check_hiera_keys = true
|
75
|
+
```
|
72
76
|
|
73
|
-
|
77
|
+
This reports common mistakes in key names in Hiera files, such as:
|
74
78
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
* Leading `::` in keys, such as: `::notsotypical::warning2: true`.
|
80
|
+
* Single colon scope separators, such as: `:picky::warning5: true`.
|
81
|
+
* Invalid camel casing, such as: `noCamelCase::warning3: true`.
|
82
|
+
* Use of hyphens, such as: `no-hyphens::warning4: true`.
|
79
83
|
|
80
84
|
## Usage
|
81
85
|
|
82
86
|
* To enable Puppet::Syntax, include the following in your module's `Rakefile`:
|
83
87
|
|
84
|
-
|
88
|
+
```ruby
|
89
|
+
require 'puppet-syntax/tasks/puppet-syntax'
|
90
|
+
```
|
85
91
|
|
86
|
-
|
92
|
+
For Continuous Integration, use Puppet::Syntax in conjunction with `puppet-lint`
|
93
|
+
and spec tests. Add the following to your module's `Rakefile`:
|
87
94
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
95
|
+
```ruby
|
96
|
+
task :test => [
|
97
|
+
:syntax,
|
98
|
+
:lint,
|
99
|
+
:spec,
|
100
|
+
]
|
101
|
+
```
|
93
102
|
|
94
103
|
* To test all manifests and templates, relative to the location of the `Rakefile`, run:
|
95
104
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
105
|
+
```
|
106
|
+
$ bundle exec rake syntax
|
107
|
+
---> syntax:manifests
|
108
|
+
---> syntax:templates
|
109
|
+
---> syntax:hiera:yaml
|
110
|
+
```
|
100
111
|
|
101
112
|
* To return a non-zero exit code and an error message on any failures, run:
|
102
113
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
114
|
+
```
|
115
|
+
$ bundle exec rake syntax
|
116
|
+
---> syntax:manifests
|
117
|
+
rake aborted!
|
118
|
+
Could not parse for environment production: Syntax error at end of file at demo.pp:2
|
119
|
+
Tasks: TOP => syntax => syntax:manifests
|
120
|
+
(See full trace by running task with --trace)
|
121
|
+
```
|
109
122
|
|
110
123
|
## Checks
|
111
124
|
|
112
|
-
Puppet::Syntax makes the following checks in the directories and subdirectories
|
125
|
+
Puppet::Syntax makes the following checks in the directories and subdirectories
|
126
|
+
of the module, relative to the location of the `Rakefile`.
|
113
127
|
|
114
128
|
### Hiera
|
115
129
|
|
@@ -135,7 +149,8 @@ Checks `.erb` files in the module for syntax errors.
|
|
135
149
|
|
136
150
|
Checks `.epp` files in the module for syntax errors.
|
137
151
|
|
138
|
-
EPP checks are supported in Puppet 4 or greater, or in Puppet 3 with the future
|
152
|
+
EPP checks are supported in Puppet 4 or greater, or in Puppet 3 with the future
|
153
|
+
parser enabled.
|
139
154
|
|
140
155
|
## Contributing
|
141
156
|
|
data/lib/puppet-syntax.rb
CHANGED
@@ -6,7 +6,6 @@ require "puppet/version"
|
|
6
6
|
|
7
7
|
module PuppetSyntax
|
8
8
|
@exclude_paths = []
|
9
|
-
@future_parser = false
|
10
9
|
@hieradata_paths = [
|
11
10
|
"**/data/**/*.*{yaml,yml}",
|
12
11
|
"hieradata/**/*.*{yaml,yml}",
|
@@ -20,23 +19,15 @@ module PuppetSyntax
|
|
20
19
|
'**/templates/**/*.epp'
|
21
20
|
]
|
22
21
|
@fail_on_deprecation_notices = true
|
23
|
-
@app_management = Puppet.version.to_i >= 5 ? true : false
|
24
22
|
@check_hiera_keys = false
|
25
23
|
|
26
24
|
class << self
|
27
25
|
attr_accessor :exclude_paths,
|
28
|
-
:future_parser,
|
29
26
|
:hieradata_paths,
|
30
27
|
:manifests_paths,
|
31
28
|
:templates_paths,
|
32
29
|
:fail_on_deprecation_notices,
|
33
30
|
:epp_only,
|
34
31
|
:check_hiera_keys
|
35
|
-
attr_reader :app_management
|
36
|
-
|
37
|
-
def app_management=(app_management)
|
38
|
-
raise 'app_management cannot be disabled on Puppet 5 or higher' if Puppet.version.to_i >= 5 && !app_management
|
39
|
-
@app_management = app_management
|
40
|
-
end
|
41
32
|
end
|
42
33
|
end
|
@@ -8,9 +8,7 @@ module PuppetSyntax
|
|
8
8
|
|
9
9
|
output = []
|
10
10
|
|
11
|
-
|
12
|
-
Puppet::Test::TestHelper.initialize
|
13
|
-
end
|
11
|
+
Puppet::Test::TestHelper.initialize
|
14
12
|
Puppet::Test::TestHelper.before_all_tests
|
15
13
|
called_before_all_tests = true
|
16
14
|
|
@@ -62,8 +60,6 @@ module PuppetSyntax
|
|
62
60
|
|
63
61
|
private
|
64
62
|
def validate_manifest(file)
|
65
|
-
Puppet[:parser] = 'future' if PuppetSyntax.future_parser and Puppet.version.to_i < 4
|
66
|
-
Puppet[:app_management] = true if PuppetSyntax.app_management && (Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0 && Puppet.version.to_i < 5)
|
67
63
|
Puppet[:tasks] = true if Puppet::Util::Package.versioncmp(Puppet.version, '5.4.0') >= 0 and file.match(/.*plans\/.*\.pp$/)
|
68
64
|
Puppet::Face[:parser, :current].validate(file)
|
69
65
|
end
|
@@ -27,42 +27,14 @@ module PuppetSyntax
|
|
27
27
|
def initialize(*args)
|
28
28
|
desc 'Syntax check Puppet manifests and templates'
|
29
29
|
task :syntax => [
|
30
|
-
'syntax:check_puppetlabs_spec_helper',
|
31
30
|
'syntax:manifests',
|
32
31
|
'syntax:templates',
|
33
32
|
'syntax:hiera',
|
34
33
|
]
|
35
34
|
|
36
35
|
namespace :syntax do
|
37
|
-
task :check_puppetlabs_spec_helper do
|
38
|
-
psh_present = task(:syntax).actions.any? { |a|
|
39
|
-
a.inspect.match(/puppetlabs_spec_helper\/rake_tasks\.rb:\d+/)
|
40
|
-
}
|
41
|
-
|
42
|
-
if psh_present
|
43
|
-
$stderr.puts <<-EOS
|
44
|
-
[WARNING] A conflicting :syntax rake task has been defined by
|
45
|
-
puppetlabs_spec_helper/rake_tasks. You should either disable this or upgrade
|
46
|
-
to puppetlabs_spec_helper >= 0.8.0 which now uses puppet-syntax.
|
47
|
-
EOS
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
36
|
desc 'Syntax check Puppet manifests'
|
52
37
|
task :manifests do |t|
|
53
|
-
if Puppet.version.to_i >= 4 and PuppetSyntax.future_parser
|
54
|
-
$stderr.puts <<-EOS
|
55
|
-
[INFO] Puppet 4 has been detected and `future_parser` has been set to
|
56
|
-
'true'. The `future_parser setting will be ignored.
|
57
|
-
EOS
|
58
|
-
end
|
59
|
-
if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') < 0 and PuppetSyntax.app_management
|
60
|
-
$stderr.puts <<-EOS
|
61
|
-
[WARNING] Puppet `app_management` has been detected but the Puppet
|
62
|
-
version is less then 4.3. The `app_management` setting will be ignored.
|
63
|
-
EOS
|
64
|
-
end
|
65
|
-
|
66
38
|
$stderr.puts "---> #{t.name}"
|
67
39
|
|
68
40
|
c = PuppetSyntax::Manifests.new
|
data/puppet-syntax.gemspec
CHANGED
@@ -28,15 +28,9 @@ describe PuppetSyntax::Manifests do
|
|
28
28
|
files = fixture_manifests('fail_error.pp')
|
29
29
|
output, has_errors = subject.check(files)
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
expect(has_errors).to eq(true)
|
35
|
-
else
|
36
|
-
expect(output.size).to eq(1)
|
37
|
-
expect(output[0]).to match(/Syntax error at .*:3$/)
|
38
|
-
expect(has_errors).to eq(true)
|
39
|
-
end
|
31
|
+
expect(output.size).to eq(3)
|
32
|
+
expect(output[2]).to match(/2 errors. Giving up/)
|
33
|
+
expect(has_errors).to eq(true)
|
40
34
|
end
|
41
35
|
|
42
36
|
it 'should return a warning from an invalid file' do
|
@@ -72,181 +66,22 @@ describe PuppetSyntax::Manifests do
|
|
72
66
|
output, has_errors = subject.check(files)
|
73
67
|
|
74
68
|
expect(has_errors).to eq(true)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
expect(output[4]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
|
82
|
-
else
|
83
|
-
expect(output.size).to eq(3)
|
84
|
-
expect(output[0]).to match(/Syntax error at '\}' .*:3$/)
|
85
|
-
expect(output[1]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
|
86
|
-
expect(output[2]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
|
87
|
-
end
|
69
|
+
expect(output.size).to eq(5)
|
70
|
+
expect(output[0]).to match(/This Name has no effect. A Host Class Definition can not end with a value-producing expression without other effect \(file: \S*\/fail_error.pp, line: 2, column: 32\)$/)
|
71
|
+
expect(output[1]).to match(/This Name has no effect. A value was produced and then forgotten \(one or more preceding expressions may have the wrong form\) \(file: \S*\/fail_error.pp, line: 2, column: 3\)$/)
|
72
|
+
expect(output[2]).to match('2 errors. Giving up')
|
73
|
+
expect(output[3]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
|
74
|
+
expect(output[4]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
|
88
75
|
end
|
89
76
|
|
90
77
|
describe 'deprecation notices' do
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
it 'should instead be failures' do
|
95
|
-
files = fixture_manifests('deprecation_notice.pp')
|
96
|
-
output, has_errors = subject.check(files)
|
97
|
-
|
98
|
-
expect(has_errors).to eq(true)
|
99
|
-
expect(output.size).to eq(1)
|
100
|
-
expect(output[0]).to match (/Node inheritance is not supported in Puppet >= 4.0.0/)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
when 3.7, 3.8
|
104
|
-
context 'on puppet 3.7 and 3.8' do
|
105
|
-
it 'should return deprecation notices as warnings' do
|
106
|
-
files = fixture_manifests('deprecation_notice.pp')
|
107
|
-
output, has_errors = subject.check(files)
|
108
|
-
|
109
|
-
expect(has_errors).to eq(false)
|
110
|
-
expect(output.size).to eq(2)
|
111
|
-
expect(output[0]).to match(/The use of 'import' is deprecated/)
|
112
|
-
expect(output[1]).to match(/Deprecation notice:/)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
when 3.5, 3.6
|
116
|
-
context 'on puppet 3.5 and 3.6' do
|
117
|
-
it 'should return deprecation notices as warnings' do
|
118
|
-
files = fixture_manifests('deprecation_notice.pp')
|
119
|
-
output, has_errors = subject.check(files)
|
120
|
-
|
121
|
-
expect(has_errors).to eq(false)
|
122
|
-
expect(output.size).to eq(1)
|
123
|
-
expect(output[0]).to match(/The use of 'import' is deprecated/)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
when 3.0..3.4
|
127
|
-
context 'on puppet 3.0 to 3.4' do
|
128
|
-
it 'should not print deprecation notices' do
|
129
|
-
files = fixture_manifests('deprecation_notice.pp')
|
130
|
-
output, has_errors = subject.check(files)
|
131
|
-
|
132
|
-
expect(output).to eq([])
|
133
|
-
expect(has_errors).to eq(false)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe 'app_management' do
|
140
|
-
after do
|
141
|
-
PuppetSyntax.app_management = false if Puppet.version.to_i < 5
|
142
|
-
end
|
143
|
-
|
144
|
-
context 'app_management = false (default)', :if => (Puppet.version.to_i < 5) do
|
145
|
-
it 'should fail to parse an application manifest' do
|
146
|
-
|
147
|
-
files = fixture_manifests(['test_app.pp'])
|
148
|
-
output,has_errors = subject.check(files)
|
149
|
-
|
150
|
-
expect(has_errors).to eq(true)
|
151
|
-
expect(output).to include(/error/)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
context 'app_management = true' do
|
155
|
-
before(:each) {
|
156
|
-
PuppetSyntax.app_management = true
|
157
|
-
}
|
158
|
-
if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0
|
159
|
-
it 'should successfully parse an application manifest on Puppet >= 4.3.0' do
|
160
|
-
expect(PuppetSyntax.app_management).to eq(true)
|
161
|
-
|
162
|
-
files = fixture_manifests(['test_app.pp'])
|
163
|
-
output,has_errors = subject.check(files)
|
164
|
-
|
165
|
-
expect(output.size).to eq(0)
|
166
|
-
expect(has_errors).to eq(false)
|
167
|
-
end
|
168
|
-
else
|
169
|
-
it 'should fail to parse an application manifest on Puppet < 4.3.0' do
|
170
|
-
expect(PuppetSyntax.app_management).to eq(true)
|
171
|
-
|
172
|
-
files = fixture_manifests(['test_app.pp'])
|
173
|
-
output,has_errors = subject.check(files)
|
174
|
-
|
175
|
-
expect(output).to include(/error/)
|
176
|
-
expect(has_errors).to eq(true)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
|
183
|
-
describe 'future_parser' do
|
184
|
-
context 'future_parser = false (default)' do
|
185
|
-
if Puppet::Util::Package.versioncmp(Puppet.version, '4.0') < 0
|
186
|
-
it 'should fail without setting future option to true on future manifest on Puppet < 4.0.0' do
|
187
|
-
expect(PuppetSyntax.future_parser).to eq(false)
|
188
|
-
|
189
|
-
files = fixture_manifests(['future_syntax.pp'])
|
190
|
-
output, has_errors = subject.check(files)
|
191
|
-
|
192
|
-
expect(output.size).to eq(1)
|
193
|
-
expect(output[0]).to match(/Syntax error at '='; expected '\}' .*:2$/)
|
194
|
-
expect(has_errors).to eq(true)
|
195
|
-
end
|
196
|
-
else
|
197
|
-
it 'should succeed on Puppet >= 4.0.0' do
|
198
|
-
expect(PuppetSyntax.future_parser).to eq(false)
|
78
|
+
it 'should instead be failures' do
|
79
|
+
files = fixture_manifests('deprecation_notice.pp')
|
80
|
+
output, has_errors = subject.check(files)
|
199
81
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
expect(output.size).to eq(0)
|
204
|
-
expect(has_errors).to eq(false)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
context 'future_parser = true' do
|
210
|
-
before(:each) {
|
211
|
-
PuppetSyntax.future_parser = true
|
212
|
-
}
|
213
|
-
|
214
|
-
if Puppet::Util::Package.versioncmp(Puppet.version, '3.2') >= 0 and Puppet.version.to_i < 4
|
215
|
-
context 'Puppet >= 3.2 < 4' do
|
216
|
-
it 'should pass with future option set to true on future manifest' do
|
217
|
-
files = fixture_manifests(['future_syntax.pp'])
|
218
|
-
output, has_errors = subject.check(files)
|
219
|
-
|
220
|
-
expect(output).to eq([])
|
221
|
-
expect(has_errors).to eq(false)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
context 'Puppet >= 3.7 < 4' do
|
225
|
-
# Certain elements of the future parser weren't added until 3.7
|
226
|
-
if Puppet::Util::Package.versioncmp(Puppet.version, '3.7') >= 0
|
227
|
-
it 'should fail on what were deprecation notices in the non-future parser' do
|
228
|
-
files = fixture_manifests('deprecation_notice.pp')
|
229
|
-
output, has_errors = subject.check(files)
|
230
|
-
|
231
|
-
expect(output.size).to eq(1)
|
232
|
-
expect(output[0]).to match(/Node inheritance is not supported/)
|
233
|
-
expect(has_errors).to eq(true)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
elsif Puppet::Util::Package.versioncmp(Puppet.version, '3.2') < 0
|
238
|
-
context 'Puppet < 3.2' do
|
239
|
-
it 'should return an error that the parser option is not supported' do
|
240
|
-
files = fixture_manifests(['future_syntax.pp'])
|
241
|
-
output, has_errors = subject.check(files)
|
242
|
-
|
243
|
-
expect(output.size).to eq(1)
|
244
|
-
expect(output[0]).to match("Attempt to assign a value to unknown configuration parameter :parser")
|
245
|
-
expect(has_errors).to eq(true)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
82
|
+
expect(has_errors).to eq(true)
|
83
|
+
expect(output.size).to eq(1)
|
84
|
+
expect(output[0]).to match (/Node inheritance is not supported in Puppet >= 4.0.0/)
|
249
85
|
end
|
250
86
|
end
|
251
|
-
|
252
87
|
end
|
@@ -74,71 +74,47 @@ describe PuppetSyntax::Templates do
|
|
74
74
|
expect(res).to match([])
|
75
75
|
end
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
file = fixture_templates('pass.epp')
|
81
|
-
expect{ subject.check(file) }.to raise_error(/Cannot validate EPP without Puppet 4/)
|
82
|
-
end
|
83
|
-
|
84
|
-
context "when the 'epp_only' options is set" do
|
85
|
-
before(:each) {
|
86
|
-
PuppetSyntax.epp_only = true
|
87
|
-
}
|
88
|
-
|
89
|
-
it 'should throw an exception for any file' do
|
90
|
-
file = fixture_templates('pass.erb')
|
91
|
-
expect{ subject.check(file) }.to raise_error(/Cannot validate EPP without Puppet 4/)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
if Puppet.version.to_f >= 3.7
|
98
|
-
context 'on Puppet >= 3.7' do
|
99
|
-
it 'should return nothing from a valid file' do
|
100
|
-
files = fixture_templates('pass.epp')
|
101
|
-
res = subject.check(files)
|
77
|
+
it 'should return nothing from a valid file' do
|
78
|
+
files = fixture_templates('pass.epp')
|
79
|
+
res = subject.check(files)
|
102
80
|
|
103
|
-
|
104
|
-
|
81
|
+
expect(res).to match([])
|
82
|
+
end
|
105
83
|
|
106
|
-
|
107
|
-
|
108
|
-
|
84
|
+
it 'should catch SyntaxError' do
|
85
|
+
files = fixture_templates('fail_error.epp')
|
86
|
+
res = subject.check(files)
|
109
87
|
|
110
|
-
|
111
|
-
|
112
|
-
|
88
|
+
expect(res.size).to eq(1)
|
89
|
+
expect(res[0]).to match(/This Type-Name has no effect/)
|
90
|
+
end
|
113
91
|
|
114
|
-
|
115
|
-
|
116
|
-
|
92
|
+
it 'should read more than one valid file' do
|
93
|
+
files = fixture_templates(['pass.epp', 'pass_also.epp'])
|
94
|
+
res = subject.check(files)
|
117
95
|
|
118
|
-
|
119
|
-
|
96
|
+
expect(res).to match([])
|
97
|
+
end
|
120
98
|
|
121
|
-
|
122
|
-
|
123
|
-
|
99
|
+
it 'should continue after finding an error in the first file' do
|
100
|
+
files = fixture_templates(['fail_error.epp', 'fail_error_also.epp'])
|
101
|
+
res = subject.check(files)
|
124
102
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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\)/)
|
106
|
+
end
|
129
107
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
108
|
+
context "when the 'epp_only' options is set" do
|
109
|
+
before(:each) {
|
110
|
+
PuppetSyntax.epp_only = true
|
111
|
+
}
|
134
112
|
|
135
|
-
|
136
|
-
|
137
|
-
|
113
|
+
it 'should process an ERB as EPP and find an error' do
|
114
|
+
files = fixture_templates('pass.erb')
|
115
|
+
res = subject.check(files)
|
138
116
|
|
139
|
-
|
140
|
-
end
|
141
|
-
end
|
117
|
+
expect(res.size).to eq(1)
|
142
118
|
end
|
143
119
|
end
|
144
120
|
end
|
data/spec/puppet-syntax_spec.rb
CHANGED
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetSyntax do
|
4
4
|
after do
|
5
5
|
PuppetSyntax.exclude_paths = []
|
6
|
-
PuppetSyntax.app_management = false if Puppet.version.to_i < 5
|
7
6
|
end
|
8
7
|
|
9
8
|
it 'should default exclude_paths to include the pkg directory' do
|
@@ -20,20 +19,6 @@ describe PuppetSyntax do
|
|
20
19
|
expect(PuppetSyntax.exclude_paths).to eq(["foo"])
|
21
20
|
end
|
22
21
|
|
23
|
-
it 'should support future parser setting' do
|
24
|
-
PuppetSyntax.future_parser = true
|
25
|
-
expect(PuppetSyntax.future_parser).to eq(true)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should support app_management setting setting' do
|
29
|
-
PuppetSyntax.app_management = true
|
30
|
-
expect(PuppetSyntax.app_management).to eq(true)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should raise error when app_management is disabled on 5.x', :if => (Puppet.version.to_i >= 5) do
|
34
|
-
expect { PuppetSyntax.app_management = false }.to raise_error(/app_management cannot be disabled on Puppet 5 or higher/)
|
35
|
-
end
|
36
|
-
|
37
22
|
it 'should support a fail_on_deprecation_notices setting' do
|
38
23
|
PuppetSyntax.fail_on_deprecation_notices = false
|
39
24
|
expect(PuppetSyntax.fail_on_deprecation_notices).to eq(false)
|
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
|
+
version: 3.0.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: 2020-
|
11
|
+
date: 2020-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -95,7 +95,6 @@ files:
|
|
95
95
|
- LICENSE.txt
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
|
-
- jenkins.sh
|
99
98
|
- lib/puppet-syntax.rb
|
100
99
|
- lib/puppet-syntax/hiera.rb
|
101
100
|
- lib/puppet-syntax/manifests.rb
|
@@ -149,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
148
|
requirements:
|
150
149
|
- - ">="
|
151
150
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
151
|
+
version: '2.4'
|
153
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
153
|
requirements:
|
155
154
|
- - ">="
|
data/jenkins.sh
DELETED