pdk 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +300 -21
  3. data/lib/pdk/cli.rb +3 -2
  4. data/lib/pdk/cli/bundle.rb +0 -2
  5. data/lib/pdk/cli/convert.rb +25 -0
  6. data/lib/pdk/cli/exec.rb +4 -34
  7. data/lib/pdk/cli/exec_group.rb +2 -2
  8. data/lib/pdk/cli/module.rb +2 -3
  9. data/lib/pdk/cli/module/generate.rb +9 -4
  10. data/lib/pdk/cli/new/class.rb +1 -1
  11. data/lib/pdk/cli/new/module.rb +12 -9
  12. data/lib/pdk/cli/test/unit.rb +16 -7
  13. data/lib/pdk/cli/util.rb +47 -4
  14. data/lib/pdk/generate.rb +4 -4
  15. data/lib/pdk/{generators → generate}/defined_type.rb +1 -1
  16. data/lib/pdk/{generators → generate}/module.rb +47 -58
  17. data/lib/pdk/{generators → generate}/puppet_class.rb +1 -1
  18. data/lib/pdk/{generators → generate}/puppet_object.rb +1 -1
  19. data/lib/pdk/{generators → generate}/task.rb +1 -1
  20. data/lib/pdk/module/convert.rb +163 -0
  21. data/lib/pdk/module/metadata.rb +11 -3
  22. data/lib/pdk/module/templatedir.rb +81 -42
  23. data/lib/pdk/module/update_manager.rb +203 -0
  24. data/lib/pdk/tests/unit.rb +7 -6
  25. data/lib/pdk/util.rb +42 -1
  26. data/lib/pdk/util/bundler.rb +2 -2
  27. data/lib/pdk/util/git.rb +36 -0
  28. data/lib/pdk/util/version.rb +2 -1
  29. data/lib/pdk/validate.rb +3 -3
  30. data/lib/pdk/{validators → validate}/base_validator.rb +0 -0
  31. data/lib/pdk/{validators → validate}/metadata/metadata_json_lint.rb +1 -1
  32. data/lib/pdk/{validators → validate}/metadata/metadata_syntax.rb +2 -2
  33. data/lib/pdk/{validators → validate}/metadata/task_metadata_lint.rb +3 -3
  34. data/lib/pdk/{validators → validate}/metadata_validator.rb +4 -4
  35. data/lib/pdk/{validators → validate}/puppet/puppet_lint.rb +1 -1
  36. data/lib/pdk/{validators → validate}/puppet/puppet_syntax.rb +1 -1
  37. data/lib/pdk/{validators → validate}/puppet_validator.rb +3 -3
  38. data/lib/pdk/{validators → validate}/ruby/rubocop.rb +2 -2
  39. data/lib/pdk/{validators → validate}/ruby_validator.rb +2 -2
  40. data/lib/pdk/version.rb +2 -1
  41. metadata +36 -18
@@ -6,9 +6,10 @@ require 'json'
6
6
  module PDK
7
7
  module Test
8
8
  class Unit
9
- def self.cmd(_tests, opts = {})
10
- # TODO: test selection
11
- opts.key?(:parallel) ? 'parallel_spec' : 'spec'
9
+ def self.cmd(tests, opts = {})
10
+ rake_args = opts.key?(:parallel) ? 'parallel_spec' : 'spec'
11
+ rake_args += "[#{tests}]" unless tests.nil?
12
+ rake_args
12
13
  end
13
14
 
14
15
  def self.rake_bin
@@ -30,8 +31,8 @@ module PDK
30
31
 
31
32
  def self.parallel_with_no_tests?(ran_in_parallel, json_result, result)
32
33
  ran_in_parallel && json_result.empty? &&
33
- !result[:exit_code].zero? &&
34
- result[:stderr].strip =~ %r{Pass files or folders to run$}
34
+ ((!result[:exit_code].zero? && result[:stderr].strip =~ %r{Pass files or folders to run$}) ||
35
+ result[:stderr].strip =~ %r{No files for parallel_spec to run against$})
35
36
  end
36
37
 
37
38
  def self.print_failure(result, exception)
@@ -199,7 +200,7 @@ module PDK
199
200
  else
200
201
  examples = []
201
202
  rspec_json['examples'].each do |example|
202
- examples << { id: example['id'], full_description: example['full_description'] }
203
+ examples << { file_path: example['file_path'], id: example['id'], full_description: example['full_description'] }
203
204
  end
204
205
  examples
205
206
  end
data/lib/pdk/util.rb CHANGED
@@ -58,8 +58,13 @@ module PDK
58
58
  end
59
59
  module_function :package_install?
60
60
 
