pdk 1.15.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +168 -10
- data/README.md +1 -1
- data/lib/pdk.rb +28 -19
- data/lib/pdk/answer_file.rb +2 -93
- data/lib/pdk/bolt.rb +19 -0
- data/lib/pdk/cli.rb +7 -6
- data/lib/pdk/cli/bundle.rb +5 -1
- data/lib/pdk/cli/config.rb +3 -1
- data/lib/pdk/cli/config/get.rb +3 -1
- data/lib/pdk/cli/convert.rb +7 -9
- data/lib/pdk/cli/exec/command.rb +45 -4
- data/lib/pdk/cli/exec_group.rb +78 -43
- data/lib/pdk/cli/get.rb +20 -0
- data/lib/pdk/cli/get/config.rb +24 -0
- data/lib/pdk/cli/new.rb +2 -0
- data/lib/pdk/cli/new/class.rb +2 -2
- data/lib/pdk/cli/new/defined_type.rb +2 -2
- data/lib/pdk/cli/new/fact.rb +29 -0
- data/lib/pdk/cli/new/function.rb +29 -0
- data/lib/pdk/cli/new/provider.rb +2 -2
- data/lib/pdk/cli/new/task.rb +2 -2
- data/lib/pdk/cli/new/test.rb +2 -2
- data/lib/pdk/cli/new/transport.rb +2 -2
- data/lib/pdk/cli/release/publish.rb +11 -1
- data/lib/pdk/cli/remove.rb +20 -0
- data/lib/pdk/cli/remove/config.rb +80 -0
- data/lib/pdk/cli/set.rb +20 -0
- data/lib/pdk/cli/set/config.rb +119 -0
- data/lib/pdk/cli/update.rb +6 -8
- data/lib/pdk/cli/util.rb +7 -3
- data/lib/pdk/cli/util/option_validator.rb +6 -0
- data/lib/pdk/cli/util/update_manager_printer.rb +82 -0
- data/lib/pdk/cli/validate.rb +26 -44
- data/lib/pdk/config.rb +264 -7
- data/lib/pdk/config/ini_file.rb +183 -0
- data/lib/pdk/config/ini_file_setting.rb +39 -0
- data/lib/pdk/config/namespace.rb +25 -5
- data/lib/pdk/config/setting.rb +3 -2
- data/lib/pdk/context.rb +99 -0
- data/lib/pdk/context/control_repo.rb +60 -0
- data/lib/pdk/context/module.rb +28 -0
- data/lib/pdk/context/none.rb +22 -0
- data/lib/pdk/control_repo.rb +90 -0
- data/lib/pdk/generate/defined_type.rb +25 -32
- data/lib/pdk/generate/fact.rb +25 -0
- data/lib/pdk/generate/function.rb +48 -0
- data/lib/pdk/generate/module.rb +33 -20
- data/lib/pdk/generate/provider.rb +15 -64
- data/lib/pdk/generate/puppet_class.rb +25 -31
- data/lib/pdk/generate/puppet_object.rb +84 -188
- data/lib/pdk/generate/task.rb +28 -46
- data/lib/pdk/generate/transport.rb +20 -74
- data/lib/pdk/module.rb +1 -1
- data/lib/pdk/module/build.rb +23 -0
- data/lib/pdk/module/convert.rb +58 -34
- data/lib/pdk/module/metadata.rb +6 -2
- data/lib/pdk/module/release.rb +3 -9
- data/lib/pdk/module/update.rb +8 -12
- data/lib/pdk/module/update_manager.rb +7 -0
- data/lib/pdk/report.rb +3 -3
- data/lib/pdk/report/event.rb +8 -2
- data/lib/pdk/template.rb +59 -0
- data/lib/pdk/template/fetcher.rb +98 -0
- data/lib/pdk/template/fetcher/git.rb +85 -0
- data/lib/pdk/template/fetcher/local.rb +28 -0
- data/lib/pdk/template/renderer.rb +96 -0
- data/lib/pdk/template/renderer/v1.rb +25 -0
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +116 -0
- data/lib/pdk/template/renderer/v1/renderer.rb +132 -0
- data/lib/pdk/template/renderer/v1/template_file.rb +102 -0
- data/lib/pdk/template/template_dir.rb +67 -0
- data/lib/pdk/tests/unit.rb +8 -1
- data/lib/pdk/util.rb +38 -39
- data/lib/pdk/util/bundler.rb +2 -1
- data/lib/pdk/util/changelog_generator.rb +11 -2
- data/lib/pdk/util/env.rb +28 -11
- data/lib/pdk/util/json_finder.rb +84 -0
- data/lib/pdk/util/puppet_strings.rb +3 -3
- data/lib/pdk/util/puppet_version.rb +2 -2
- data/lib/pdk/util/ruby_version.rb +11 -4
- data/lib/pdk/util/template_uri.rb +17 -14
- data/lib/pdk/util/vendored_file.rb +1 -2
- data/lib/pdk/validate.rb +79 -25
- data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -0
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -0
- data/lib/pdk/validate/external_command_validator.rb +208 -0
- data/lib/pdk/validate/internal_ruby_validator.rb +100 -0
- data/lib/pdk/validate/invokable_validator.rb +220 -0
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +86 -0
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +78 -0
- data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -0
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +133 -0
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -0
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +137 -0
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +21 -0
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +80 -0
- data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -0
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +88 -0
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +50 -0
- data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -0
- data/lib/pdk/validate/validator.rb +118 -0
- data/lib/pdk/validate/validator_group.rb +104 -0
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +95 -0
- data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -0
- data/lib/pdk/version.rb +1 -1
- data/locales/pdk.pot +513 -329
- metadata +76 -32
- data/lib/pdk/module/template_dir.rb +0 -115
- data/lib/pdk/module/template_dir/base.rb +0 -268
- data/lib/pdk/module/template_dir/git.rb +0 -91
- data/lib/pdk/module/template_dir/local.rb +0 -21
- data/lib/pdk/template_file.rb +0 -96
- data/lib/pdk/validate/base_validator.rb +0 -215
- data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -82
- data/lib/pdk/validate/metadata/metadata_syntax.rb +0 -111
- data/lib/pdk/validate/metadata_validator.rb +0 -26
- data/lib/pdk/validate/puppet/puppet_epp.rb +0 -135
- data/lib/pdk/validate/puppet/puppet_lint.rb +0 -64
- data/lib/pdk/validate/puppet/puppet_syntax.rb +0 -135
- data/lib/pdk/validate/puppet_validator.rb +0 -26
- data/lib/pdk/validate/ruby/rubocop.rb +0 -72
- data/lib/pdk/validate/ruby_validator.rb +0 -26
- data/lib/pdk/validate/tasks/metadata_lint.rb +0 -130
- data/lib/pdk/validate/tasks/name.rb +0 -90
- data/lib/pdk/validate/tasks_validator.rb +0 -29
- data/lib/pdk/validate/yaml/syntax.rb +0 -125
- data/lib/pdk/validate/yaml_validator.rb +0 -28
@@ -3,84 +3,30 @@ require 'pdk'
|
|
3
3
|
module PDK
|
4
4
|
module Generate
|
5
5
|
class Transport < PuppetObject
|
6
|
-
|
7
|
-
|
8
|
-
# Prepares the data needed to render the new defined type template.
|
9
|
-
#
|
10
|
-
# @return [Hash{Symbol => Object}] a hash of information that will be
|
11
|
-
# provided to the defined type and defined type spec templates during
|
12
|
-
# rendering.
|
13
|
-
def template_data
|
14
|
-
data = {
|
15
|
-
name: object_name,
|
16
|
-
transport_class: Transport.class_name_from_object_name(object_name),
|
17
|
-
}
|
18
|
-
|
19
|
-
data
|
20
|
-
end
|
21
|
-
|
22
|
-
def raise_precondition_error(error)
|
23
|
-
raise PDK::CLI::ExitWithError, _('%{error}: Creating a transport needs some local configuration in your module.' \
|
24
|
-
' Please follow the docs at https://github.com/puppetlabs/puppet-resource_api#getting-started.') % { error: error }
|
25
|
-
end
|
26
|
-
|
27
|
-
def check_preconditions
|
28
|
-
super
|
29
|
-
# These preconditions can be removed once the pdk-templates are carrying the puppet-resource_api gem by default, and have switched
|
30
|
-
# the default mock_with value.
|
31
|
-
sync_path = PDK::Util.find_upwards('.sync.yml')
|
32
|
-
if sync_path.nil?
|
33
|
-
raise_precondition_error(_('.sync.yml not found'))
|
34
|
-
end
|
35
|
-
sync = YAML.load_file(sync_path)
|
36
|
-
if !sync.is_a? Hash
|
37
|
-
raise_precondition_error(_('.sync.yml contents is not a Hash'))
|
38
|
-
elsif !sync.key? 'Gemfile'
|
39
|
-
raise_precondition_error(_('Gemfile configuration not found'))
|
40
|
-
elsif !sync['Gemfile'].key? 'optional'
|
41
|
-
raise_precondition_error(_('Gemfile.optional configuration not found'))
|
42
|
-
elsif !sync['Gemfile']['optional'].key? ':development'
|
43
|
-
raise_precondition_error(_('Gemfile.optional.:development configuration not found'))
|
44
|
-
elsif sync['Gemfile']['optional'][':development'].none? { |g| g['gem'] == 'puppet-resource_api' }
|
45
|
-
raise_precondition_error(_('puppet-resource_api not found in the Gemfile config'))
|
46
|
-
elsif !sync.key? 'spec/spec_helper.rb'
|
47
|
-
raise_precondition_error(_('spec/spec_helper.rb configuration not found'))
|
48
|
-
elsif !sync['spec/spec_helper.rb'].key? 'mock_with'
|
49
|
-
raise_precondition_error(_('spec/spec_helper.rb.mock_with configuration not found'))
|
50
|
-
elsif !sync['spec/spec_helper.rb']['mock_with'] == ':rspec'
|
51
|
-
raise_precondition_error(_('spec/spec_helper.rb.mock_with not set to \':rspec\''))
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# @return [String] the path where the new transport will be written.
|
56
|
-
def target_object_path
|
57
|
-
@target_object_path ||= File.join(module_dir, 'lib', 'puppet', 'transport', object_name) + '.rb'
|
6
|
+
def friendly_name
|
7
|
+
'Resource API Transport'.freeze
|
58
8
|
end
|
59
9
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@target_spec_path ||= File.join(module_dir, 'spec', 'unit', 'puppet', 'transport', object_name) + '_spec.rb'
|
74
|
-
end
|
75
|
-
|
76
|
-
# @return [String] the path where the tests for the new schema will be written.
|
77
|
-
def target_type_spec_path
|
78
|
-
@target_type_spec_path ||= File.join(module_dir, 'spec', 'unit', 'puppet', 'transport', 'schema', object_name) + '_spec.rb'
|
10
|
+
def template_files
|
11
|
+
# Note : Due to how the V1 templates work, the names of the source template files may be mismatched to
|
12
|
+
# their destination, e.g. transport_type.erb is really a transport schema
|
13
|
+
files = {
|
14
|
+
'transport_spec.erb' => File.join('spec', 'unit', 'puppet', 'transport', object_name) + '_spec.rb',
|
15
|
+
'transport_type_spec.erb' => File.join('spec', 'unit', 'puppet', 'transport', 'schema', object_name) + '_spec.rb',
|
16
|
+
}
|
17
|
+
return files if spec_only?
|
18
|
+
files.merge(
|
19
|
+
'transport.erb' => File.join('lib', 'puppet', 'transport', object_name) + '.rb',
|
20
|
+
'transport_device.erb' => File.join('lib', 'puppet', 'util', 'network_device', object_name, 'device.rb'),
|
21
|
+
'transport_type.erb' => File.join('lib', 'puppet', 'transport', 'schema', object_name) + '.rb',
|
22
|
+
)
|
79
23
|
end
|
80
24
|
|
81
|
-
|
82
|
-
|
83
|
-
|
25
|
+
def template_data
|
26
|
+
{
|
27
|
+
name: object_name,
|
28
|
+
transport_class: class_name_from_object_name(object_name),
|
29
|
+
}
|
84
30
|
end
|
85
31
|
end
|
86
32
|
end
|
data/lib/pdk/module.rb
CHANGED
@@ -4,7 +4,6 @@ module PDK
|
|
4
4
|
autoload :Convert, 'pdk/module/convert'
|
5
5
|
autoload :Metadata, 'pdk/module/metadata'
|
6
6
|
autoload :Release, 'pdk/module/release'
|
7
|
-
autoload :TemplateDir, 'pdk/module/template_dir'
|
8
7
|
autoload :UpdateManager, 'pdk/module/update_manager'
|
9
8
|
autoload :Update, 'pdk/module/update'
|
10
9
|
|
@@ -16,6 +15,7 @@ module PDK
|
|
16
15
|
'/REVISION',
|
17
16
|
'/spec/fixtures/modules/',
|
18
17
|
'/vendor/',
|
18
|
+
'.DS_Store',
|
19
19
|
].freeze
|
20
20
|
|
21
21
|
def default_ignored_pathspec(ignore_dotfiles = true)
|
data/lib/pdk/module/build.rb
CHANGED
@@ -115,6 +115,8 @@ module PDK
|
|
115
115
|
relative_path = Pathname.new(path).relative_path_from(Pathname.new(module_dir))
|
116
116
|
dest_path = File.join(build_dir, relative_path)
|
117
117
|
|
118
|
+
validate_path_encoding!(relative_path.to_path)
|
119
|
+
|
118
120
|
if PDK::Util::Filesystem.directory?(path)
|
119
121
|
PDK::Util::Filesystem.mkdir_p(dest_path, mode: PDK::Util::Filesystem.stat(path).mode)
|
120
122
|
elsif PDK::Util::Filesystem.symlink?(path)
|
@@ -212,6 +214,27 @@ module PDK
|
|
212
214
|
) % { path: path }
|
213
215
|
end
|
214
216
|
|
217
|
+
# Checks if the path contains any non-ASCII characters.
|
218
|
+
#
|
219
|
+
# Java will throw an error when it encounters a path containing
|
220
|
+
# characters that are not supported by the hosts locale. In order to
|
221
|
+
# maximise compatibility we limit the paths to contain only ASCII
|
222
|
+
# characters, which should be part of any locale character set.
|
223
|
+
#
|
224
|
+
# @param path [String] the relative path to be added to the tar file.
|
225
|
+
#
|
226
|
+
# @raise [ArgumentError] if the path contains non-ASCII characters.
|
227
|
+
#
|
228
|
+
# @return [nil]
|
229
|
+
def validate_path_encoding!(path)
|
230
|
+
return unless path =~ %r{[^\x00-\x7F]}
|
231
|
+
|
232
|
+
raise ArgumentError, _(
|
233
|
+
"'%{path}' can only include ASCII characters in its path or " \
|
234
|
+
'filename in order to be compatible with a wide range of hosts.',
|
235
|
+
) % { path: path }
|
236
|
+
end
|
237
|
+
|
215
238
|
# Creates a gzip compressed tarball of the build directory.
|
216
239
|
#
|
217
240
|
# If the destination package already exists, it will be removed before
|
data/lib/pdk/module/convert.rb
CHANGED
@@ -3,13 +3,16 @@ require 'pdk'
|
|
3
3
|
module PDK
|
4
4
|
module Module
|
5
5
|
class Convert
|
6
|
-
def self.invoke(options)
|
7
|
-
new(options).run
|
6
|
+
def self.invoke(module_dir, options)
|
7
|
+
new(module_dir, options).run
|
8
8
|
end
|
9
9
|
|
10
|
+
attr_reader :module_dir
|
11
|
+
|
10
12
|
attr_reader :options
|
11
13
|
|
12
|
-
def initialize(options = {})
|
14
|
+
def initialize(module_dir, options = {})
|
15
|
+
@module_dir = module_dir
|
13
16
|
@options = options
|
14
17
|
end
|
15
18
|
|
@@ -23,6 +26,7 @@ module PDK
|
|
23
26
|
unless update_manager.changes?
|
24
27
|
if adding_tests?
|
25
28
|
add_tests!
|
29
|
+
print_result 'Convert completed'
|
26
30
|
else
|
27
31
|
require 'pdk/report'
|
28
32
|
|
@@ -50,18 +54,15 @@ module PDK
|
|
50
54
|
return unless continue
|
51
55
|
end
|
52
56
|
|
53
|
-
# Remove these files straight away as these changes are not something
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
57
|
+
# Remove these files straight away as these changes are not something
|
58
|
+
# that the user needs to review.
|
59
|
+
update_manager.unlink_file('Gemfile.lock')
|
60
|
+
update_manager.unlink_file(File.join('.bundle', 'config'))
|
58
61
|
|
59
62
|
update_manager.sync_changes!
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
PDK::Util::Bundler.ensure_bundle!
|
64
|
-
end
|
64
|
+
require 'pdk/util/bundler'
|
65
|
+
PDK::Util::Bundler.ensure_bundle!
|
65
66
|
|
66
67
|
add_tests! if adding_tests?
|
67
68
|
|
@@ -85,41 +86,59 @@ module PDK
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def missing_tests?
|
88
|
-
|
89
|
+
!available_test_generators.empty?
|
90
|
+
end
|
91
|
+
|
92
|
+
def available_test_generators
|
93
|
+
# Only select generators which can run and have no pre-existing files
|
94
|
+
test_generators.select do |gen|
|
95
|
+
if gen.can_run?
|
96
|
+
gen.template_files.none? { |_, dst_path| PDK::Util::Filesystem.exist?(File.join(gen.context.root_path, dst_path)) }
|
97
|
+
else
|
98
|
+
false
|
99
|
+
end
|
100
|
+
end
|
89
101
|
end
|
90
102
|
|
91
|
-
def test_generators
|
103
|
+
def test_generators(context = PDK.context)
|
92
104
|
return @test_generators unless @test_generators.nil?
|
93
105
|
require 'pdk/util/puppet_strings'
|
94
106
|
|
95
107
|
test_gens = PDK::Util::PuppetStrings.all_objects.map do |generator, objects|
|
96
108
|
(objects || []).map do |obj|
|
97
|
-
generator.new(
|
109
|
+
generator.new(context, obj['name'], spec_only: true)
|
98
110
|
end
|
99
111
|
end
|
100
112
|
|
101
113
|
@test_generators = test_gens.flatten
|
102
114
|
end
|
103
115
|
|
104
|
-
def
|
105
|
-
|
106
|
-
gen.
|
116
|
+
def stage_tests!(manager)
|
117
|
+
available_test_generators.each do |gen|
|
118
|
+
gen.stage_changes(manager)
|
107
119
|
end
|
120
|
+
manager
|
108
121
|
end
|
109
122
|
|
110
|
-
def
|
111
|
-
update_manager.
|
123
|
+
def add_tests!
|
124
|
+
update_manager.clear!
|
125
|
+
stage_tests!(update_manager)
|
126
|
+
|
127
|
+
if update_manager.changes?
|
128
|
+
update_manager.sync_changes!
|
129
|
+
print_summary
|
130
|
+
else
|
131
|
+
PDK::Report.default_target.puts(_('No test changes required.'))
|
132
|
+
end
|
112
133
|
end
|
113
134
|
|
114
|
-
def stage_changes!
|
135
|
+
def stage_changes!(context = PDK.context)
|
115
136
|
require 'pdk/util/filesystem'
|
116
137
|
|
117
|
-
metadata_path = 'metadata.json'
|
118
|
-
|
119
|
-
PDK::Module::TemplateDir.with(template_uri, nil, true) do |templates|
|
120
|
-
new_metadata = update_metadata(metadata_path, templates.metadata)
|
121
|
-
templates.module_metadata = new_metadata.data unless new_metadata.nil?
|
138
|
+
metadata_path = File.join(module_dir, 'metadata.json')
|
122
139
|
|
140
|
+
PDK::Template.with(template_uri, context) do |template_dir|
|
141
|
+
new_metadata = update_metadata(metadata_path, template_dir.metadata)
|
123
142
|
if options[:noop] && new_metadata.nil?
|
124
143
|
update_manager.add_file(metadata_path, '')
|
125
144
|
elsif PDK::Util::Filesystem.file?(metadata_path)
|
@@ -128,21 +147,26 @@ module PDK
|
|
128
147
|
update_manager.add_file(metadata_path, new_metadata.to_json)
|
129
148
|
end
|
130
149
|
|
131
|
-
|
150
|
+
# new_metadata == nil when creating a new module but with --noop@
|
151
|
+
module_name = new_metadata.nil? ? 'new-module' : new_metadata.data['name']
|
152
|
+
metadata_for_render = new_metadata.nil? ? {} : new_metadata.data
|
153
|
+
|
154
|
+
template_dir.render_new_module(module_name, metadata_for_render) do |relative_file_path, file_content, file_status|
|
155
|
+
absolute_file_path = File.join(module_dir, relative_file_path)
|
132
156
|
case file_status
|
133
157
|
when :unmanage
|
134
|
-
PDK.logger.debug(_("skipping '%{path}'") % { path:
|
158
|
+
PDK.logger.debug(_("skipping '%{path}'") % { path: absolute_file_path })
|
135
159
|
when :delete
|
136
|
-
update_manager.remove_file(
|
160
|
+
update_manager.remove_file(absolute_file_path)
|
137
161
|
when :init
|
138
|
-
if convert? && !PDK::Util::Filesystem.exist?(
|
139
|
-
update_manager.add_file(
|
162
|
+
if convert? && !PDK::Util::Filesystem.exist?(absolute_file_path)
|
163
|
+
update_manager.add_file(absolute_file_path, file_content)
|
140
164
|
end
|
141
165
|
when :manage
|
142
|
-
if PDK::Util::Filesystem.exist?(
|
143
|
-
update_manager.modify_file(
|
166
|
+
if PDK::Util::Filesystem.exist?(absolute_file_path)
|
167
|
+
update_manager.modify_file(absolute_file_path, file_content)
|
144
168
|
else
|
145
|
-
update_manager.add_file(
|
169
|
+
update_manager.add_file(absolute_file_path, file_content)
|
146
170
|
end
|
147
171
|
end
|
148
172
|
end
|
data/lib/pdk/module/metadata.rb
CHANGED
@@ -27,7 +27,7 @@ module PDK
|
|
27
27
|
'Debian based Linux' => [
|
28
28
|
{
|
29
29
|
'operatingsystem' => 'Debian',
|
30
|
-
'operatingsystemrelease' => ['
|
30
|
+
'operatingsystemrelease' => ['10'],
|
31
31
|
},
|
32
32
|
{
|
33
33
|
'operatingsystem' => 'Ubuntu',
|
@@ -54,6 +54,10 @@ module PDK
|
|
54
54
|
'operatingsystem' => 'windows',
|
55
55
|
'operatingsystemrelease' => %w[2019 10],
|
56
56
|
},
|
57
|
+
'AIX' => {
|
58
|
+
'operatingsystem' => 'AIX',
|
59
|
+
'operatingsystemrelease' => %w[6.1 7.1 7.2],
|
60
|
+
},
|
57
61
|
}.freeze
|
58
62
|
|
59
63
|
DEFAULT_OPERATING_SYSTEMS = [
|
@@ -77,7 +81,7 @@ module PDK
|
|
77
81
|
OPERATING_SYSTEMS[os_name]
|
78
82
|
}.flatten,
|
79
83
|
'requirements' => [
|
80
|
-
{ 'name' => 'puppet', 'version_requirement' => '>=
|
84
|
+
{ 'name' => 'puppet', 'version_requirement' => '>= 6.21.0 < 8.0.0' },
|
81
85
|
],
|
82
86
|
}.freeze
|
83
87
|
|
data/lib/pdk/module/release.rb
CHANGED
@@ -105,20 +105,14 @@ module PDK
|
|
105
105
|
|
106
106
|
PDK::CLI::Util.module_version_check
|
107
107
|
|
108
|
-
report = PDK::Report.new
|
109
108
|
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
|
110
109
|
PDK::Util::PuppetVersion.fetch_puppet_dev if opts[:'puppet-dev']
|
111
110
|
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
|
112
111
|
|
113
|
-
opts = opts.merge(puppet_env[:gemset])
|
114
|
-
|
115
112
|
PDK::Util::Bundler.ensure_bundle!(puppet_env[:gemset])
|
116
113
|
|
117
|
-
|
118
|
-
|
119
|
-
validator_exit_code = validator.invoke(report, opts.dup)
|
120
|
-
raise PDK::CLI::ExitWithError, _('An error occured during validation') unless validator_exit_code.zero?
|
121
|
-
end
|
114
|
+
validator_exit_code, = PDK::Validate.invoke_validators_by_name(PDK.context, PDK::Validate.validator_names, false, options)
|
115
|
+
raise PDK::CLI::ExitWithError, _('An error occured during validation') unless validator_exit_code.zero?
|
122
116
|
end
|
123
117
|
|
124
118
|
def run_documentation(_opts)
|
@@ -169,7 +163,7 @@ module PDK
|
|
169
163
|
http.request(request)
|
170
164
|
end
|
171
165
|
|
172
|
-
raise PDK::CLI::ExitWithError, _('Error uploading to Puppet Forge: %{result}') % { result: response } unless response.is_a?(Net::HTTPSuccess)
|
166
|
+
raise PDK::CLI::ExitWithError, _('Error uploading to Puppet Forge: %{result}') % { result: response.body } unless response.is_a?(Net::HTTPSuccess)
|
173
167
|
PDK.logger.info _('Publish to Forge was successful')
|
174
168
|
end
|
175
169
|
|
data/lib/pdk/module/update.rb
CHANGED
@@ -33,25 +33,21 @@ module PDK
|
|
33
33
|
return unless PDK::CLI::Util.prompt_for_yes(message)
|
34
34
|
end
|
35
35
|
|
36
|
-
# Remove these files straight away as these changes are not something
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
36
|
+
# Remove these files straight away as these changes are not something
|
37
|
+
# that the user needs to review.
|
38
|
+
update_manager.unlink_file('Gemfile.lock')
|
39
|
+
update_manager.unlink_file(File.join('.bundle', 'config'))
|
41
40
|
|
42
41
|
update_manager.sync_changes!
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
PDK::Util::Bundler.ensure_bundle!
|
48
|
-
end
|
43
|
+
require 'pdk/util/bundler'
|
44
|
+
PDK::Util::Bundler.ensure_bundle!
|
49
45
|
|
50
46
|
print_result 'Update completed'
|
51
47
|
end
|
52
48
|
|
53
49
|
def module_metadata
|
54
|
-
@module_metadata ||= PDK::Module::Metadata.from_file('metadata.json')
|
50
|
+
@module_metadata ||= PDK::Module::Metadata.from_file(File.join(module_dir, 'metadata.json'))
|
55
51
|
rescue ArgumentError => e
|
56
52
|
raise PDK::CLI::ExitWithError, e.message
|
57
53
|
end
|
@@ -89,7 +85,7 @@ module PDK
|
|
89
85
|
private
|
90
86
|
|
91
87
|
def latest_template?
|
92
|
-
[PDK::TEMPLATE_REF, 'master'].include?(template_uri.uri_fragment)
|
88
|
+
[PDK::TEMPLATE_REF, 'master', 'main'].include?(template_uri.uri_fragment)
|
93
89
|
end
|
94
90
|
|
95
91
|
def current_template_version
|
@@ -75,6 +75,13 @@ module PDK
|
|
75
75
|
changes[:modified].key?(path)
|
76
76
|
end
|
77
77
|
|
78
|
+
def clear!
|
79
|
+
@modified_files.clear
|
80
|
+
@added_files.clear
|
81
|
+
@removed_files.clear
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
|
78
85
|
# Apply any pending changes stored in the UpdateManager to the module.
|
79
86
|
#
|
80
87
|
# @raise (see #calculate_diffs)
|
data/lib/pdk/report.rb
CHANGED
@@ -104,7 +104,7 @@ module PDK
|
|
104
104
|
if event.rspec_puppet_coverage?
|
105
105
|
coverage_report = event.to_text
|
106
106
|
else
|
107
|
-
report << event.to_text unless event.pass?
|
107
|
+
report << event.to_text unless event.pass? || event.skipped?
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -113,8 +113,8 @@ module PDK
|
|
113
113
|
|
114
114
|
if target.is_a?(String)
|
115
115
|
PDK::Util::Filesystem.write_file(target, report.join("\n"))
|
116
|
-
|
117
|
-
target << report.join("\n")
|
116
|
+
elsif !report.empty?
|
117
|
+
target << report.join("\n") << "\n"
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|