pdk 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae821da6d24883d0df5ffda8ffa0bba0b8943552
4
- data.tar.gz: 8408717624413c4535373e6db19fbb877957c6bd
3
+ metadata.gz: b878e02d3bef0909854556bea786e90c9046e19d
4
+ data.tar.gz: 57f154d05abdef54e0c658529664cfe4eeedc3d3
5
5
  SHA512:
6
- metadata.gz: 9382d4e0a2b841b5a35c0e0031767139613be448a3e7876e21c0fc6757553cc154210d55a13ae35355e9e791c1d12498b35bacdae8b4cf850a082d3c85f0d993
7
- data.tar.gz: b8c75c0a94b62659e09ec743429ec8c608827880d447001994f9eb4c11ac547bf0ae07719a4d974b8eca46e8c859753c09a725297d77901ecf6a4a9a8a08fdb0
6
+ metadata.gz: 5334b857cda21c8a2383cded335f22e8fdd16752305db1d3b52bb1f61c98d8ccca6acf33724085e79b4492e0c083a44732acd6b081f75ce20eba8af5bc01a0af
7
+ data.tar.gz: ff431dd53fa3ebe9d4b5f0ab95d0e3d49101c0bb7cebcd80720d4bf007440df216f03d573f257994d3cb33f0f39a225f4918ff23438276c0c28cceef9c377999
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
5
 