61
+ def development_mode?
62
+ !PDK::Util::Version.git_ref.nil?
63
+ end
64
+ module_function :development_mode?
65
+
61
66
  def gem_install?
62
- !package_install?
67
+ !(package_install? || development_mode?)
63
68
  end
64
69
  module_function :gem_install?
65
70
 
@@ -166,5 +171,41 @@ module PDK
166
171
  end
167
172
  end
168
173
  module_function :targets_relative_to_pwd
174
+
175
+ def default_template_url
176
+ if !PDK.answers['template-url'].nil?
177
+ PDK.answers['template-url']
178
+ else
179
+ puppetlabs_template_url
180
+ end
181
+ end
182
+ module_function :default_template_url
183
+
184
+ def puppetlabs_template_url
185
+ if package_install?
186
+ 'file://' + File.join(package_cachedir, 'pdk-templates.git')
187
+ else
188
+ 'https://github.com/puppetlabs/pdk-templates'
189
+ end
190
+ end
191
+ module_function :puppetlabs_template_url
192
+
193
+ def default_template_ref
194
+ if !PDK.answers['template-ref'].nil?
195
+ PDK.answers['template-ref']
196
+ else
197
+ puppetlabs_template_ref
198
+ end
199
+ end
200
+ module_function :default_template_ref
201
+
202
+ def puppetlabs_template_ref
203
+ if PDK::Util.package_install? || PDK::Util.gem_install?
204
+ PDK::TEMPLATE_REF
205
+ else
206
+ 'origin/master'
207
+ end
208
+ end
209
+ module_function :puppetlabs_template_ref
169
210
  end
170
211
  end
@@ -77,7 +77,7 @@ module PDK
77
77
  PDK.logger.debug(_('Checking for missing Gemfile dependencies.'))
78
78
 
79
79
  argv = ['check', "--gemfile=#{gemfile}"]
80
- argv << "--path=#{bundle_cachedir}" if PDK::Util.gem_install?
80
+ argv << "--path=#{bundle_cachedir}" unless PDK::Util.package_install?
81
81
 
82
82
  result = bundle_command(*argv).execute!
83
83
 
@@ -104,7 +104,7 @@ module PDK
104
104
 
105
105
  def install!
106
106
  argv = ['install', "--gemfile=#{gemfile}", '-j4']
107
- argv << "--path=#{bundle_cachedir}" if PDK::Util.gem_install?
107
+ argv << "--path=#{bundle_cachedir}" unless PDK::Util.package_install?
108
108
 
109
109
  command = bundle_command(*argv).tap do |c|
110
110
  c.add_spinner(_('Installing missing Gemfile dependencies.'))
@@ -0,0 +1,36 @@
1
+ module PDK
2
+ module Util
3
+ module Git
4
+ def self.git_bindir
5
+ @git_dir ||= File.join('private', 'git', Gem.win_platform? ? 'cmd' : 'bin')
6
+ end
7
+
8
+ def self.git_paths
9
+ @paths ||= begin
10
+ paths = [File.join(PDK::Util.pdk_package_basedir, git_bindir)]
11
+
12
+ if Gem.win_platform?
13
+ paths << File.join(PDK::Util.pdk_package_basedir, 'private', 'git', 'mingw64', 'bin')
14
+ paths << File.join(PDK::Util.pdk_package_basedir, 'private', 'git', 'mingw64', 'libexec', 'git-core')
15
+ paths << File.join(PDK::Util.pdk_package_basedir, 'private', 'git', 'usr', 'bin')
16
+ end
17
+
18
+ paths
19
+ end
20
+ end
21
+
22
+ def self.git_bin
23
+ git_bin = Gem.win_platform? ? 'git.exe' : 'git'
24
+ vendored_bin_path = File.join(git_bindir, git_bin)
25
+
26
+ PDK::CLI::Exec.try_vendored_bin(vendored_bin_path, git_bin)
27
+ end
28
+
29
+ def self.git(*args)
30
+ PDK::CLI::Exec.ensure_bin_present!(git_bin, 'git')
31
+
32
+ PDK::CLI::Exec.execute(git_bin, *args)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,6 @@
1
1
  require 'pdk/version'
2
2
  require 'pdk/cli/exec'
3
+ require 'pdk/util/git'
3
4
 
4
5
  module PDK
5
6
  module Util
@@ -27,7 +28,7 @@ module PDK
27
28
 
28
29
  return nil unless File.directory?(source_git_dir)
29
30
 
30
- ref_result = PDK::CLI::Exec.git('--git-dir', source_git_dir, 'describe', '--all', '--long')
31
+ ref_result = PDK::Util::Git.git('--git-dir', source_git_dir, 'describe', '--all', '--long')
31
32
  return ref_result[:stdout].strip if ref_result[:exit_code].zero?
