pdk 1.17.0 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +71 -2
  3. data/lib/pdk/cli/convert.rb +7 -9
  4. data/lib/pdk/cli/new/class.rb +2 -1
  5. data/lib/pdk/cli/new/defined_type.rb +2 -1
  6. data/lib/pdk/cli/new/provider.rb +2 -1
  7. data/lib/pdk/cli/new/task.rb +2 -1
  8. data/lib/pdk/cli/new/test.rb +2 -1
  9. data/lib/pdk/cli/new/transport.rb +2 -1
  10. data/lib/pdk/cli/remove/config.rb +80 -0
  11. data/lib/pdk/cli/remove.rb +20 -0
  12. data/lib/pdk/cli/set/config.rb +119 -0
  13. data/lib/pdk/cli/set.rb +20 -0
  14. data/lib/pdk/cli/update.rb +6 -8
  15. data/lib/pdk/cli/util/update_manager_printer.rb +82 -0
  16. data/lib/pdk/cli/util.rb +1 -0
  17. data/lib/pdk/cli.rb +2 -0
  18. data/lib/pdk/config.rb +96 -13
  19. data/lib/pdk/context.rb +8 -5
  20. data/lib/pdk/generate/defined_type.rb +25 -32
  21. data/lib/pdk/generate/module.rb +11 -10
  22. data/lib/pdk/generate/provider.rb +16 -65
  23. data/lib/pdk/generate/puppet_class.rb +25 -31
  24. data/lib/pdk/generate/puppet_object.rb +83 -187
  25. data/lib/pdk/generate/resource_api_object.rb +55 -0
  26. data/lib/pdk/generate/task.rb +28 -46
  27. data/lib/pdk/generate/transport.rb +21 -75
  28. data/lib/pdk/generate.rb +1 -0
  29. data/lib/pdk/module/convert.rb +41 -23
  30. data/lib/pdk/module/release.rb +1 -1
  31. data/lib/pdk/module/update.rb +6 -10
  32. data/lib/pdk/module/update_manager.rb +7 -0
  33. data/lib/pdk/module.rb +0 -1
  34. data/lib/pdk/template/fetcher/git.rb +85 -0
  35. data/lib/pdk/template/fetcher/local.rb +28 -0
  36. data/lib/pdk/template/fetcher.rb +98 -0
  37. data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +116 -0
  38. data/lib/pdk/template/renderer/v1/renderer.rb +132 -0
  39. data/lib/pdk/template/renderer/v1/template_file.rb +102 -0
  40. data/lib/pdk/template/renderer/v1.rb +25 -0
  41. data/lib/pdk/template/renderer.rb +96 -0
  42. data/lib/pdk/template/template_dir.rb +67 -0
  43. data/lib/pdk/template.rb +59 -0
  44. data/lib/pdk/tests/unit.rb +5 -0
  45. data/lib/pdk/util/json_finder.rb +84 -0
  46. data/lib/pdk/util/puppet_strings.rb +3 -3
  47. data/lib/pdk/util/template_uri.rb +4 -6
  48. data/lib/pdk/util.rb +4 -35
  49. data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -0
  50. data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -0
  51. data/lib/pdk/validate/invokable_validator.rb +2 -3
  52. data/lib/pdk/validate/validator.rb +7 -0
  53. data/lib/pdk/validate/validator_group.rb +1 -0
  54. data/lib/pdk/validate.rb +17 -10
  55. data/lib/pdk/version.rb +1 -1
  56. data/lib/pdk.rb +1 -1
  57. data/locales/pdk.pot +356 -228
  58. metadata +33 -12
  59. data/lib/pdk/module/template_dir/base.rb +0 -268
  60. data/lib/pdk/module/template_dir/git.rb +0 -91
  61. data/lib/pdk/module/template_dir/local.rb +0 -21
  62. data/lib/pdk/module/template_dir.rb +0 -115
  63. data/lib/pdk/template_file.rb +0 -96
@@ -1,96 +0,0 @@
1
- require 'ostruct'
2
- require 'pdk'
3
-
4
- module PDK
5
- class TemplateFile < OpenStruct
6
- # Initialises the TemplateFile object with the path to the template file
7
- # and the data to be used when rendering the template.
8
- #
9
- # @param template_file [String] The path on disk to the template file.
10
- # @param data [Hash{Symbol => Object}] The data that should be provided to
11
- # the template when rendering.
12
- # @option data [Object] :configs The value of this key will be provided to
13
- # the template as an instance variable `@configs` in order to maintain
14
- # compatibility with modulesync.
15
- #
16
- # @api public
17
- def initialize(template_file, data = {})
18
- @template_file = template_file
19
-
20
- if data.key?(:configs)
21
- @configs = data[:configs]
22
- end
23
-
24
- super(data)
25
- end
26
-
27
- # Renders the template by calling the appropriate engine based on the file
28
- # extension.
29
- #
30
- # If the template has an `.erb` extension, the content of the template
31
- # file will be treated as an ERB template. All other extensions are treated
32
- # as plain text.
33
- #
34
- # @return [String] The rendered template
35
- #
36
- # @raise (see #template_content)
37
- #
38
- # @api public
39
- def render
40
- case File.extname(@template_file)
41
- when '.erb'
42
- render_erb
43
- else
44
- render_plain
45
- end
46
- end
47
-
48
- def config_for(path)
49
- return unless respond_to?(:template_dir)
50
-
51
- template_dir.config_for(path)
52
- end
53
-
54
- private
55
-
56
- # Reads the content of the template file into memory.
57
- #
58
- # @return [String] The content of the template file.
59
- #
60
- # @raise [ArgumentError] If the template file does not exist or can not be
61
- # read.
62
- #
63
- # @api private
64
- def template_content
65
- if PDK::Util::Filesystem.file?(@template_file) && PDK::Util::Filesystem.readable?(@template_file)
66
- return PDK::Util::Filesystem.read_file(@template_file)
67
- end
68
-
69
- raise ArgumentError, _("'%{template}' is not a readable file") % { template: @template_file }
70
- end
71
-
72
- # Renders the content of the template file as an ERB template.
73
- #
74
- # @return [String] The rendered template.
75
- #
76
- # @raise (see #template_content)
77
- #
78
- # @api private
79
- def render_erb
80
- renderer = ERB.new(template_content, nil, '-')
81
- renderer.filename = @template_file
82
- renderer.result(binding)
83
- end
84
-
85
- # Renders the content of the template file as plain text.
86
- #
87
- # @return [String] The rendered template.
88
- #
89
- # @raise (see #template_content)
90
- #
91
- # @api private
92
- def render_plain
93
- template_content
94
- end
95
- end
96
- end