pdk 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +41 -0
  4. data/lib/pdk.rb +0 -13
  5. data/lib/pdk/analytics.rb +18 -2
  6. data/lib/pdk/analytics/client/google_analytics.rb +3 -0
  7. data/lib/pdk/answer_file.rb +4 -1
  8. data/lib/pdk/cli.rb +7 -2
  9. data/lib/pdk/cli/build.rb +2 -2
  10. data/lib/pdk/cli/bundle.rb +7 -1
  11. data/lib/pdk/cli/console.rb +148 -0
  12. data/lib/pdk/cli/convert.rb +2 -2
  13. data/lib/pdk/cli/exec.rb +14 -14
  14. data/lib/pdk/cli/exec/command.rb +16 -11
  15. data/lib/pdk/cli/exec/interactive_command.rb +4 -0
  16. data/lib/pdk/cli/exec_group.rb +5 -5
  17. data/lib/pdk/cli/module/build.rb +0 -2
  18. data/lib/pdk/cli/module/generate.rb +1 -2
  19. data/lib/pdk/cli/new.rb +1 -1
  20. data/lib/pdk/cli/new/defined_type.rb +2 -0
  21. data/lib/pdk/cli/new/provider.rb +2 -0
  22. data/lib/pdk/cli/new/task.rb +2 -0
  23. data/lib/pdk/cli/new/{unit_test.rb → test.rb} +16 -12
  24. data/lib/pdk/cli/new/transport.rb +2 -0
  25. data/lib/pdk/cli/test/unit.rb +5 -3
  26. data/lib/pdk/cli/update.rb +2 -3
  27. data/lib/pdk/cli/util.rb +45 -14
  28. data/lib/pdk/cli/util/spinner.rb +2 -2
  29. data/lib/pdk/cli/validate.rb +6 -2
  30. data/lib/pdk/config.rb +20 -8
  31. data/lib/pdk/config/analytics_schema.json +26 -0
  32. data/lib/pdk/config/json.rb +14 -3
  33. data/lib/pdk/config/json_schema_namespace.rb +143 -0
  34. data/lib/pdk/config/json_schema_setting.rb +53 -0
  35. data/lib/pdk/config/json_with_schema.rb +50 -0
  36. data/lib/pdk/config/namespace.rb +84 -76
  37. data/lib/pdk/config/setting.rb +132 -0
  38. data/lib/pdk/config/yaml.rb +15 -3
  39. data/lib/pdk/config/yaml_with_schema.rb +59 -0
  40. data/lib/pdk/generate.rb +0 -2
  41. data/lib/pdk/generate/module.rb +29 -16
  42. data/lib/pdk/generate/puppet_object.rb +31 -28
  43. data/lib/pdk/module.rb +2 -2
  44. data/lib/pdk/module/build.rb +21 -8
  45. data/lib/pdk/module/convert.rb +64 -7
  46. data/lib/pdk/module/metadata.rb +5 -1
  47. data/lib/pdk/module/templatedir.rb +24 -7
  48. data/lib/pdk/module/update.rb +5 -1
  49. data/lib/pdk/module/update_manager.rb +21 -13
  50. data/lib/pdk/report.rb +4 -3
  51. data/lib/pdk/report/event.rb +5 -3
  52. data/lib/pdk/tests/unit.rb +36 -7
  53. data/lib/pdk/util.rb +20 -8
  54. data/lib/pdk/util/bundler.rb +14 -6
  55. data/lib/pdk/util/filesystem.rb +5 -0
  56. data/lib/pdk/util/git.rb +6 -0
  57. data/lib/pdk/util/puppet_strings.rb +24 -2
  58. data/lib/pdk/util/puppet_version.rb +25 -10
  59. data/lib/pdk/util/ruby_version.rb +13 -1
  60. data/lib/pdk/util/template_uri.rb +23 -2
  61. data/lib/pdk/util/vendored_file.rb +28 -24
  62. data/lib/pdk/util/version.rb +5 -5
  63. data/lib/pdk/validate/base_validator.rb +5 -4
  64. data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -4
  65. data/lib/pdk/validate/metadata/metadata_syntax.rb +5 -3
  66. data/lib/pdk/validate/metadata_validator.rb +0 -2
  67. data/lib/pdk/validate/puppet/puppet_epp.rb +4 -4
  68. data/lib/pdk/validate/puppet/puppet_lint.rb +0 -3
  69. data/lib/pdk/validate/puppet/puppet_syntax.rb +4 -4
  70. data/lib/pdk/validate/puppet_validator.rb +0 -2
  71. data/lib/pdk/validate/ruby/rubocop.rb +0 -5
  72. data/lib/pdk/validate/ruby_validator.rb +0 -2
  73. data/lib/pdk/validate/tasks/metadata_lint.rb +9 -5
  74. data/lib/pdk/validate/tasks/name.rb +4 -2
  75. data/lib/pdk/validate/tasks_validator.rb +0 -2
  76. data/lib/pdk/validate/yaml/syntax.rb +4 -4
  77. data/lib/pdk/validate/yaml_validator.rb +0 -2
  78. data/lib/pdk/version.rb +1 -1
  79. data/locales/pdk.pot +351 -311
  80. metadata +11 -7
  81. data/lib/pdk/config/validator.rb +0 -31
  82. data/lib/pdk/config/value.rb +0 -94
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.13.0
4
+ version: 1.14.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: 2019-08-29 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -291,6 +291,7 @@ files:
291
291
  - lib/pdk/cli/bundle.rb