32
33
  end
33
34
 
data/lib/pdk/validate.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'pdk/validators/metadata_validator'
2
- require 'pdk/validators/puppet_validator'
3
- require 'pdk/validators/ruby_validator'
1
+ require 'pdk/validate/metadata_validator'
2
+ require 'pdk/validate/puppet_validator'
3
+ require 'pdk/validate/ruby_validator'
4
4
 
5
5
  module PDK
6
6
  module Validate
File without changes
@@ -1,6 +1,6 @@
1
1
  require 'pdk'
2
2
  require 'pdk/cli/exec'
3
- require 'pdk/validators/base_validator'
3
+ require 'pdk/validate/base_validator'
4
4
  require 'pdk/util/bundler'
5
5
  require 'pathname'
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'pdk'
2
2
  require 'pdk/cli/exec'
3
- require 'pdk/validators/base_validator'
3
+ require 'pdk/validate/base_validator'
4
4
  require 'pathname'
5
5
 
6
6
  module PDK
@@ -21,7 +21,7 @@ module PDK
21
21
  end
22
22
 
23
23
  def self.create_spinner(targets = [], options = {})
24
- return if PDK.logger.debug?
24
+ return unless PDK::CLI::Util.interactive?
25
25
  options = options.merge(PDK::CLI::Util.spinner_opts_for_platform)
26
26
 
27
27
  exec_group = options[:exec_group]
@@ -1,6 +1,6 @@
1
1
  require 'pdk'
2
2
  require 'pdk/cli/exec'
3
- require 'pdk/validators/base_validator'
3
+ require 'pdk/validate/base_validator'
4
4
  require 'pdk/util'
5
5
  require 'pathname'
6
6
  require 'json-schema'
@@ -25,7 +25,7 @@ module PDK
25
25
  end
26
26
 
27
27
  def self.create_spinner(targets = [], options = {})
28
- return if PDK.logger.debug?
28
+ return unless PDK::CLI::Util.interactive?
29
29
  options = options.merge(PDK::CLI::Util.spinner_opts_for_platform)
30
30
 
31
31
  exec_group = options[:exec_group]
@@ -77,7 +77,7 @@ module PDK
77
77
 
78
78
  response.body
79
79
  rescue StandardError => e
80
- raise PDK::CLI::FatalError, _('Unable to download Task Metadata Schema file. Please check internet connectivity and retry this action. %{error}') % { error: e }
80
+ raise PDK::CLI::FatalError, _('Unable to download Task Metadata Schema file. Check internet connectivity and retry this action. %{error}') % { error: e }
81
81
  end
82
82
 
83
83
  def self.invoke(report, options = {})
@@ -1,9 +1,9 @@
1
1
  require 'pdk'
2
2
  require 'pdk/cli/exec'
3
- require 'pdk/validators/base_validator'
4
- require 'pdk/validators/metadata/metadata_json_lint'
5
- require 'pdk/validators/metadata/metadata_syntax'
6
- require 'pdk/validators/metadata/task_metadata_lint'
3
+ require 'pdk/validate/base_validator'
4
+ require 'pdk/validate/metadata/metadata_json_lint'
5
+ require 'pdk/validate/metadata/metadata_syntax'
6
+ require 'pdk/validate/metadata/task_metadata_lint'
7
7
 
8
8
  module PDK
9
9
  module Validate
@@ -1,7 +1,7 @@
1
1
  require 'pdk'
2
2
  require 'pdk/util'
3
3
  require 'pdk/cli/exec'
4
- require 'pdk/validators/base_validator'
4
+ require 'pdk/validate/base_validator'
5
5
 
6
6
  module PDK
7
7
  module Validate
@@ -1,6 +1,6 @@
1
1
  require 'pdk'
2
2
  require 'pdk/cli/exec'
3
- require 'pdk/validators/base_validator'
3
+ require 'pdk/validate/base_validator'
4
4
 
5
5
  module PDK
6
6
  module Validate
@@ -1,8 +1,8 @@
1
1
  require 'pdk'
2
2
  require 'pdk/cli/exec'
3
- require 'pdk/validators/base_validator'
4
- require 'pdk/validators/puppet/puppet_lint'
5
- require 'pdk/validators/puppet/puppet_syntax'
3
+ require 'pdk/validate/base_validator'
4
+ require 'pdk/validate/puppet/puppet_lint'
5
+ require 'pdk/validate/puppet/puppet_syntax'
6
6
 
7
7
  module PDK
8
8
  module Validate
@@ -2,8 +2,8 @@ require 'pdk'
2
2
  require 'pdk/cli/exec'
3
3
  require 'pdk/util'
4
4
  require 'pdk/util/bundler'
