pdk-akerl 1.8.0.1 → 1.9.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -1
- data/lib/pdk/cli/bundle.rb +1 -1
- data/lib/pdk/cli/exec.rb +4 -4
- data/lib/pdk/cli/validate.rb +1 -1
- data/lib/pdk/module/metadata.rb +2 -1
- data/lib/pdk/module/templatedir.rb +16 -8
- data/lib/pdk/module.rb +4 -3
- data/lib/pdk/template_file.rb +6 -0
- data/lib/pdk/util/ruby_version.rb +3 -2
- data/lib/pdk/util.rb +16 -4
- data/lib/pdk/validate/base_validator.rb +10 -4
- data/lib/pdk/validate/puppet/puppet_syntax.rb +26 -1
- data/lib/pdk/validate/yaml/syntax.rb +123 -0
- data/lib/pdk/validate/yaml_validator.rb +31 -0
- data/lib/pdk/validate.rb +8 -1
- data/lib/pdk/version.rb +1 -1
- data/locales/pdk.pot +37 -25
- metadata +57 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39f58183065dc5b1f230bcffb0d5b9cb889b17c3a60185c824c34d2ab48e8787
|
4
|
+
data.tar.gz: 32a54051654794a36a5de1a34980a469a5e0b11e9a6d1c5ad18407b764dc7728
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5d3c027319d74685372a715a7ae858bc3ee219be81e4d26d31d60e8a89d68a9952f6547c4cd45c8ef23683dbf399a892cb75f11e41a755afaaf36deb9407cce
|
7
|
+
data.tar.gz: 45a778d76f7d8ec4ff09082c0710c2a0b291dce8162287ca4ef7f705e4e8f34e5ad534664d3a23ca25ab0a1986b834f654f2c833559e3d8a36d824bba06877d2
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,54 @@ All changes to this repo will be documented in this file.
|
|
4
4
|
See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) for a high-level summary.
|
5
5
|
|
6
6
|
|
7
|
-
## [v1.
|
7
|
+
## [v1.9.1](https://github.com/puppetlabs/pdk/tree/v1.9.1) (2019-03-01)
|
8
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.9.0...v1.9.1)
|
9
|
+
|
10
|
+
**Fixed bugs:**
|
11
|
+
|
12
|
+
- \(IMAGES-1037\) Make sure our paths are used [\#630](https://github.com/puppetlabs/pdk/pull/630) ([mihaibuzgau](https://github.com/mihaibuzgau))
|
13
|
+
- \(PDK-1266\) Clear modulepath value when validating manifest syntax [\#629](https://github.com/puppetlabs/pdk/pull/629) ([rodjek](https://github.com/rodjek))
|
14
|
+
- \(PDK-1272\) Convert user/module module names to user-module [\#626](https://github.com/puppetlabs/pdk/pull/626) ([rodjek](https://github.com/rodjek))
|
15
|
+
- \(PDK-1276\) Skip non-file YAML validator targets [\#625](https://github.com/puppetlabs/pdk/pull/625) ([rodjek](https://github.com/rodjek))
|
16
|
+
- \(PDK-1273\) Whitelist Ruby symbols in YAML validator [\#624](https://github.com/puppetlabs/pdk/pull/624) ([rodjek](https://github.com/rodjek))
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- \(maint\) Pin parallel gem to 1.13.0 [\#631](https://github.com/puppetlabs/pdk/pull/631) ([rodjek](https://github.com/rodjek))
|
21
|
+
- \(PDK-1260\) Bump to 1.10.0.pre for new dev work [\#621](https://github.com/puppetlabs/pdk/pull/621) ([bmjen](https://github.com/bmjen))
|
22
|
+
|
23
|
+
## [v1.9.0](https://github.com/puppetlabs/pdk/tree/v1.9.0) (2019-01-29)
|
24
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.8.0...v1.9.0)
|
25
|
+
|
26
|
+
**Implemented enhancements:**
|
27
|
+
|
28
|
+
- \(PDK-735\) Implement a YAML validator [\#612](https://github.com/puppetlabs/pdk/pull/612) ([rodjek](https://github.com/rodjek))
|
29
|
+
|
30
|
+
**Fixed bugs:**
|
31
|
+
|
32
|
+
- \(PDK-914\) Adjust default\_template\_url validation to accept local dirs [\#606](https://github.com/puppetlabs/pdk/pull/606) ([rodjek](https://github.com/rodjek))
|
33
|
+
- \(PDK-1204\) pdk bundle execs in the context of the pwd [\#603](https://github.com/puppetlabs/pdk/pull/603) ([rodjek](https://github.com/rodjek))
|
34
|
+
|
35
|
+
**Closed issues:**
|
36
|
+
|
37
|
+
- After today upgrade rubygems-update the check for ruby 2.1.9 is completely broken [\#609](https://github.com/puppetlabs/pdk/issues/609)
|
38
|
+
- 'unknown type yumrepo' during 'pdk test unit' [\#607](https://github.com/puppetlabs/pdk/issues/607)
|
39
|
+
|
40
|
+
**Merged pull requests:**
|
41
|
+
|
42
|
+
- \(maint\) Fix pin for nokogiri in package tests [\#620](https://github.com/puppetlabs/pdk/pull/620) ([bmjen](https://github.com/bmjen))
|
43
|
+
- \(PDK-1240\) Update nokogiri to minimum of 1.8.5 [\#619](https://github.com/puppetlabs/pdk/pull/619) ([bmjen](https://github.com/bmjen))
|
44
|
+
- \(maint\) Update hitimes pin to 1.3.0 for r2.1 compat [\#617](https://github.com/puppetlabs/pdk/pull/617) ([bmjen](https://github.com/bmjen))
|
45
|
+
- Release 1.9.0 [\#616](https://github.com/puppetlabs/pdk/pull/616) ([bmjen](https://github.com/bmjen))
|
46
|
+
- \(MAINT\) Configure Slack notifications for Travis [\#614](https://github.com/puppetlabs/pdk/pull/614) ([scotje](https://github.com/scotje))
|
47
|
+
- \(maint\) Fix package tests to remove hardcoding [\#613](https://github.com/puppetlabs/pdk/pull/613) ([bmjen](https://github.com/bmjen))
|
48
|
+
- \(MAINT\) Fix package acceptance tests to pass with any Ruby 2.4.x [\#611](https://github.com/puppetlabs/pdk/pull/611) ([scotje](https://github.com/scotje))
|
49
|
+
- \(MAINT\) Bump default packaged ruby version to 2.4.5 [\#608](https://github.com/puppetlabs/pdk/pull/608) ([scotje](https://github.com/scotje))
|
50
|
+
- \(PDK-1202\) Pass TemplateDir object through to TemplateFile [\#605](https://github.com/puppetlabs/pdk/pull/605) ([rodjek](https://github.com/rodjek))
|
51
|
+
- \(PDK-1231\) Update version for new dev cycle. [\#604](https://github.com/puppetlabs/pdk/pull/604) ([bmjen](https://github.com/bmjen))
|
52
|
+
- \(PDK-1001\) Chdir before execing git rather than "git -C" [\#602](https://github.com/puppetlabs/pdk/pull/602) ([rodjek](https://github.com/rodjek))
|
53
|
+
|
54
|
+
## [v1.8.0](https://github.com/puppetlabs/pdk/tree/v1.8.0) (2018-11-28)
|
8
55
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.7.1...v1.8.0)
|
9
56
|
|
10
57
|
**Implemented enhancements:**
|
@@ -34,6 +81,7 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
34
81
|
|
35
82
|
**Merged pull requests:**
|
36
83
|
|
84
|
+
- Release 1.8.0 [\#601](https://github.com/puppetlabs/pdk/pull/601) ([bmjen](https://github.com/bmjen))
|
37
85
|
- \(maint\) Update package tests to add task name validation [\#600](https://github.com/puppetlabs/pdk/pull/600) ([bmjen](https://github.com/bmjen))
|
38
86
|
- \(maint\) Fix package tests [\#596](https://github.com/puppetlabs/pdk/pull/596) ([rodjek](https://github.com/rodjek))
|
39
87
|
- \(maint\) Add --skip-bundle-install to `pdk new module` [\#595](https://github.com/puppetlabs/pdk/pull/595) ([rodjek](https://github.com/rodjek))
|
data/lib/pdk/cli/bundle.rb
CHANGED
@@ -27,7 +27,7 @@ EOF
|
|
27
27
|
gemfile_env = PDK::Util::Bundler::BundleHelper.gemfile_env(puppet_env[:gemset])
|
28
28
|
|
29
29
|
command = PDK::CLI::Exec::Command.new(PDK::CLI::Exec.bundle_bin, *args).tap do |c|
|
30
|
-
c.context = :
|
30
|
+
c.context = :pwd
|
31
31
|
c.update_environment(gemfile_env)
|
32
32
|
end
|
33
33
|
|
data/lib/pdk/cli/exec.rb
CHANGED
@@ -94,7 +94,7 @@ module PDK
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def context=(new_context)
|
97
|
-
unless [:system, :module].include?(new_context)
|
97
|
+
unless [:system, :module, :pwd].include?(new_context)
|
98
98
|
raise ArgumentError, _("Expected execution context to be :system or :module but got '%{context}'.") % { context: new_context }
|
99
99
|
end
|
100
100
|
|
@@ -132,7 +132,7 @@ module PDK
|
|
132
132
|
|
133
133
|
@process.environment['BUNDLE_IGNORE_CONFIG'] = '1'
|
134
134
|
|
135
|
-
if
|
135
|
+
if [:module, :pwd].include?(context)
|
136
136
|
@process.environment['GEM_HOME'] = PDK::Util::RubyVersion.gem_home
|
137
137
|
@process.environment['GEM_PATH'] = PDK::Util::RubyVersion.gem_path
|
138
138
|
|
@@ -143,8 +143,8 @@ module PDK
|
|
143
143
|
File.join(@process.environment['GEM_HOME'], 'bin'),
|
144
144
|
PDK::Util::RubyVersion.gem_paths_raw.map { |gem_path| File.join(gem_path, 'bin') },
|
145
145
|
package_binpath,
|
146
|
-
ENV['PATH'],
|
147
146
|
PDK::Util.package_install? ? PDK::Util::Git.git_paths : nil,
|
147
|
+
ENV['PATH'],
|
148
148
|
].compact.flatten.join(File::PATH_SEPARATOR)
|
149
149
|
|
150
150
|
mod_root = PDK::Util.module_root
|
@@ -155,7 +155,7 @@ module PDK
|
|
155
155
|
raise PDK::CLI::FatalError, _('Current working directory is not part of a module. (No metadata.json was found.)')
|
156
156
|
end
|
157
157
|
|
158
|
-
if Dir.pwd == mod_root
|
158
|
+
if Dir.pwd == mod_root || context == :pwd
|
159
159
|
run_process_in_clean_env!
|
160
160
|
else
|
161
161
|
Dir.chdir(mod_root) do
|
data/lib/pdk/cli/validate.rb
CHANGED
@@ -6,7 +6,7 @@ module PDK::CLI
|
|
6
6
|
usage _('validate [validators] [options] [targets]')
|
7
7
|
summary _('Run static analysis tests.')
|
8
8
|
description _(
|
9
|
-
"Run metadata, Puppet, Ruby, or Tasks validation.\n\n" \
|
9
|
+
"Run metadata, YAML, Puppet, Ruby, or Tasks validation.\n\n" \
|
10
10
|
'[validators] is an optional comma-separated list of validators to use. ' \
|
11
11
|
'If not specified, all validators are used. ' \
|
12
12
|
"Note that when using PowerShell, the list of validators must be enclosed in single quotes.\n\n" \
|
data/lib/pdk/module/metadata.rb
CHANGED
@@ -163,7 +163,8 @@ module PDK
|
|
163
163
|
# Do basic validation and parsing of the name parameter.
|
164
164
|
def process_name(data)
|
165
165
|
validate_name(data['name'])
|
166
|
-
author,
|
166
|
+
author, modname = data['name'].split(%r{[-/]}, 2)
|
167
|
+
data['name'] = [author, modname].join('-')
|
167
168
|
|
168
169
|
data['author'] ||= author if @data['author'] == DEFAULTS['author']
|
169
170
|
end
|
@@ -117,7 +117,7 @@ module PDK
|
|
117
117
|
dest_status = :delete
|
118
118
|
else
|
119
119
|
begin
|
120
|
-
dest_content = PDK::TemplateFile.new(File.join(template_loc, template_file), configs: config).render
|
120
|
+
dest_content = PDK::TemplateFile.new(File.join(template_loc, template_file), configs: config, template_dir: self).render
|
121
121
|
rescue => e
|
122
122
|
error_msg = _(
|
123
123
|
"Failed to render template '%{template}'\n" \
|
@@ -269,8 +269,14 @@ module PDK
|
|
269
269
|
if File.file?(loc) && File.readable?(loc)
|
270
270
|
begin
|
271
271
|
YAML.safe_load(File.read(loc), [], [], true)
|
272
|
-
rescue
|
273
|
-
PDK.logger.warn
|
272
|
+
rescue Psych::SyntaxError => e
|
273
|
+
PDK.logger.warn _("'%{file}' is not a valid YAML file: %{problem} %{context} at line %{line} column %{column}") % {
|
274
|
+
file: loc,
|
275
|
+
problem: e.problem,
|
276
|
+
context: e.context,
|
277
|
+
line: e.line,
|
278
|
+
column: e.column,
|
279
|
+
}
|
274
280
|
{}
|
275
281
|
end
|
276
282
|
else
|
@@ -294,11 +300,13 @@ module PDK
|
|
294
300
|
clone_result = PDK::Util::Git.git('clone', origin_repo, temp_dir)
|
295
301
|
|
296
302
|
if clone_result[:exit_code].zero?
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
303
|
+
Dir.chdir(temp_dir) do
|
304
|
+
reset_result = PDK::Util::Git.git('reset', '--hard', git_ref)
|
305
|
+
unless reset_result[:exit_code].zero?
|
306
|
+
PDK.logger.error reset_result[:stdout]
|
307
|
+
PDK.logger.error reset_result[:stderr]
|
308
|
+
raise PDK::CLI::FatalError, _("Unable to set HEAD of git repository at '%{repo}' to ref:'%{ref}'.") % { repo: temp_dir, ref: git_ref }
|
309
|
+
end
|
302
310
|
end
|
303
311
|
else
|
304
312
|
PDK.logger.error clone_result[:stdout]
|
data/lib/pdk/module.rb
CHANGED
@@ -4,7 +4,6 @@ module PDK
|
|
4
4
|
module Module
|
5
5
|
DEFAULT_IGNORED = [
|
6
6
|
'/pkg/',
|
7
|
-
'.*',
|
8
7
|
'~*',
|
9
8
|
'/coverage',
|
10
9
|
'/checksums.json',
|
@@ -13,8 +12,10 @@ module PDK
|
|
13
12
|
'/vendor/',
|
14
13
|
].freeze
|
15
14
|
|
16
|
-
def default_ignored_pathspec
|
17
|
-
|
15
|
+
def default_ignored_pathspec(ignore_dotfiles = true)
|
16
|
+
PathSpec.new(DEFAULT_IGNORED).tap do |ps|
|
17
|
+
ps.add('.*') if ignore_dotfiles
|
18
|
+
end
|
18
19
|
end
|
19
20
|
module_function :default_ignored_pathspec
|
20
21
|
end
|
data/lib/pdk/template_file.rb
CHANGED
@@ -45,8 +45,9 @@ module PDK
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def default_ruby_version
|
48
|
-
# For now, the packaged versions will be using default of 2.4.
|
49
|
-
|
48
|
+
# For now, the packaged versions will be using default of 2.4.5
|
49
|
+
# FIXME: make this dynamic
|
50
|
+
return '2.4.5' if PDK::Util.package_install?
|
50
51
|
|
51
52
|
# TODO: may not be a safe assumption that highest available version should be default
|
52
53
|
latest_ruby_version
|
data/lib/pdk/util.rb
CHANGED
@@ -206,13 +206,25 @@ module PDK
|
|
206
206
|
return puppetlabs_template_url if answer_file_url == 'https://github.com/puppetlabs/pdk-module-template'
|
207
207
|
return puppetlabs_template_url if answer_file_url == puppetlabs_template_url
|
208
208
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
209
|
+
if File.directory?(answer_file_url)
|
210
|
+
# Instantiating a new TemplateDir object pointing to the directory
|
211
|
+
# will cause the directory contents to be validated, raising
|
212
|
+
# ArgumentError if it does not appear to be a valid template.
|
213
|
+
PDK::Module::TemplateDir.new(answer_file_url) {}
|
214
|
+
return answer_file_url
|
213
215
|
end
|
214
216
|
|
217
|
+
raise ArgumentError unless PDK::Util::Git.repo?(answer_file_url)
|
218
|
+
|
215
219
|
answer_file_url
|
220
|
+
rescue ArgumentError
|
221
|
+
PDK.logger.warn(
|
222
|
+
_("Unable to access the previously used template '%{template}', using the default template instead.") % {
|
223
|
+
template: answer_file_url,
|
224
|
+
},
|
225
|
+
)
|
226
|
+
PDK.answers.update!('template-url' => nil)
|
227
|
+
return puppetlabs_template_url
|
216
228
|
end
|
217
229
|
module_function :default_template_url
|
218
230
|
|
@@ -21,6 +21,8 @@ module PDK
|
|
21
21
|
# false - PDK will pass the globbed targets to the validator command.
|
22
22
|
ALLOW_EMPTY_TARGETS = false
|
23
23
|
|
24
|
+
IGNORE_DOTFILES = true
|
25
|
+
|
24
26
|
def self.cmd_path
|
25
27
|
File.join(PDK::Util.module_root, 'bin', cmd)
|
26
28
|
end
|
@@ -49,10 +51,10 @@ module PDK
|
|
49
51
|
if respond_to?(:pattern)
|
50
52
|
if File.directory?(target)
|
51
53
|
target_root = PDK::Util.module_root
|
52
|
-
pattern_glob = Array(pattern).map { |p| Dir.glob(File.join(target_root, p)) }
|
54
|
+
pattern_glob = Array(pattern).map { |p| Dir.glob(File.join(target_root, p), File::FNM_DOTMATCH) }
|
53
55
|
|
54
56
|
target_list = pattern_glob.flatten.map do |file|
|
55
|
-
if File.fnmatch(File.join(File.expand_path(target), '*'), file)
|
57
|
+
if File.fnmatch(File.join(File.expand_path(target), '*'), file, File::FNM_DOTMATCH)
|
56
58
|
Pathname.new(file).relative_path_from(Pathname.new(PDK::Util.module_root)).to_s
|
57
59
|
end
|
58
60
|
end
|
@@ -65,7 +67,7 @@ module PDK
|
|
65
67
|
elsif File.file?(target)
|
66
68
|
if Array(pattern).include? target
|
67
69
|
target
|
68
|
-
elsif Array(pattern).any? { |p| File.fnmatch(File.expand_path(p), File.expand_path(target)) }
|
70
|
+
elsif Array(pattern).any? { |p| File.fnmatch(File.expand_path(p), File.expand_path(target), File::FNM_DOTMATCH) }
|
69
71
|
target
|
70
72
|
else
|
71
73
|
skipped << target
|
@@ -83,7 +85,7 @@ module PDK
|
|
83
85
|
end
|
84
86
|
|
85
87
|
def self.ignore_pathspec
|
86
|
-
ignore_pathspec = PDK::Module.default_ignored_pathspec
|
88
|
+
ignore_pathspec = PDK::Module.default_ignored_pathspec(ignore_dotfiles?)
|
87
89
|
|
88
90
|
if respond_to?(:pattern_ignore)
|
89
91
|
Array(pattern_ignore).each do |pattern|
|
@@ -94,6 +96,10 @@ module PDK
|
|
94
96
|
ignore_pathspec
|
95
97
|
end
|
96
98
|
|
99
|
+
def self.ignore_dotfiles?
|
100
|
+
self::IGNORE_DOTFILES
|
101
|
+
end
|
102
|
+
|
97
103
|
def self.parse_options(_options, targets)
|
98
104
|
targets
|
99
105
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'pdk'
|
2
2
|
require 'pdk/cli/exec'
|
3
3
|
require 'pdk/validate/base_validator'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'tmpdir'
|
4
6
|
|
5
7
|
module PDK
|
6
8
|
module Validate
|
@@ -46,7 +48,30 @@ module PDK
|
|
46
48
|
end
|
47
49
|
|
48
50
|
def self.parse_options(_options, targets)
|
49
|
-
|
51
|
+
# Due to PDK-1266 we need to run `puppet parser validate` with an empty
|
52
|
+
# modulepath. On *nix, Ruby treats `/dev/null` as an empty directory
|
53
|
+
# however it doesn't do so with `NUL` on Windows. The workaround for
|
54
|
+
# this to ensure consistent behaviour is to create an empty temporary
|
55
|
+
# directory and use that as the modulepath.
|
56
|
+
['parser', 'validate', '--config', null_file, '--modulepath', validate_tmpdir].concat(targets)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.invoke(report, options)
|
60
|
+
super
|
61
|
+
ensure
|
62
|
+
remove_validate_tmpdir
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.validate_tmpdir
|
66
|
+
@validate_tmpdir ||= Dir.mktmpdir('puppet-parser-validate')
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.remove_validate_tmpdir
|
70
|
+
return unless @validate_tmpdir
|
71
|
+
return unless File.directory?(@validate_tmpdir)
|
72
|
+
|
73
|
+
FileUtils.remove_entry_secure(@validate_tmpdir)
|
74
|
+
@validate_tmpdir = nil
|
50
75
|
end
|
51
76
|
|
52
77
|
def self.null_file
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'pdk'
|
2
|
+
require 'pdk/cli/exec'
|
3
|
+
require 'pdk/validate/base_validator'
|
4
|
+
require 'pdk/util'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
module PDK
|
8
|
+
module Validate
|
9
|
+
class YAML
|
10
|
+
class Syntax < BaseValidator
|
11
|
+
IGNORE_DOTFILES = false
|
12
|
+
YAML_WHITELISTED_CLASSES = [Symbol].freeze
|
13
|
+
|
14
|
+
def self.name
|
15
|
+
'yaml-syntax'
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.pattern
|
19
|
+
[
|
20
|
+
'**/*.yaml',
|
21
|
+
'*.yaml',
|
22
|
+
'**/*.yml',
|
23
|
+
'*.yml',
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.spinner_text(_targets = [])
|
28
|
+
_('Checking YAML syntax (%{targets}).') % {
|
29
|
+
targets: pattern,
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.create_spinner(targets = [], options = {})
|
34
|
+
return unless PDK::CLI::Util.interactive?
|
35
|
+
options = options.merge(PDK::CLI::Util.spinner_opts_for_platform)
|
36
|
+
|
37
|
+
exec_group = options[:exec_group]
|
38
|
+
@spinner = if exec_group
|
39
|
+
exec_group.add_spinner(spinner_text(targets), options)
|
40
|
+
else
|
41
|
+
TTY::Spinner.new("[:spinner] #{spinner_text(targets)}", options)
|
42
|
+
end
|
43
|
+
@spinner.auto_spin
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.stop_spinner(exit_code)
|
47
|
+
if exit_code.zero? && @spinner
|
48
|
+
@spinner.success
|
49
|
+
elsif @spinner
|
50
|
+
@spinner.error
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.invoke(report, options = {})
|
55
|
+
targets, skipped, invalid = parse_targets(options)
|
56
|
+
|
57
|
+
process_skipped(report, skipped)
|
58
|
+
process_invalid(report, invalid)
|
59
|
+
|
60
|
+
return 0 if targets.empty?
|
61
|
+
|
62
|
+
return_val = 0
|
63
|
+
create_spinner(targets, options)
|
64
|
+
|
65
|
+
targets.each do |target|
|
66
|
+
next unless File.file?(target)
|
67
|
+
|
68
|
+
unless File.readable?(target)
|
69
|
+
report.add_event(
|
70
|
+
file: target,
|
71
|
+
source: name,
|
72
|
+
state: :failure,
|
73
|
+
severity: 'error',
|
74
|
+
message: _('Could not be read.'),
|
75
|
+
)
|
76
|
+
return_val = 1
|
77
|
+
next
|
78
|
+
end
|
79
|
+
|
80
|
+
begin
|
81
|
+
::YAML.safe_load(File.read(target), YAML_WHITELISTED_CLASSES, [], true)
|
82
|
+
|
83
|
+
report.add_event(
|
84
|
+
file: target,
|
85
|
+
source: name,
|
86
|
+
state: :passed,
|
87
|
+
severity: 'ok',
|
88
|
+
)
|
89
|
+
rescue Psych::SyntaxError => e
|
90
|
+
report.add_event(
|
91
|
+
file: target,
|
92
|
+
source: name,
|
93
|
+
state: :failure,
|
94
|
+
severity: 'error',
|
95
|
+
line: e.line,
|
96
|
+
column: e.column,
|
97
|
+
message: _('%{problem} %{context}') % {
|
98
|
+
problem: e.problem,
|
99
|
+
context: e.context,
|
100
|
+
},
|
101
|
+
)
|
102
|
+
return_val = 1
|
103
|
+
rescue Psych::DisallowedClass => e
|
104
|
+
report.add_event(
|
105
|
+
file: target,
|
106
|
+
source: name,
|
107
|
+
state: :failure,
|
108
|
+
severity: 'error',
|
109
|
+
message: _('Unsupported class: %{message}') % {
|
110
|
+
message: e.message,
|
111
|
+
},
|
112
|
+
)
|
113
|
+
return_val = 1
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
stop_spinner(return_val)
|
118
|
+
return_val
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'pdk'
|
2
|
+
require 'pdk/cli/exec'
|
3
|
+
require 'pdk/validate/base_validator'
|
4
|
+
require 'pdk/validate/yaml/syntax'
|
5
|
+
|
6
|
+
module PDK
|
7
|
+
module Validate
|
8
|
+
class YAMLValidator < BaseValidator
|
9
|
+
def self.name
|
10
|
+
'yaml'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.validators
|
14
|
+
[
|
15
|
+
PDK::Validate::YAML::Syntax,
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.invoke(report, options = {})
|
20
|
+
exit_code = 0
|
21
|
+
|
22
|
+
validators.each do |validator|
|
23
|
+
exit_code = validator.invoke(report, options)
|
24
|
+
break if exit_code != 0
|
25
|
+
end
|
26
|
+
|
27
|
+
exit_code
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/pdk/validate.rb
CHANGED
@@ -2,11 +2,18 @@ require 'pdk/validate/metadata_validator'
|
|
2
2
|
require 'pdk/validate/puppet_validator'
|
3
3
|
require 'pdk/validate/ruby_validator'
|
4
4
|
require 'pdk/validate/tasks_validator'
|
5
|
+
require 'pdk/validate/yaml_validator'
|
5
6
|
|
6
7
|
module PDK
|
7
8
|
module Validate
|
8
9
|
def self.validators
|
9
|
-
@validators ||= [
|
10
|
+
@validators ||= [
|
11
|
+
MetadataValidator,
|
12
|
+
YAMLValidator,
|
13
|
+
PuppetValidator,
|
14
|
+
RubyValidator,
|
15
|
+
TasksValidator,
|
16
|
+
].freeze
|
10
17
|
end
|
11
18
|
|
12
19
|
class ParseOutputError < StandardError; end
|
data/lib/pdk/version.rb
CHANGED
data/locales/pdk.pot
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# SOME DESCRIPTIVE TITLE.
|
2
|
-
# Copyright (C)
|
2
|
+
# Copyright (C) 2019 Puppet, Inc.
|
3
3
|
# This file is distributed under the same license as the puppet development kit package.
|
4
|
-
# FIRST AUTHOR <EMAIL@ADDRESS>,
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2019.
|
5
5
|
#
|
6
6
|
#, fuzzy
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
|
-
"Project-Id-Version: puppet development kit v1.
|
9
|
+
"Project-Id-Version: puppet development kit v1.9.0-15-g264d3c07ab\n"
|
10
10
|
"\n"
|
11
11
|
"Report-Msgid-Bugs-To: docs@puppet.com\n"
|
12
|
-
"POT-Creation-Date:
|
13
|
-
"PO-Revision-Date:
|
12
|
+
"POT-Creation-Date: 2019-03-01 11:43-0700\n"
|
13
|
+
"PO-Revision-Date: 2019-03-01 11:43-0700\n"
|
14
14
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
15
15
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
16
16
|
"Language: \n"
|
@@ -533,7 +533,7 @@ msgstr ""
|
|
533
533
|
|
534
534
|
#: ../lib/pdk/cli/validate.rb:8
|
535
535
|
msgid ""
|
536
|
-
"Run metadata, Puppet, Ruby, or Tasks validation.\n"
|
536
|
+
"Run metadata, YAML, Puppet, Ruby, or Tasks validation.\n"
|
537
537
|
"\n"
|
538
538
|
"[validators] is an optional comma-separated list of validators to use. If not specified, all validators are used. Note that when using PowerShell, the list of validators must be enclosed in single quotes.\n"
|
539
539
|
"\n"
|
@@ -695,11 +695,11 @@ msgid "If there is a public issue tracker for this module, enter its URL here."
|
|
695
695
|
msgstr ""
|
696
696
|
|
697
697
|
#: ../lib/pdk/generate/module.rb:258
|
698
|
-
msgid "
|
698
|
+
msgid "update"
|
699
699
|
msgstr ""
|
700
700
|
|
701
701
|
#: ../lib/pdk/generate/module.rb:258
|
702
|
-
msgid "
|
702
|
+
msgid "create"
|
703
703
|
msgstr ""
|
704
704
|
|
705
705
|
#: ../lib/pdk/generate/module.rb:259
|
@@ -878,23 +878,23 @@ msgstr ""
|
|
878
878
|
msgid "The \"puppet\" requirement in module metadata does not specify a \"version_requirement\"."
|
879
879
|
msgstr ""
|
880
880
|
|
881
|
-
#: ../lib/pdk/module/metadata.rb:
|
881
|
+
#: ../lib/pdk/module/metadata.rb:181
|
882
882
|
msgid "Field must be a dash-separated user name and module name."
|
883
883
|
msgstr ""
|
884
884
|
|
885
|
-
#: ../lib/pdk/module/metadata.rb:
|
885
|
+
#: ../lib/pdk/module/metadata.rb:183
|
886
886
|
msgid "Module name must contain only alphanumeric or underscore characters."
|
887
887
|
msgstr ""
|
888
888
|
|
889
|
-
#: ../lib/pdk/module/metadata.rb:
|
889
|
+
#: ../lib/pdk/module/metadata.rb:185
|
890
890
|
msgid "Module name must begin with a letter."
|
891
891
|
msgstr ""
|
892
892
|
|
893
|
-
#: ../lib/pdk/module/metadata.rb:
|
893
|
+
#: ../lib/pdk/module/metadata.rb:187
|
894
894
|
msgid "Namespace must contain only alphanumeric characters."
|
895
895
|
msgstr ""
|
896
896
|
|
897
|
-
#: ../lib/pdk/module/metadata.rb:
|
897
|
+
#: ../lib/pdk/module/metadata.rb:190
|
898
898
|
msgid "Invalid 'name' field in metadata.json: %{err}"
|
899
899
|
msgstr ""
|
900
900
|
|
@@ -933,14 +933,14 @@ msgid "The directory '%{dir}' doesn't exist"
|
|
933
933
|
msgstr ""
|
934
934
|
|
935
935
|
#: ../lib/pdk/module/templatedir.rb:273
|
936
|
-
msgid "'%{file}' is not a valid YAML file: %{
|
936
|
+
msgid "'%{file}' is not a valid YAML file: %{problem} %{context} at line %{line} column %{column}"
|
937
937
|
msgstr ""
|
938
938
|
|
939
|
-
#: ../lib/pdk/module/templatedir.rb:
|
939
|
+
#: ../lib/pdk/module/templatedir.rb:308
|
940
940
|
msgid "Unable to set HEAD of git repository at '%{repo}' to ref:'%{ref}'."
|
941
941
|
msgstr ""
|
942
942
|
|
943
|
-
#: ../lib/pdk/module/templatedir.rb:
|
943
|
+
#: ../lib/pdk/module/templatedir.rb:314
|
944
944
|
msgid "Unable to clone git repository at '%{repo}' into '%{dest}'."
|
945
945
|
msgstr ""
|
946
946
|
|
@@ -1024,7 +1024,7 @@ msgstr ""
|
|
1024
1024
|
msgid "Trace must be an Array of stack trace lines."
|
1025
1025
|
msgstr ""
|
1026
1026
|
|
1027
|
-
#: ../lib/pdk/template_file.rb:
|
1027
|
+
#: ../lib/pdk/template_file.rb:68
|
1028
1028
|
msgid "'%{template}' is not a readable file"
|
1029
1029
|
msgstr ""
|
1030
1030
|
|
@@ -1084,7 +1084,7 @@ msgstr ""
|
|
1084
1084
|
msgid "Package basedir requested for non-package install."
|
1085
1085
|
msgstr ""
|
1086
1086
|
|
1087
|
-
#: ../lib/pdk/util.rb:
|
1087
|
+
#: ../lib/pdk/util.rb:222
|
1088
1088
|
msgid "Unable to access the previously used template '%{template}', using the default template instead."
|
1089
1089
|
msgstr ""
|
1090
1090
|
|
@@ -1214,23 +1214,23 @@ msgstr ""
|
|
1214
1214
|
msgid "Failed to call GetLongPathName"
|
1215
1215
|
msgstr ""
|
1216
1216
|
|
1217
|
-
#: ../lib/pdk/validate/base_validator.rb:
|
1217
|
+
#: ../lib/pdk/validate/base_validator.rb:108
|
1218
1218
|
msgid "Invoking %{cmd}"
|
1219
1219
|
msgstr ""
|
1220
1220
|
|
1221
|
-
#: ../lib/pdk/validate/base_validator.rb:
|
1221
|
+
#: ../lib/pdk/validate/base_validator.rb:113
|
1222
1222
|
msgid "%{validator}: Skipped '%{target}'. Target does not contain any files to validate (%{pattern})."
|
1223
1223
|
msgstr ""
|
1224
1224
|
|
1225
|
-
#: ../lib/pdk/validate/base_validator.rb:
|
1225
|
+
#: ../lib/pdk/validate/base_validator.rb:117
|
1226
1226
|
msgid "Target does not contain any files to validate (%{pattern})."
|
1227
1227
|
msgstr ""
|
1228
1228
|
|
1229
|
-
#: ../lib/pdk/validate/base_validator.rb:
|
1229
|
+
#: ../lib/pdk/validate/base_validator.rb:126
|
1230
1230
|
msgid "%{validator}: Skipped '%{target}'. Target file not found."
|
1231
1231
|
msgstr ""
|
1232
1232
|
|
1233
|
-
#: ../lib/pdk/validate/base_validator.rb:
|
1233
|
+
#: ../lib/pdk/validate/base_validator.rb:130
|
1234
1234
|
msgid "File does not exist."
|
1235
1235
|
msgstr ""
|
1236
1236
|
|
@@ -1246,7 +1246,7 @@ msgstr ""
|
|
1246
1246
|
msgid "Checking metadata syntax (%{targets})."
|
1247
1247
|
msgstr ""
|
1248
1248
|
|
1249
|
-
#: ../lib/pdk/validate/metadata/metadata_syntax.rb:69 ../lib/pdk/validate/tasks/metadata_lint.rb:77
|
1249
|
+
#: ../lib/pdk/validate/metadata/metadata_syntax.rb:69 ../lib/pdk/validate/tasks/metadata_lint.rb:77 ../lib/pdk/validate/yaml/syntax.rb:74
|
1250
1250
|
msgid "Could not be read."
|
1251
1251
|
msgstr ""
|
1252
1252
|
|
@@ -1254,7 +1254,7 @@ msgstr ""
|
|
1254
1254
|
msgid "Checking Puppet manifest style (%{pattern})."
|
1255
1255
|
msgstr ""
|
1256
1256
|
|
1257
|
-
#: ../lib/pdk/validate/puppet/puppet_syntax.rb:
|
1257
|
+
#: ../lib/pdk/validate/puppet/puppet_syntax.rb:47
|
1258
1258
|
msgid "Checking Puppet manifest syntax (%{pattern})."
|
1259
1259
|
msgstr ""
|
1260
1260
|
|
@@ -1281,3 +1281,15 @@ msgstr ""
|
|
1281
1281
|
#: ../lib/pdk/validate/tasks/name.rb:23
|
1282
1282
|
msgid "Checking task names (%{targets})."
|
1283
1283
|
msgstr ""
|
1284
|
+
|
1285
|
+
#: ../lib/pdk/validate/yaml/syntax.rb:28
|
1286
|
+
msgid "Checking YAML syntax (%{targets})."
|
1287
|
+
msgstr ""
|
1288
|
+
|
1289
|
+
#: ../lib/pdk/validate/yaml/syntax.rb:97
|
1290
|
+
msgid "%{problem} %{context}"
|
1291
|
+
msgstr ""
|
1292
|
+
|
1293
|
+
#: ../lib/pdk/validate/yaml/syntax.rb:109
|
1294
|
+
msgid "Unsupported class: %{message}"
|
1295
|
+
msgstr ""
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdk-akerl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.15.0
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 3.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 1.15.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: cri
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +184,48 @@ dependencies:
|
|
178
184
|
- - "~>"
|
179
185
|
- !ruby/object:Gem::Version
|
180
186
|
version: 0.2.1
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: ffi
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: 1.9.0
|
194
|
+
type: :runtime
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: 1.9.0
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
name: hitimes
|
203
|
+
requirement: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - '='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: 1.3.0
|
208
|
+
type: :runtime
|
209
|
+
prerelease: false
|
210
|
+
version_requirements: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - '='
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: 1.3.0
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: net-ssh
|
217
|
+
requirement: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - "~>"
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: 4.2.0
|
222
|
+
type: :runtime
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - "~>"
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: 4.2.0
|
181
229
|
- !ruby/object:Gem::Dependency
|
182
230
|
name: deep_merge
|
183
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,6 +324,8 @@ files:
|
|
276
324
|
- lib/pdk/validate/tasks/metadata_lint.rb
|
277
325
|
- lib/pdk/validate/tasks/name.rb
|
278
326
|
- lib/pdk/validate/tasks_validator.rb
|
327
|
+
- lib/pdk/validate/yaml/syntax.rb
|
328
|
+
- lib/pdk/validate/yaml_validator.rb
|
279
329
|
- lib/pdk/version.rb
|
280
330
|
- locales/config.yaml
|
281
331
|
- locales/pdk.pot
|
@@ -297,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
347
|
- !ruby/object:Gem::Version
|
298
348
|
version: '0'
|
299
349
|
requirements: []
|
300
|
-
rubygems_version: 3.0.
|
350
|
+
rubygems_version: 3.0.1
|
301
351
|
signing_key:
|
302
352
|
specification_version: 4
|
303
353
|
summary: A key part of the Puppet Development Kit, the shortest path to better modules
|