metadata-json-lint 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +18 -0
- data/Gemfile +2 -0
- data/lib/metadata-json-lint/semantic_puppet_loader.rb +47 -0
- data/lib/metadata-json-lint/version_requirement.rb +1 -0
- data/lib/metadata_json_lint.rb +6 -5
- data/metadata-json-lint.gemspec +3 -3
- data/tests/non_array_requirements/Rakefile +2 -0
- data/tests/non_array_requirements/expected +1 -0
- data/tests/non_array_requirements/metadata.json +61 -0
- data/tests/test.sh +3 -0
- metadata +21 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fb2c947e575640401cda92a61f4b092a3670a0eac2c2bb94de66ce03b6d13d9f
|
4
|
+
data.tar.gz: 39c477f21af81c03b70e6e019fe38871d010dd8367561842b67c450d737f9679
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6248827093dbcbde3a6e49beed51c61f40ed8b28b443155f04b062ee24f52790004dcb30567f6eb1f750250e0c9df34c0965de264f0589e851ff9706e72b6f39
|
7
|
+
data.tar.gz: f66771e15322868d43eb8e140f734e710c84a9035f4f47870c095a1af5d06aca12e4b49be94828bce7ea21773989028d7aea8db912782a9cca6212b489de1824
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
+
## 2.1.0
|
9
|
+
|
10
|
+
### Changes
|
11
|
+
* Improve rendering of post\_install message by trimming unnecessary leading
|
12
|
+
spaces [#89](https://github.com/voxpupuli/metadata-json-lint/pull/89)
|
13
|
+
* Fail when checking version requirements if the version range is empty
|
14
|
+
[#91](https://github.com/voxpupuli/metadata-json-lint/pull/91)
|
15
|
+
* Pin `public_suffix` gem to < 3 for Ruby <= 2.0
|
16
|
+
[#93](https://github.com/voxpupuli/metadata-json-lint/pull/93)
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
* Prevent metadata-json-lint from crashing when the `requirements` field does
|
20
|
+
not contain an array
|
21
|
+
[#94](https://github.com/voxpupuli/metadata-json-lint/pull/94)
|
22
|
+
* Fix loading of `semantic_puppet` so that it supports using version vendored
|
23
|
+
in Puppet (if available)
|
24
|
+
[#96](https://github.com/voxpupuli/metadata-json-lint/pull/96)
|
25
|
+
|
8
26
|
## 2.0.2
|
9
27
|
|
10
28
|
### Changes
|
data/Gemfile
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
module MetadataJsonLint
|
2
|
+
# Attempts the various methods of loading SemanticPuppet.
|
3
|
+
module SemanticPuppetLoader
|
4
|
+
def try_load
|
5
|
+
try_load_puppet
|
6
|
+
return if defined?(SemanticPuppet)
|
7
|
+
|
8
|
+
try_load_semantic
|
9
|
+
return if defined?(SemanticPuppet)
|
10
|
+
|
11
|
+
try_load_semantic_puppet
|
12
|
+
return if defined?(SemanticPuppet)
|
13
|
+
|
14
|
+
warn 'Could not find semantic_puppet gem, falling back to internal functionality. Version checks may be less robust.'
|
15
|
+
end
|
16
|
+
module_function :try_load
|
17
|
+
|
18
|
+
# Most modern Puppet versions have SemanticPuppet vendored in the proper
|
19
|
+
# namespace and automatically load it at require time.
|
20
|
+
def try_load_puppet
|
21
|
+
require 'puppet'
|
22
|
+
rescue LoadError
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
module_function :try_load_puppet
|
26
|
+
|
27
|
+
# Older Puppet 4.x versions have SemanticPuppet vendored but under the
|
28
|
+
# Semantic namespace and require it on demand, so we need to load it
|
29
|
+
# ourselves and then alias it to SemanticPuppet for convenience.
|
30
|
+
def try_load_semantic
|
31
|
+
require 'semantic'
|
32
|
+
Kernel.const_set('SemanticPuppet', Semantic)
|
33
|
+
rescue LoadError
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
module_function :try_load_semantic
|
37
|
+
|
38
|
+
# If Puppet is not available or is a version that does not have
|
39
|
+
# SemanticPuppet vendored, try to load the external gem.
|
40
|
+
def try_load_semantic_puppet
|
41
|
+
require 'semantic_puppet'
|
42
|
+
rescue LoadError
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
module_function :try_load_semantic_puppet
|
46
|
+
end
|
47
|
+
end
|
@@ -7,6 +7,7 @@ module MetadataJsonLint
|
|
7
7
|
|
8
8
|
if defined?(SemanticPuppet::VersionRange)
|
9
9
|
@range = SemanticPuppet::VersionRange.parse(requirement)
|
10
|
+
raise ArgumentError, "Range matches no versions: \"#{requirement}\"" if @range == SemanticPuppet::VersionRange::EMPTY_RANGE
|
10
11
|
elsif requirement.match(/\A[a-z0-9*.\-^~><=|\t ]*\Z/i).nil?
|
11
12
|
raise ArgumentError, "Unparsable version range: \"#{requirement}\""
|
12
13
|
end
|
data/lib/metadata_json_lint.rb
CHANGED
@@ -2,11 +2,8 @@ require 'json'
|
|
2
2
|
require 'spdx-licenses'
|
3
3
|
require 'optparse'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
rescue LoadError
|
8
|
-
$stderr.puts('Could not find semantic_puppet gem, falling back to internal functionality. Version checks may be less robust.')
|
9
|
-
end
|
5
|
+
require 'metadata-json-lint/semantic_puppet_loader'
|
6
|
+
MetadataJsonLint::SemanticPuppetLoader.try_load
|
10
7
|
|
11
8
|
require 'metadata-json-lint/schema'
|
12
9
|
require 'metadata-json-lint/version_requirement'
|
@@ -133,6 +130,8 @@ module MetadataJsonLint
|
|
133
130
|
module_function :parse
|
134
131
|
|
135
132
|
def validate_requirements!(requirements)
|
133
|
+
return unless requirements.is_a?(Array)
|
134
|
+
|
136
135
|
requirements.each do |requirement|
|
137
136
|
if requirement['name'] == 'pe'
|
138
137
|
warn :requirements, "The 'pe' requirement is no longer supported by the Forge."
|
@@ -154,6 +153,8 @@ module MetadataJsonLint
|
|
154
153
|
rescue ArgumentError => e
|
155
154
|
# Raised when the version_requirement provided could not be parsed
|
156
155
|
error :dependencies, "Invalid 'version_requirement' field in metadata.json: #{e}"
|
156
|
+
# Skip to the next dependency
|
157
|
+
next
|
157
158
|
end
|
158
159
|
validate_version_requirement!(dep, requirement)
|
159
160
|
|
data/metadata-json-lint.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'date'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'metadata-json-lint'
|
5
|
-
s.version = '2.0
|
5
|
+
s.version = '2.1.0'
|
6
6
|
s.date = Date.today.to_s
|
7
7
|
s.summary = 'metadata-json-lint /path/to/metadata.json'
|
8
8
|
s.description = 'Utility to verify Puppet metadata.json files'
|
@@ -21,12 +21,12 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency 'json-schema', '~> 2.8'
|
22
22
|
s.add_development_dependency 'rake'
|
23
23
|
s.add_development_dependency 'rspec'
|
24
|
-
s.add_development_dependency 'rubocop'
|
24
|
+
s.add_development_dependency 'rubocop', '~> 0.50.0'
|
25
25
|
s.post_install_message = '
|
26
26
|
----------------------------------------------------------
|
27
27
|
For the most accurate results, the semantic_puppet
|
28
28
|
gem should be included within your Gemfile if you
|
29
29
|
use Puppet <= 4.8.x
|
30
30
|
----------------------------------------------------------
|
31
|
-
'
|
31
|
+
'.gsub(/^ /, '')
|
32
32
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
(ERROR) requirements: The property 'requirements' of type string did not match the following type: array
|
@@ -0,0 +1,61 @@
|
|
1
|
+
{
|
2
|
+
"name": "puppetlabs-postgresql",
|
3
|
+
"version": "3.4.1",
|
4
|
+
"author": "Inkling/Puppet Labs",
|
5
|
+
"summary": "PostgreSQL defined resource types",
|
6
|
+
"license": "Apache-2.0",
|
7
|
+
"source": "git://github.com/puppetlabs/puppet-postgresql.git",
|
8
|
+
"project_page": "https://github.com/puppetlabs/puppet-postgresql",
|
9
|
+
"issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues",
|
10
|
+
"operatingsystem_support": [
|
11
|
+
{
|
12
|
+
"operatingsystem": "RedHat",
|
13
|
+
"operatingsystemrelease": [
|
14
|
+
"5",
|
15
|
+
"6",
|
16
|
+
"7"
|
17
|
+
]
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"operatingsystem": "CentOS",
|
21
|
+
"operatingsystemrelease": [
|
22
|
+
"5",
|
23
|
+
"6",
|
24
|
+
"7"
|
25
|
+
]
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"operatingsystem": "OracleLinux",
|
29
|
+
"operatingsystemrelease": [
|
30
|
+
"5",
|
31
|
+
"6",
|
32
|
+
"7"
|
33
|
+
]
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"operatingsystem": "Scientific",
|
37
|
+
"operatingsystemrelease": [
|
38
|
+
"5",
|
39
|
+
"6",
|
40
|
+
"7"
|
41
|
+
]
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"operatingsystem": "Debian",
|
45
|
+
"operatingsystemrelease": [
|
46
|
+
"6",
|
47
|
+
"7"
|
48
|
+
]
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"operatingsystem": "Ubuntu",
|
52
|
+
"operatingsystemrelease": [
|
53
|
+
"10.04",
|
54
|
+
"12.04",
|
55
|
+
"14.04"
|
56
|
+
]
|
57
|
+
}
|
58
|
+
],
|
59
|
+
"requirements": "aoeu",
|
60
|
+
"dependencies": []
|
61
|
+
}
|
data/tests/test.sh
CHANGED
@@ -141,6 +141,9 @@ test "tags_no_array" $FAILURE
|
|
141
141
|
# Run with json output format
|
142
142
|
test "json_format" $FAILURE --format json
|
143
143
|
|
144
|
+
# Run against a metadata.json with a string for the requirements
|
145
|
+
test "non_array_requirements" $FAILURE
|
146
|
+
|
144
147
|
# Test running without specifying file to parse
|
145
148
|
cd perfect
|
146
149
|
bundle exec metadata-json-lint
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metadata-json-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.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: 2018-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spdx-licenses
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.50.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.50.0
|
83
83
|
description: Utility to verify Puppet metadata.json files
|
84
84
|
email: voxpupuli@groups.io
|
85
85
|
executables:
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- bin/metadata-json-lint
|
101
101
|
- lib/metadata-json-lint/rake_task.rb
|
102
102
|
- lib/metadata-json-lint/schema.rb
|
103
|
+
- lib/metadata-json-lint/semantic_puppet_loader.rb
|
103
104
|
- lib/metadata-json-lint/version_requirement.rb
|
104
105
|
- lib/metadata_json_lint.rb
|
105
106
|
- metadata-json-lint.gemspec
|
@@ -138,6 +139,9 @@ files:
|
|
138
139
|
- tests/no_pe/metadata.json
|
139
140
|
- tests/no_version_range/Rakefile
|
140
141
|
- tests/no_version_range/metadata.json
|
142
|
+
- tests/non_array_requirements/Rakefile
|
143
|
+
- tests/non_array_requirements/expected
|
144
|
+
- tests/non_array_requirements/metadata.json
|
141
145
|
- tests/noname/Rakefile
|
142
146
|
- tests/noname/expected
|
143
147
|
- tests/noname/metadata.json
|
@@ -169,10 +173,13 @@ homepage: http://github.com/voxpupuli/metadata-json-lint
|
|
169
173
|
licenses:
|
170
174
|
- Apache-2.0
|
171
175
|
metadata: {}
|
172
|
-
post_install_message:
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
+
post_install_message: |2
|
177
|
+
|
178
|
+
----------------------------------------------------------
|
179
|
+
For the most accurate results, the semantic_puppet
|
180
|
+
gem should be included within your Gemfile if you
|
181
|
+
use Puppet <= 4.8.x
|
182
|
+
----------------------------------------------------------
|
176
183
|
rdoc_options: []
|
177
184
|
require_paths:
|
178
185
|
- lib
|
@@ -188,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
195
|
version: '0'
|
189
196
|
requirements: []
|
190
197
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.7.5
|
192
199
|
signing_key:
|
193
200
|
specification_version: 4
|
194
201
|
summary: metadata-json-lint /path/to/metadata.json
|
@@ -228,6 +235,9 @@ test_files:
|
|
228
235
|
- tests/no_pe/metadata.json
|
229
236
|
- tests/no_version_range/Rakefile
|
230
237
|
- tests/no_version_range/metadata.json
|
238
|
+
- tests/non_array_requirements/Rakefile
|
239
|
+
- tests/non_array_requirements/expected
|
240
|
+
- tests/non_array_requirements/metadata.json
|
231
241
|
- tests/noname/Rakefile
|
232
242
|
- tests/noname/expected
|
233
243
|
- tests/noname/metadata.json
|