292
292
  - lib/pdk/cli/config.rb
293
293
  - lib/pdk/cli/config/get.rb
294
+ - lib/pdk/cli/console.rb
294
295
  - lib/pdk/cli/convert.rb
295
296
  - lib/pdk/cli/errors.rb
296
297
  - lib/pdk/cli/exec.rb
@@ -306,8 +307,8 @@ files:
306
307
  - lib/pdk/cli/new/module.rb
307
308
  - lib/pdk/cli/new/provider.rb
308
309
  - lib/pdk/cli/new/task.rb
310
+ - lib/pdk/cli/new/test.rb
309
311
  - lib/pdk/cli/new/transport.rb
310
- - lib/pdk/cli/new/unit_test.rb
311
312
  - lib/pdk/cli/test.rb
312
313
  - lib/pdk/cli/test/unit.rb
313
314
  - lib/pdk/cli/update.rb
@@ -319,12 +320,16 @@ files:
319
320
  - lib/pdk/cli/util/spinner.rb
320
321
  - lib/pdk/cli/validate.rb
321
322
  - lib/pdk/config.rb
323
+ - lib/pdk/config/analytics_schema.json
322
324
  - lib/pdk/config/errors.rb
323
325
  - lib/pdk/config/json.rb
326
+ - lib/pdk/config/json_schema_namespace.rb
327
+ - lib/pdk/config/json_schema_setting.rb
328
+ - lib/pdk/config/json_with_schema.rb
324
329
  - lib/pdk/config/namespace.rb
325
- - lib/pdk/config/validator.rb
326
- - lib/pdk/config/value.rb
330
+ - lib/pdk/config/setting.rb
327
331
  - lib/pdk/config/yaml.rb
332
+ - lib/pdk/config/yaml_with_schema.rb
328
333
  - lib/pdk/generate.rb
329
334
  - lib/pdk/generate/defined_type.rb
330
335
  - lib/pdk/generate/module.rb
@@ -397,8 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
397
402
  - !ruby/object:Gem::Version
398
403
  version: '0'
399
404
  requirements: []
400
- rubyforge_project:
401
- rubygems_version: 2.6.14.4
405
+ rubygems_version: 3.0.6
402
406
  signing_key:
403
407
  specification_version: 4
404
408
  summary: A key part of the Puppet Development Kit, the shortest path to better modules