5
- require 'pdk/validators/base_validator'
6
- require 'pdk/validators/ruby_validator'
5
+ require 'pdk/validate/base_validator'
6
+ require 'pdk/validate/ruby_validator'
7
7
 
8
8
  module PDK
9
9
  module Validate
@@ -1,7 +1,7 @@
1
1
  require 'pdk'
2
2
  require 'pdk/cli/exec'
3
- require 'pdk/validators/base_validator'
4
- require 'pdk/validators/ruby/rubocop'
3
+ require 'pdk/validate/base_validator'
4
+ require 'pdk/validate/ruby/rubocop'
5
5
 
6
6
  module PDK
7
7
  module Validate
data/lib/pdk/version.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module PDK
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.3.0'.freeze
3
+ TEMPLATE_REF = '1.3.0'.freeze
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.3.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: diff-lcs
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: '1.3'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: '1.3'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: deep_merge
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +180,7 @@ files:
166
180
  - lib/pdk/answer_file.rb
167
181
  - lib/pdk/cli.rb
168
182
  - lib/pdk/cli/bundle.rb
183
+ - lib/pdk/cli/convert.rb
169
184
  - lib/pdk/cli/errors.rb
170
185
  - lib/pdk/cli/exec.rb
171
186
  - lib/pdk/cli/exec_group.rb
@@ -185,34 +200,37 @@ files:
185
200
  - lib/pdk/cli/util/option_validator.rb
186
201
  - lib/pdk/cli/validate.rb
187
202
  - lib/pdk/generate.rb
188
- - lib/pdk/generators/defined_type.rb
189
- - lib/pdk/generators/module.rb
190
- - lib/pdk/generators/puppet_class.rb
191
- - lib/pdk/generators/puppet_object.rb
192
- - lib/pdk/generators/task.rb
203
+ - lib/pdk/generate/defined_type.rb
204
+ - lib/pdk/generate/module.rb
205
+ - lib/pdk/generate/puppet_class.rb
206
+ - lib/pdk/generate/puppet_object.rb
207
+ - lib/pdk/generate/task.rb
193
208
  - lib/pdk/i18n.rb
194
209
  - lib/pdk/logger.rb
210
+ - lib/pdk/module/convert.rb
195
211
  - lib/pdk/module/metadata.rb
196
212
  - lib/pdk/module/templatedir.rb
213
+ - lib/pdk/module/update_manager.rb
197
214
  - lib/pdk/report.rb
198
215
  - lib/pdk/report/event.rb
199
216
  - lib/pdk/template_file.rb
200
217
  - lib/pdk/tests/unit.rb
201
218
  - lib/pdk/util.rb
202
219
  - lib/pdk/util/bundler.rb
220
+ - lib/pdk/util/git.rb
203
221
  - lib/pdk/util/version.rb
204
222
  - lib/pdk/util/windows.rb
205
223
  - lib/pdk/validate.rb
206
- - lib/pdk/validators/base_validator.rb
207
- - lib/pdk/validators/metadata/metadata_json_lint.rb
208
- - lib/pdk/validators/metadata/metadata_syntax.rb
209
- - lib/pdk/validators/metadata/task_metadata_lint.rb
210
- - lib/pdk/validators/metadata_validator.rb
211
- - lib/pdk/validators/puppet/puppet_lint.rb
212
- - lib/pdk/validators/puppet/puppet_syntax.rb
213
- - lib/pdk/validators/puppet_validator.rb
214
- - lib/pdk/validators/ruby/rubocop.rb
215
- - lib/pdk/validators/ruby_validator.rb
224
+ - lib/pdk/validate/base_validator.rb
225
+ - lib/pdk/validate/metadata/metadata_json_lint.rb
226
+ - lib/pdk/validate/metadata/metadata_syntax.rb
227
+ - lib/pdk/validate/metadata/task_metadata_lint.rb
228
+ - lib/pdk/validate/metadata_validator.rb
229
+ - lib/pdk/validate/puppet/puppet_lint.rb
230
+ - lib/pdk/validate/puppet/puppet_syntax.rb
231
+ - lib/pdk/validate/puppet_validator.rb
232
+ - lib/pdk/validate/ruby/rubocop.rb
233
+ - lib/pdk/validate/ruby_validator.rb
216
234
  - lib/pdk/version.rb
217
235
  - lib/puppet/util/windows.rb
218
236
  - lib/puppet/util/windows/api_types.rb
@@ -239,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
257
  version: '0'
240
258
  requirements: []
241
259
  rubyforge_project:
242
- rubygems_version: 2.5.1
260
+ rubygems_version: 2.6.12
243
261
  signing_key:
244
262
  specification_version: 4
245
263
  summary: A key part of the Puppet Development Kit, the shortest path to better modules