pdk 2.3.0 → 2.4.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 +1329 -1321
- data/LICENSE +201 -201
- data/README.md +163 -163
- data/exe/pdk +10 -10
- data/lib/pdk/analytics/client/google_analytics.rb +143 -143
- data/lib/pdk/analytics/client/noop.rb +25 -25
- data/lib/pdk/analytics/util.rb +19 -19
- data/lib/pdk/analytics.rb +30 -30
- data/lib/pdk/answer_file.rb +12 -12
- data/lib/pdk/bolt.rb +19 -19
- data/lib/pdk/cli/build.rb +82 -82
- data/lib/pdk/cli/bundle.rb +48 -48
- data/lib/pdk/cli/config/get.rb +26 -26
- data/lib/pdk/cli/config.rb +22 -22
- data/lib/pdk/cli/console.rb +148 -148
- data/lib/pdk/cli/convert.rb +52 -52
- data/lib/pdk/cli/env.rb +52 -52
- data/lib/pdk/cli/errors.rb +25 -25
- data/lib/pdk/cli/exec/command.rb +293 -293
- data/lib/pdk/cli/exec/interactive_command.rb +114 -114
- data/lib/pdk/cli/exec.rb +84 -84
- data/lib/pdk/cli/exec_group.rb +104 -104
- data/lib/pdk/cli/get/config.rb +24 -24
- data/lib/pdk/cli/get.rb +20 -20
- data/lib/pdk/cli/module/build.rb +12 -12
- data/lib/pdk/cli/module/generate.rb +47 -47
- data/lib/pdk/cli/module.rb +14 -14
- data/lib/pdk/cli/new/class.rb +32 -32
- data/lib/pdk/cli/new/defined_type.rb +32 -32
- data/lib/pdk/cli/new/fact.rb +29 -29
- data/lib/pdk/cli/new/function.rb +29 -29
- data/lib/pdk/cli/new/module.rb +53 -53
- data/lib/pdk/cli/new/provider.rb +29 -29
- data/lib/pdk/cli/new/task.rb +34 -34
- data/lib/pdk/cli/new/test.rb +52 -52
- data/lib/pdk/cli/new/transport.rb +27 -27
- data/lib/pdk/cli/new.rb +21 -21
- data/lib/pdk/cli/release/prep.rb +39 -39
- data/lib/pdk/cli/release/publish.rb +50 -50
- data/lib/pdk/cli/release.rb +194 -194
- data/lib/pdk/cli/remove/config.rb +80 -80
- data/lib/pdk/cli/remove.rb +20 -20
- data/lib/pdk/cli/set/config.rb +119 -119
- data/lib/pdk/cli/set.rb +20 -20
- data/lib/pdk/cli/test/unit.rb +90 -90
- data/lib/pdk/cli/test.rb +11 -11
- data/lib/pdk/cli/update.rb +64 -64
- data/lib/pdk/cli/util/command_redirector.rb +27 -27
- data/lib/pdk/cli/util/interview.rb +72 -72
- data/lib/pdk/cli/util/option_normalizer.rb +55 -55
- data/lib/pdk/cli/util/option_validator.rb +68 -68
- data/lib/pdk/cli/util/spinner.rb +13 -13
- data/lib/pdk/cli/util/update_manager_printer.rb +82 -82
- data/lib/pdk/cli/util.rb +305 -305
- data/lib/pdk/cli/validate.rb +116 -116
- data/lib/pdk/cli.rb +175 -175
- data/lib/pdk/config/analytics_schema.json +26 -26
- data/lib/pdk/config/errors.rb +5 -5
- data/lib/pdk/config/ini_file.rb +183 -183
- data/lib/pdk/config/ini_file_setting.rb +39 -39
- data/lib/pdk/config/json.rb +34 -34
- data/lib/pdk/config/json_schema_namespace.rb +142 -142
- data/lib/pdk/config/json_schema_setting.rb +53 -53
- data/lib/pdk/config/json_with_schema.rb +49 -49
- data/lib/pdk/config/namespace.rb +354 -354
- data/lib/pdk/config/setting.rb +135 -135
- data/lib/pdk/config/validator.rb +31 -31
- data/lib/pdk/config/yaml.rb +46 -46
- data/lib/pdk/config/yaml_with_schema.rb +59 -59
- data/lib/pdk/config.rb +390 -390
- data/lib/pdk/context/control_repo.rb +60 -60
- data/lib/pdk/context/module.rb +28 -28
- data/lib/pdk/context/none.rb +22 -22
- data/lib/pdk/context.rb +99 -99
- data/lib/pdk/control_repo.rb +90 -90
- data/lib/pdk/generate/defined_type.rb +43 -43
- data/lib/pdk/generate/fact.rb +25 -25
- data/lib/pdk/generate/function.rb +48 -48
- data/lib/pdk/generate/module.rb +352 -352
- data/lib/pdk/generate/provider.rb +28 -28
- data/lib/pdk/generate/puppet_class.rb +43 -43
- data/lib/pdk/generate/puppet_object.rb +232 -232
- data/lib/pdk/generate/task.rb +68 -68
- data/lib/pdk/generate/transport.rb +33 -33
- data/lib/pdk/generate.rb +24 -24
- data/lib/pdk/i18n.rb +4 -4
- data/lib/pdk/logger.rb +45 -45
- data/lib/pdk/module/build.rb +322 -322
- data/lib/pdk/module/convert.rb +296 -296
- data/lib/pdk/module/metadata.rb +202 -202
- data/lib/pdk/module/release.rb +260 -260
- data/lib/pdk/module/update.rb +131 -131
- data/lib/pdk/module/update_manager.rb +227 -227
- data/lib/pdk/module.rb +30 -30
- data/lib/pdk/report/event.rb +370 -370
- data/lib/pdk/report.rb +121 -121
- data/lib/pdk/template/fetcher/git.rb +85 -85
- data/lib/pdk/template/fetcher/local.rb +28 -28
- data/lib/pdk/template/fetcher.rb +98 -98
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +116 -116
- data/lib/pdk/template/renderer/v1/renderer.rb +132 -132
- data/lib/pdk/template/renderer/v1/template_file.rb +102 -102
- data/lib/pdk/template/renderer/v1.rb +25 -25
- data/lib/pdk/template/renderer.rb +96 -96
- data/lib/pdk/template/template_dir.rb +67 -67
- data/lib/pdk/template.rb +59 -59
- data/lib/pdk/tests/unit.rb +252 -252
- data/lib/pdk/util/bundler.rb +259 -259
- data/lib/pdk/util/changelog_generator.rb +137 -137
- data/lib/pdk/util/env.rb +47 -47
- data/lib/pdk/util/filesystem.rb +138 -138
- data/lib/pdk/util/git.rb +179 -179
- data/lib/pdk/util/json_finder.rb +85 -85
- data/lib/pdk/util/puppet_strings.rb +125 -125
- data/lib/pdk/util/puppet_version.rb +266 -266
- data/lib/pdk/util/ruby_version.rb +179 -179
- data/lib/pdk/util/template_uri.rb +295 -295
- data/lib/pdk/util/vendored_file.rb +93 -93
- data/lib/pdk/util/version.rb +43 -43
- data/lib/pdk/util/windows/api_types.rb +82 -82
- data/lib/pdk/util/windows/file.rb +36 -36
- data/lib/pdk/util/windows/process.rb +79 -79
- data/lib/pdk/util/windows/string.rb +16 -16
- data/lib/pdk/util/windows.rb +15 -15
- data/lib/pdk/util.rb +278 -277
- data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -23
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -98
- data/lib/pdk/validate/external_command_validator.rb +208 -208
- data/lib/pdk/validate/internal_ruby_validator.rb +100 -100
- data/lib/pdk/validate/invokable_validator.rb +228 -228
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +86 -86
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +78 -78
- data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -20
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +133 -133
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -66
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +137 -137
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +21 -21
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +80 -80
- data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -19
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +88 -88
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +50 -50
- data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -20
- data/lib/pdk/validate/validator.rb +118 -118
- data/lib/pdk/validate/validator_group.rb +104 -104
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +95 -95
- data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -19
- data/lib/pdk/validate.rb +94 -94
- data/lib/pdk/version.rb +4 -4
- data/lib/pdk.rb +76 -76
- data/locales/config.yaml +21 -21
- data/locales/pdk.pot +2094 -2094
- metadata +5 -6
data/lib/pdk/module/update.rb
CHANGED
@@ -1,131 +1,131 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
|
3
|
-
module PDK
|
4
|
-
module Module
|
5
|
-
class Update < Convert
|
6
|
-
GIT_DESCRIBE_PATTERN = %r{\A(?<base>.+?)-(?<additional_commits>\d+)-g(?<sha>.+)\Z}
|
7
|
-
|
8
|
-
def run
|
9
|
-
template_uri.uri_fragment = new_template_version
|
10
|
-
|
11
|
-
stage_changes!
|
12
|
-
|
13
|
-
if current_version == new_version
|
14
|
-
PDK.logger.debug _('This module is already up to date with version %{version} of the template.') % {
|
15
|
-
version: new_version,
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
unless update_manager.changes?
|
20
|
-
PDK::Report.default_target.puts(_('No changes required.'))
|
21
|
-
return
|
22
|
-
end
|
23
|
-
|
24
|
-
PDK.logger.info(update_message)
|
25
|
-
|
26
|
-
print_summary
|
27
|
-
full_report('update_report.txt') unless update_manager.changes[:modified].empty?
|
28
|
-
|
29
|
-
return if noop?
|
30
|
-
|
31
|
-
unless force?
|
32
|
-
message = _('Do you want to continue and make these changes to your module?')
|
33
|
-
return unless PDK::CLI::Util.prompt_for_yes(message)
|
34
|
-
end
|
35
|
-
|
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'))
|
40
|
-
|
41
|
-
update_manager.sync_changes!
|
42
|
-
|
43
|
-
require 'pdk/util/bundler'
|
44
|
-
PDK::Util::Bundler.ensure_bundle!
|
45
|
-
|
46
|
-
print_result 'Update completed'
|
47
|
-
end
|
48
|
-
|
49
|
-
def module_metadata
|
50
|
-
@module_metadata ||= PDK::Module::Metadata.from_file(File.join(module_dir, 'metadata.json'))
|
51
|
-
rescue ArgumentError => e
|
52
|
-
raise PDK::CLI::ExitWithError, e.message
|
53
|
-
end
|
54
|
-
|
55
|
-
def template_uri
|
56
|
-
@template_uri ||= PDK::Util::TemplateURI.new(module_metadata.data['template-url'])
|
57
|
-
end
|
58
|
-
|
59
|
-
def current_version
|
60
|
-
@current_version ||= describe_ref_to_s(current_template_version)
|
61
|
-
end
|
62
|
-
|
63
|
-
def new_version
|
64
|
-
@new_version ||= fetch_remote_version(new_template_version)
|
65
|
-
end
|
66
|
-
|
67
|
-
def new_template_version
|
68
|
-
return options[:'template-ref'] if options[:'template-ref']
|
69
|
-
|
70
|
-
if template_uri.default? && PDK::Util::Git.tag?(template_uri.bare_uri, template_uri.uri_fragment) && PDK::Util.package_install?
|
71
|
-
PDK::Util::TemplateURI.default_template_ref
|
72
|
-
else
|
73
|
-
template_uri.uri_fragment
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def pinned_to_puppetlabs_template_tag?
|
78
|
-
return false unless template_uri.puppetlabs_template?
|
79
|
-
return false unless PDK::Util::Git.tag?(template_uri.bare_uri, template_uri.uri_fragment)
|
80
|
-
return false if latest_template?
|
81
|
-
|
82
|
-
template_uri.uri_fragment == new_template_version
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
def latest_template?
|
88
|
-
[PDK::TEMPLATE_REF, 'master', 'main'].include?(template_uri.uri_fragment)
|
89
|
-
end
|
90
|
-
|
91
|
-
def current_template_version
|
92
|
-
@current_template_version ||= module_metadata.data['template-ref']
|
93
|
-
end
|
94
|
-
|
95
|
-
def describe_ref_to_s(describe_ref)
|
96
|
-
data = GIT_DESCRIBE_PATTERN.match(describe_ref)
|
97
|
-
|
98
|
-
return data if data.nil?
|
99
|
-
|
100
|
-
if data[:base] =~ %r{^(?:heads|remotes)/}
|
101
|
-
"#{data[:base].gsub(%r{^(heads/|remotes/\w+?/)}, '')}@#{data[:sha]}"
|
102
|
-
else
|
103
|
-
data[:base]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def fetch_remote_version(template_ref)
|
108
|
-
return template_ref unless current_template_version.is_a?(String)
|
109
|
-
return template_ref if template_ref == PDK::TEMPLATE_REF
|
110
|
-
|
111
|
-
sha_length = GIT_DESCRIBE_PATTERN.match(current_template_version)[:sha].length - 1
|
112
|
-
"#{template_ref}@#{PDK::Util::Git.ls_remote(template_uri.bare_uri, template_ref)[0..sha_length]}"
|
113
|
-
end
|
114
|
-
|
115
|
-
def update_message
|
116
|
-
format_string = if template_uri.default?
|
117
|
-
_('Updating %{module_name} using the default template, from %{current_version} to %{new_version}')
|
118
|
-
else
|
119
|
-
_('Updating %{module_name} using the template at %{template_url}, from %{current_version} to %{new_version}')
|
120
|
-
end
|
121
|
-
|
122
|
-
format_string % {
|
123
|
-
module_name: module_metadata.data['name'],
|
124
|
-
template_url: template_uri.bare_uri,
|
125
|
-
current_version: current_version,
|
126
|
-
new_version: new_version,
|
127
|
-
}
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
1
|
+
require 'pdk'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Module
|
5
|
+
class Update < Convert
|
6
|
+
GIT_DESCRIBE_PATTERN = %r{\A(?<base>.+?)-(?<additional_commits>\d+)-g(?<sha>.+)\Z}
|
7
|
+
|
8
|
+
def run
|
9
|
+
template_uri.uri_fragment = new_template_version
|
10
|
+
|
11
|
+
stage_changes!
|
12
|
+
|
13
|
+
if current_version == new_version
|
14
|
+
PDK.logger.debug _('This module is already up to date with version %{version} of the template.') % {
|
15
|
+
version: new_version,
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
unless update_manager.changes?
|
20
|
+
PDK::Report.default_target.puts(_('No changes required.'))
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
PDK.logger.info(update_message)
|
25
|
+
|
26
|
+
print_summary
|
27
|
+
full_report('update_report.txt') unless update_manager.changes[:modified].empty?
|
28
|
+
|
29
|
+
return if noop?
|
30
|
+
|
31
|
+
unless force?
|
32
|
+
message = _('Do you want to continue and make these changes to your module?')
|
33
|
+
return unless PDK::CLI::Util.prompt_for_yes(message)
|
34
|
+
end
|
35
|
+
|
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'))
|
40
|
+
|
41
|
+
update_manager.sync_changes!
|
42
|
+
|
43
|
+
require 'pdk/util/bundler'
|
44
|
+
PDK::Util::Bundler.ensure_bundle!
|
45
|
+
|
46
|
+
print_result 'Update completed'
|
47
|
+
end
|
48
|
+
|
49
|
+
def module_metadata
|
50
|
+
@module_metadata ||= PDK::Module::Metadata.from_file(File.join(module_dir, 'metadata.json'))
|
51
|
+
rescue ArgumentError => e
|
52
|
+
raise PDK::CLI::ExitWithError, e.message
|
53
|
+
end
|
54
|
+
|
55
|
+
def template_uri
|
56
|
+
@template_uri ||= PDK::Util::TemplateURI.new(module_metadata.data['template-url'])
|
57
|
+
end
|
58
|
+
|
59
|
+
def current_version
|
60
|
+
@current_version ||= describe_ref_to_s(current_template_version)
|
61
|
+
end
|
62
|
+
|
63
|
+
def new_version
|
64
|
+
@new_version ||= fetch_remote_version(new_template_version)
|
65
|
+
end
|
66
|
+
|
67
|
+
def new_template_version
|
68
|
+
return options[:'template-ref'] if options[:'template-ref']
|
69
|
+
|
70
|
+
if template_uri.default? && PDK::Util::Git.tag?(template_uri.bare_uri, template_uri.uri_fragment) && PDK::Util.package_install?
|
71
|
+
PDK::Util::TemplateURI.default_template_ref
|
72
|
+
else
|
73
|
+
template_uri.uri_fragment
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def pinned_to_puppetlabs_template_tag?
|
78
|
+
return false unless template_uri.puppetlabs_template?
|
79
|
+
return false unless PDK::Util::Git.tag?(template_uri.bare_uri, template_uri.uri_fragment)
|
80
|
+
return false if latest_template?
|
81
|
+
|
82
|
+
template_uri.uri_fragment == new_template_version
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def latest_template?
|
88
|
+
[PDK::TEMPLATE_REF, 'master', 'main'].include?(template_uri.uri_fragment)
|
89
|
+
end
|
90
|
+
|
91
|
+
def current_template_version
|
92
|
+
@current_template_version ||= module_metadata.data['template-ref']
|
93
|
+
end
|
94
|
+
|
95
|
+
def describe_ref_to_s(describe_ref)
|
96
|
+
data = GIT_DESCRIBE_PATTERN.match(describe_ref)
|
97
|
+
|
98
|
+
return data if data.nil?
|
99
|
+
|
100
|
+
if data[:base] =~ %r{^(?:heads|remotes)/}
|
101
|
+
"#{data[:base].gsub(%r{^(heads/|remotes/\w+?/)}, '')}@#{data[:sha]}"
|
102
|
+
else
|
103
|
+
data[:base]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def fetch_remote_version(template_ref)
|
108
|
+
return template_ref unless current_template_version.is_a?(String)
|
109
|
+
return template_ref if template_ref == PDK::TEMPLATE_REF
|
110
|
+
|
111
|
+
sha_length = GIT_DESCRIBE_PATTERN.match(current_template_version)[:sha].length - 1
|
112
|
+
"#{template_ref}@#{PDK::Util::Git.ls_remote(template_uri.bare_uri, template_ref)[0..sha_length]}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def update_message
|
116
|
+
format_string = if template_uri.default?
|
117
|
+
_('Updating %{module_name} using the default template, from %{current_version} to %{new_version}')
|
118
|
+
else
|
119
|
+
_('Updating %{module_name} using the template at %{template_url}, from %{current_version} to %{new_version}')
|
120
|
+
end
|
121
|
+
|
122
|
+
format_string % {
|
123
|
+
module_name: module_metadata.data['name'],
|
124
|
+
template_url: template_uri.bare_uri,
|
125
|
+
current_version: current_version,
|
126
|
+
new_version: new_version,
|
127
|
+
}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|