@@ -1,31 +0,0 @@
1
- module PDK
2
- class Config
3
- # A collection of predefined validators for use with {PDK::Config::Value}.
4
- #
5
- # @example
6
- # value :enabled do
7
- # validate PDK::Config::Validator.boolean
8
- # end
9
- module Validator
10
- # @return [Hash{Symbol => [Proc,String]}] a {PDK::Config::Value}
11
- # validator that ensures that the value is either a TrueClass or
12
- # FalseClass.
13
- def self.boolean
14
- {
15
- proc: ->(value) { [true, false].include?(value) },
16
- message: _('must be a boolean: true or false'),
17
- }
18
- end
19
-
20
- # @return [Hash{Symbol => [Proc,String]}] a {PDK::Config::Value}
21
- # validator that ensures that the value is a String that matches the
22
- # regex for a version 4 UUID.
23
- def self.uuid
24
- {
25
- proc: ->(value) { value.match(%r{\A\h{8}(?:-\h{4}){3}-\h{12}\z}) },
26
- message: _('must be a version 4 UUID'),
27
- }
28
- end
29
- end
30
- end
31
- end
@@ -1,94 +0,0 @@
1
- module PDK
2
- class Config
3
- # A class for describing the value of a {PDK::Config} setting.
4
- #
5
- # Generally, this is never instantiated manually, but is instead
6
- # instantiated by passing a block to {PDK::Config::Namespace#value}.
7
- #
8
- # @example
9
- #
10
- # PDK::Config::Namespace.new('analytics') do
11
- # value :disabled do
12
- # validate PDK::Config::Validator.boolean
13
- # default_to { false }
14
- # end
15
- # end
16
- class Value
17
- # Initialises an empty value definition.
18
- #
19
- # @param name [String,Symbol] the name of the value.
20
- def initialize(name)
21
- @name = name
22
- @validators = []
23
- end
24
-
25
- # Assign a validator to the value.
26
- #
27
- # @param validator [Hash{Symbol => [Proc,String]}]
28
- # @option validator [Proc] :proc a lambda that takes the value to be
29
- # validated as the argument and returns `true` if the value is valid.
30
- # @option validator [String] :message a description of what the validator
31
- # is testing for, that is displayed to the user as part of the error
32
- # message for invalid values.
33
- #
34
- # @raise [ArgumentError] if not passed a Hash.
35
- # @raise [ArgumentError] if the Hash doesn't have a `:proc` key that
36
- # contains a Proc.
37
- # @raise [ArgumentError] if the Hash doesn't have a `:message` key that
38
- # contains a String.
39
- #
40
- # @return [nil]
41
- def validate(validator)
42
- raise ArgumentError, _('`validator` must be a Hash') unless validator.is_a?(Hash)
43
- raise ArgumentError, _('the :proc key must contain a Proc') unless validator.key?(:proc) && validator[:proc].is_a?(Proc)
44
- raise ArgumentError, _('the :message key must contain a String') unless validator.key?(:message) && validator[:message].is_a?(String)
45
-
46
- @validators << validator
47
- end
48
-
49
- # Validate a value against the assigned validators.
50
- #
51
- # @param key [String] the name of the value being validated.
52
- # @param value [Object] the value being validated.
53
- #
54
- # @raise [ArgumentError] if any of the assigned validators fail to
55
- # validate the value.
56
- #
57
- # @return [nil]
58
- def validate!(key, value)
59
- @validators.each do |validator|
60
- next if validator[:proc].call(value)
61
-
62
- raise ArgumentError, _('%{key} %{message}') % {
63
- key: key,
64
- message: validator[:message],
65
- }
66
- end
67
- end
68
-
69
- # Assign a default value.
70
- #
71
- # @param block [Proc] a block that is lazy evaluated when necessary in
72
- # order to determine the default value.
73
- #
74
- # @return [nil]
75
- def default_to(&block)
76
- raise ArgumentError, _('must be passed a block') unless block_given?
77
- @default_to = block
78
- end
79
-
80
- # Evaluate the default value block.
81
- #
82
- # @return [Object,nil] the result of evaluating the block given to
83
- # {#default_to}, or `nil` if the value has no default.
84
- def default
85
- default? ? @default_to.call : nil
86
- end
87
-
88
- # @return [Boolean] true if the value has a default value block.
89
- def default?
90
- !@default_to.nil?
91
- end
92
- end
93
- end
94
- end