6
+ ## [v0.5.0](https://github.com/puppetlabs/pdk/tree/v0.5.0) (2017-07-20)
7
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.4.4...v0.5.0)
8
+
9
+ **Implemented enhancements:**
10
+
11
+ - \(SDK-329\) implement running arbitrary commands in PDK's environment [\#179](https://github.com/puppetlabs/pdk/pull/179) ([DavidS](https://github.com/DavidS))
12
+ - \(maint\) Add 2.1.9 as the minimum required ruby version in the gemspec [\#176](https://github.com/puppetlabs/pdk/pull/176) ([rodjek](https://github.com/rodjek))
13
+
14
+ **Fixed bugs:**
15
+
16
+ - \(SDK-331\) allow additional gems to be installed [\#178](https://github.com/puppetlabs/pdk/pull/178) ([DavidS](https://github.com/DavidS))
17
+
6
18
  ## [v0.4.4](https://github.com/puppetlabs/pdk/tree/v0.4.4) (2017-07-18)
7
19
  [Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.4.3...v0.4.4)
8
20
 
data/README.md CHANGED
@@ -238,7 +238,7 @@ Running validations on `new_module/lib`:
238
238
  * puppet syntax: (no puppet manifests found)
239
239
  ```
240
240
 
241
- #### `pdk test unit` command
241
+ ### `pdk test unit` command
242
242
 
243
243
  Runs unit tests. Any errors are displayed to the console and reported in the report-file, if requested. The exitcode is non-zero when errors occur.
244
244
 
@@ -270,13 +270,36 @@ Multiple `--format` options can be specified as long as they all have distinct o
270
270
 
271
271
  Specifies options to pass through to the actual test-runner. In the default template (and most commonly across modules), this is [rspec](https://relishapp.com/rspec/rspec-core/docs/command-line).
272
272
 
273
+ ### `pdk bundle` command
274
+
275
+ This experimental command allows advanced users to execute arbitrary commands in a bundler context within the module you're currently working on. Arguments to this command are passed straight through to bundler. Careless use of this command can lead to errors later which can't be recovered by the pdk itself.
276
+
277
+ Note that for most advanced uses it is required to use the `--` to separate bundler options from pdk options. Compare the following two commands:
278
+
279
+ ```
280
+ $ pdk bundle exec rake -T
281
+ bundle: illegal option -- T
282
+
283
+ ```
284
+
285
+ and
286
+
287
+ ```
288
+ $ pdk bundle -- exec rake -T
289
+ rake beaker # Run beaker acceptance tests
290
+ rake beaker:sets # List available beaker nodesets
291
+ rake beaker:ssh[set,node] # Try to use vagrant to login to the Beaker node
292
+ rake build # Build puppet module package
293
+ [...]
294
+ ```
295
+
273
296
  ## Contributing
274
297
 
275
298
  In cases where `pdk` needs to run in a working directory outside the cloned repository, either set `BUNDLE_GEMFILE` to the pdk's Gemfile location, or install and use the [binstubs of bundler](http://bundler.io/v1.15/bundle_binstubs.html), which are small proxy binaries, that set up the environment for running the tool.
276
299
 
277
300
  ```
278
301
  # assuming ~/bin is already on your path:
279
- bundle binstubs pdk --path ~/bin
302
+ $ bundle binstubs pdk --path ~/bin
280
303
  ```
281
304
 
282
305
  Bug reports and pull requests are welcome on GitHub at https://github.com/puppetlabs/pdk/issues.
@@ -72,6 +72,7 @@ module PDK::CLI
72
72
  end
73
73
  end
74
74
 
75
+ require 'pdk/cli/bundle'
75
76
  require 'pdk/cli/new'
76
77
  require 'pdk/cli/test'
77
78
  require 'pdk/cli/validate'
@@ -0,0 +1,25 @@
1
+
2
+ module PDK::CLI
3
+ @bundle_cmd = @base_cmd.define_command do
4
+ name 'bundle'
5
+ usage _('bundle -- [bundler_options]')
6
+ summary _('escape hatch to bundler')
7
+ description _('[experimental] For advanced users, this allows to run arbitrary commands in the bundler environment that the pdk manages. ' \
8
+ 'Careless use of this command can lead to errors later which can\'t be recovered by the pdk itself.')
9
+
10
+ run do |_opts, args, _cmd|
11
+ PDK::CLI::Util.ensure_in_module!
12
+
13
+ command = PDK::CLI::Exec::Command.new(PDK::CLI::Exec.bundle_bin, *args).tap do |c|
14
+ c.context = :module
15
+ end
16
+
17
+ result = command.execute!
18
+
19
+ $stderr.puts result[:stdout]
20
+ $stderr.puts result[:stderr]
21
+
22
+ exit result[:exit_code]
23
+ end
24
+ end
25
+ end
@@ -104,13 +104,17 @@ module PDK
104
104
  end
105
105
 
106
106
  if context == :module
107
+ # `bundle install --path` ignores all "system" installed gems and causes unnecessary package installs
108
+ # `bundle install` (without --path) installs into GEM_HOME, which by default is non-user writeable
109
+ # To still use the pre-installed packages, but allow folks to install additional gems
110
+ # we set GEM_HOME to the user's cachedir, and put all other cache locations onto GEM_PATH
111
+ # See https://stackoverflow.com/a/11277228 for background
112
+ @process.environment['GEM_HOME'] = File.join(PDK::Util.cachedir, 'ruby', RbConfig::CONFIG['ruby_version'])
113
+
107
114
  if PDK::Util.package_install?
108
115
  # Subprocesses use their own set of gems which are managed by pdk or installed with the package.
109
- @process.environment['GEM_HOME'] = File.join(PDK::Util.package_cachedir, 'ruby', RbConfig::CONFIG['ruby_version'])
116
+ @process.environment['GEM_PATH'] = File.join(PDK::Util.package_cachedir, 'ruby', RbConfig::CONFIG['ruby_version'])
110
117
  else
111
- # Subprocesses use their own set of gems which are managed by pdk or installed with the package.
112
- @process.environment['GEM_HOME'] = File.join(PDK::Util.cachedir, 'ruby', RbConfig::CONFIG['ruby_version'])
113
-
114
118
  # This allows the subprocess to find the 'bundler' gem, which isn't in the cachedir above for gem installs.
115
119
  bundler_gem_path = File.absolute_path(File.join(`gem which bundler`, '..', '..', '..', '..'))
116
120
  @process.environment['GEM_PATH'] = bundler_gem_path
@@ -36,18 +36,33 @@ module PDK
36
36
  end
37
37
 
38
38
  def self.parse_output(report, result, targets)
39
- begin
40
- json_data = JSON.parse(result[:stdout])
41
- rescue JSON::ParserError
42
- json_data = []
43
- end
39
+ raise ArgumentError, 'More than 1 target provided to PDK::Validate::MetadataJSONLint' if targets.count > 1
44
40
 
45
- raise ArgumentError, 'More that 1 target provided to PDK::Validate::MetadataJSONLint' if targets.count > 1
41
+ if result[:stdout].strip.empty?
42
+ # metadata-json-lint will print nothing if there are no problems with
43
+ # the file being linted. This should be handled separately to
44
+ # metadata-json-lint generating output that can not be parsed as JSON
45
+ # (unhandled exception in metadata-json-lint).
46
+ json_data = {}
47
+ else
48
+ begin
49
+ json_data = JSON.parse(result[:stdout])
50
+ rescue JSON::ParserError
51
+ report.add_event(
52
+ file: targets.first,
53
+ source: name,
54
+ state: :error,
55
+ severity: :error,
56
+ message: result[:stdout],
57
+ )
58
+ return
59
+ end
60
+ end
46
61
 
47
62
  if json_data.empty?
48
63
  report.add_event(
49
64
  file: targets.first,
50
- source: cmd,
65
+ source: name,
51
66
  state: :passed,
52
67
  severity: :ok,
53
68
  )
@@ -62,7 +77,7 @@ module PDK
62
77
 
63
78
  report.add_event(
64
79
  file: targets.first,
65
- source: cmd,
80
+ source: name,
66
81
  message: offense['msg'],
67
82
  test: offense['check'],
68
83
  severity: event_type,
@@ -43,7 +43,7 @@ module PDK
43
43
  targets.reject { |target| json_data.any? { |j| j['path'] == target } }.each do |target|
44
44
  report.add_event(
45
45
  file: target,
46
- source: 'puppet-lint',
46
+ source: name,
47
47
  severity: 'ok',
48
48
  state: :passed,
49
49
  )
@@ -52,7 +52,7 @@ module PDK
52
52
  json_data.each do |offense|
53
53
  report.add_event(
54
54
  file: offense['path'],
55
- source: 'puppet-lint',
55
+ source: name,
56
56
  line: offense['line'],
57
57
  column: offense['column'],
58
58
  message: offense['message'],
@@ -44,7 +44,7 @@ module PDK
44
44
  attributes = {
45
45
  source: name,
46
46
  message: message.strip,
47
- state: 'failure',
47
+ state: :failure,
48
48
  }
49
49
  attributes[:severity] = severity.strip unless severity.nil?
50
50
 
@@ -57,14 +57,14 @@ module PDK
57
57
  results_data << attributes
58
58
  end
59
59
 
60
- # puppet-lint does not include files without problems in its JSON
60
+ # puppet parser validate does not include files without problems in its
61
61
  # output, so we need to go through the list of targets and add passing
62
- # events to the report for any target not listed in the JSON output.
62
+ # events to the report for any target not listed in the output.
63
63
  targets.reject { |target| results_data.any? { |j| j[:file] == target } }.each do |target|
64
64
  report.add_event(
65
65
  file: target,
66
- source: 'puppet-syntax',
67
- severity: 'ok',
66
+ source: name,
67
+ severity: :ok,
68
68
  state: :passed,
69
69
  )
70
70
  end
@@ -1,3 +1,3 @@
1
1
  module PDK
2
- VERSION = '0.4.4'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  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: 0.4.4
4
+ version: 0.5.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-07-18 00:00:00.000000000 Z
11
+ date: 2017-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -137,6 +137,7 @@ files:
137
137
  - lib/pdk.rb
138
138
  - lib/pdk/answer_file.rb
139
139
  - lib/pdk/cli.rb
140
+ - lib/pdk/cli/bundle.rb
140
141
  - lib/pdk/cli/errors.rb
141
142
  - lib/pdk/cli/exec.rb
142
143
  - lib/pdk/cli/new.rb
@@ -193,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
194
  requirements:
194
195
  - - ">="
195
196
  - !ruby/object:Gem::Version
196
- version: '0'
197
+ version: 2.1.9
197
198
  required_rubygems_version: !ruby/object:Gem::Requirement
198
199
  requirements:
199
200
  - - ">="
@@ -201,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  version: '0'
202
203
  requirements: []
203
204
  rubyforge_project:
204
- rubygems_version: 2.2.5
205
+ rubygems_version: 2.5.2
205
206
  signing_key:
206
207
  specification_version: 4
207
208
  summary: A key part of the Puppet Development Kit, the shortest path to better modules