pdk 3.0.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -1
- data/lib/pdk/cli/build.rb +6 -5
- data/lib/pdk/cli/bundle.rb +0 -2
- data/lib/pdk/cli/console.rb +0 -2
- data/lib/pdk/cli/convert.rb +3 -3
- data/lib/pdk/cli/env.rb +0 -2
- data/lib/pdk/cli/exec/command.rb +0 -2
- data/lib/pdk/cli/new/class.rb +0 -2
- data/lib/pdk/cli/new/defined_type.rb +0 -2
- data/lib/pdk/cli/new/fact.rb +0 -2
- data/lib/pdk/cli/new/function.rb +0 -2
- data/lib/pdk/cli/new/module.rb +0 -2
- data/lib/pdk/cli/new/provider.rb +0 -2
- data/lib/pdk/cli/new/task.rb +0 -2
- data/lib/pdk/cli/new/test.rb +0 -2
- data/lib/pdk/cli/release/prep.rb +0 -2
- data/lib/pdk/cli/release/publish.rb +0 -2
- data/lib/pdk/cli/release.rb +0 -9
- data/lib/pdk/cli/test/unit.rb +0 -2
- data/lib/pdk/cli/update.rb +3 -3
- data/lib/pdk/cli/util.rb +0 -38
- data/lib/pdk/cli/validate.rb +0 -7
- data/lib/pdk/cli.rb +0 -2
- data/lib/pdk/config/namespace.rb +3 -3
- data/lib/pdk/config/setting.rb +3 -3
- data/lib/pdk/config.rb +0 -80
- data/lib/pdk/module/convert.rb +8 -3
- data/lib/pdk/module/metadata.rb +18 -10
- data/lib/pdk/module/release.rb +9 -6
- data/lib/pdk/module/update_manager.rb +29 -3
- data/lib/pdk/report/event.rb +1 -1
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +10 -13
- data/lib/pdk/template/renderer/v1/renderer.rb +3 -1
- data/lib/pdk/template.rb +0 -3
- data/lib/pdk/tests/unit.rb +3 -3
- data/lib/pdk/util/filesystem.rb +10 -0
- data/lib/pdk/util.rb +1 -0
- data/lib/pdk/version.rb +2 -2
- data/lib/pdk.rb +0 -14
- metadata +63 -98
- data/lib/pdk/analytics/client/google_analytics.rb +0 -141
- data/lib/pdk/analytics/client/noop.rb +0 -25
- data/lib/pdk/analytics/util.rb +0 -18
- data/lib/pdk/analytics.rb +0 -30
- data/lib/pdk/config/analytics_schema.json +0 -26
- data/lib/pdk/module/build.rb +0 -302
- data/lib/pdk/monkey_patches.rb +0 -268
data/lib/pdk/module/metadata.rb
CHANGED
@@ -9,7 +9,7 @@ module PDK
|
|
9
9
|
'RedHat based Linux' => [
|
10
10
|
{
|
11
11
|
'operatingsystem' => 'CentOS',
|
12
|
-
'operatingsystemrelease' => ['7']
|
12
|
+
'operatingsystemrelease' => ['7', '8', '9']
|
13
13
|
},
|
14
14
|
{
|
15
15
|
'operatingsystem' => 'OracleLinux',
|
@@ -17,30 +17,38 @@ module PDK
|
|
17
17
|
},
|
18
18
|
{
|
19
19
|
'operatingsystem' => 'RedHat',
|
20
|
-
'operatingsystemrelease' => ['8']
|
20
|
+
'operatingsystemrelease' => ['7', '8', '9']
|
21
21
|
},
|
22
22
|
{
|
23
23
|
'operatingsystem' => 'Scientific',
|
24
24
|
'operatingsystemrelease' => ['7']
|
25
|
+
},
|
26
|
+
{
|
27
|
+
'operatingsystem' => 'Rocky',
|
28
|
+
'operatingsystemrelease' => ['8']
|
29
|
+
},
|
30
|
+
{
|
31
|
+
'operatingsystem' => 'AlmaLinux',
|
32
|
+
'operatingsystemrelease' => ['8']
|
25
33
|
}
|
26
34
|
],
|
27
35
|
'Debian based Linux' => [
|
28
36
|
{
|
29
37
|
'operatingsystem' => 'Debian',
|
30
|
-
'operatingsystemrelease' => ['10']
|
38
|
+
'operatingsystemrelease' => ['10', '11', '12']
|
31
39
|
},
|
32
40
|
{
|
33
41
|
'operatingsystem' => 'Ubuntu',
|
34
|
-
'operatingsystemrelease' => ['18.04']
|
42
|
+
'operatingsystemrelease' => ['18.04', '20.04', '22.04']
|
35
43
|
}
|
36
44
|
],
|
37
45
|
'Fedora' => {
|
38
46
|
'operatingsystem' => 'Fedora',
|
39
|
-
'operatingsystemrelease' => ['
|
47
|
+
'operatingsystemrelease' => ['40']
|
40
48
|
},
|
41
49
|
'OSX' => {
|
42
50
|
'operatingsystem' => 'Darwin',
|
43
|
-
'operatingsystemrelease' => ['
|
51
|
+
'operatingsystemrelease' => ['21', '22', '23']
|
44
52
|
},
|
45
53
|
'SLES' => {
|
46
54
|
'operatingsystem' => 'SLES',
|
@@ -52,11 +60,11 @@ module PDK
|
|
52
60
|
},
|
53
61
|
'Windows' => {
|
54
62
|
'operatingsystem' => 'windows',
|
55
|
-
'operatingsystemrelease' => ['2019', '10']
|
63
|
+
'operatingsystemrelease' => ['2019', '2022', '10', '11']
|
56
64
|
},
|
57
65
|
'AIX' => {
|
58
66
|
'operatingsystem' => 'AIX',
|
59
|
-
'operatingsystemrelease' => ['
|
67
|
+
'operatingsystemrelease' => ['7.2', '7.3']
|
60
68
|
}
|
61
69
|
}.freeze
|
62
70
|
|
@@ -117,7 +125,7 @@ module PDK
|
|
117
125
|
def to_json(*_args)
|
118
126
|
require 'json'
|
119
127
|
|
120
|
-
JSON.pretty_generate(@data.dup.delete_if { |_key, value| value.nil? })
|
128
|
+
JSON.pretty_generate(@data.dup.delete_if { |_key, value| value.nil? })
|
121
129
|
end
|
122
130
|
|
123
131
|
def write!(path)
|
@@ -162,7 +170,7 @@ module PDK
|
|
162
170
|
|
163
171
|
# Do basic validation and parsing of the name parameter.
|
164
172
|
def process_name(data)
|
165
|
-
validate_name(data['name'])
|
173
|
+
validate_name(data['name']) unless PDK.context.is_a?(PDK::Context::ControlRepo)
|
166
174
|
author, modname = data['name'].split(%r{[-/]}, 2)
|
167
175
|
data['name'] = [author, modname].join('-')
|
168
176
|
|
data/lib/pdk/module/release.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pdk'
|
2
2
|
require 'uri'
|
3
|
+
require 'puppet/modulebuilder'
|
3
4
|
|
4
5
|
module PDK
|
5
6
|
module Module
|
@@ -77,7 +78,7 @@ module PDK
|
|
77
78
|
# Use the default as a last resort
|
78
79
|
package_file = default_package_filename if package_file.nil?
|
79
80
|
else
|
80
|
-
package_file = run_build
|
81
|
+
package_file = run_build
|
81
82
|
end
|
82
83
|
|
83
84
|
run_publish(options.dup, package_file) unless skip_publish?
|
@@ -95,7 +96,7 @@ module PDK
|
|
95
96
|
def default_package_filename
|
96
97
|
return @default_tarball_filename unless @default_tarball_filename.nil?
|
97
98
|
|
98
|
-
builder =
|
99
|
+
builder = Puppet::Modulebuilder::Builder.new(module_path, nil, PDK.logger)
|
99
100
|
@default_tarball_filename = builder.package_file
|
100
101
|
end
|
101
102
|
|
@@ -135,8 +136,11 @@ module PDK
|
|
135
136
|
end
|
136
137
|
|
137
138
|
# @return [String] Path to the built tarball
|
138
|
-
def run_build
|
139
|
-
PDK::
|
139
|
+
def run_build
|
140
|
+
module_dir = PDK::Util::Filesystem.expand_path(module_path || Dir.pwd)
|
141
|
+
target_dir = File.join(module_dir, 'pkg')
|
142
|
+
builder = Puppet::Modulebuilder::Builder.new(module_dir, target_dir, PDK.logger)
|
143
|
+
builder.build
|
140
144
|
end
|
141
145
|
|
142
146
|
def run_publish(_opts, tarball_path)
|
@@ -238,8 +242,7 @@ module PDK
|
|
238
242
|
def pdk_compatible?
|
239
243
|
return @pdk_compatible unless @pdk_compatible.nil?
|
240
244
|
|
241
|
-
|
242
|
-
@pdk_compatible = builder.module_pdk_compatible?
|
245
|
+
@pdk_compatible = PDK::Util.module_pdk_compatible?(module_path)
|
243
246
|
end
|
244
247
|
# :nocov:
|
245
248
|
|
@@ -11,6 +11,7 @@ module PDK
|
|
11
11
|
@modified_files = Set.new
|
12
12
|
@added_files = Set.new
|
13
13
|
@removed_files = Set.new
|
14
|
+
@executable_files = Set.new
|
14
15
|
@diff_cache = {}
|
15
16
|
end
|
16
17
|
|
@@ -37,6 +38,13 @@ module PDK
|
|
37
38
|
@removed_files << path
|
38
39
|
end
|
39
40
|
|
41
|
+
# Store a pending file execute mode change.
|
42
|
+
#
|
43
|
+
# @param path [String] The path to the file to be made executable.
|
44
|
+
def make_file_executable(path)
|
45
|
+
@executable_files << path
|
46
|
+
end
|
47
|
+
|
40
48
|
# Generate a summary of the changes that will be applied to the module.
|
41
49
|
#
|
42
50
|
# @raise (see #calculate_diffs)
|
@@ -49,7 +57,8 @@ module PDK
|
|
49
57
|
{
|
50
58
|
added: @added_files,
|
51
59
|
removed: @removed_files.select { |f| PDK::Util::Filesystem.exist?(f) },
|
52
|
-
modified: @diff_cache.compact
|
60
|
+
modified: @diff_cache.compact,
|
61
|
+
'made executable': @executable_files
|
53
62
|
}
|
54
63
|
end
|
55
64
|
|
@@ -60,7 +69,8 @@ module PDK
|
|
60
69
|
def changes?
|
61
70
|
!changes[:added].empty? ||
|
62
71
|
!changes[:removed].empty? ||
|
63
|
-
changes[:modified].any? { |_, value| !value.nil? }
|
72
|
+
changes[:modified].any? { |_, value| !value.nil? } ||
|
73
|
+
!changes[:'made executable'].empty?
|
64
74
|
end
|
65
75
|
|
66
76
|
# Check if the update manager will change the specified file upon sync.
|
@@ -72,13 +82,15 @@ module PDK
|
|
72
82
|
def changed?(path)
|
73
83
|
changes[:added].any? { |add| add[:path] == path } ||
|
74
84
|
changes[:removed].include?(path) ||
|
75
|
-
changes[:modified].key?(path)
|
85
|
+
changes[:modified].key?(path) ||
|
86
|
+
changes[:'made executable'].include?(path)
|
76
87
|
end
|
77
88
|
|
78
89
|
def clear!
|
79
90
|
@modified_files.clear
|
80
91
|
@added_files.clear
|
81
92
|
@removed_files.clear
|
93
|
+
@executable_files.clear
|
82
94
|
nil
|
83
95
|
end
|
84
96
|
|
@@ -100,6 +112,10 @@ module PDK
|
|
100
112
|
files_to_write.each do |file|
|
101
113
|
write_file(file[:path], file[:content])
|
102
114
|
end
|
115
|
+
|
116
|
+
@executable_files.each do |file|
|
117
|
+
update_execute_bits(file)
|
118
|
+
end
|
103
119
|
end
|
104
120
|
|
105
121
|
# Remove a file from disk.
|
@@ -215,6 +231,16 @@ module PDK
|
|
215
231
|
|
216
232
|
output.join($INPUT_RECORD_SEPARATOR)
|
217
233
|
end
|
234
|
+
|
235
|
+
# Set the execute bits on a file
|
236
|
+
def update_execute_bits(path)
|
237
|
+
require 'pdk/util/filesystem'
|
238
|
+
|
239
|
+
PDK.logger.debug(format("making '%{path}' executable", path: path))
|
240
|
+
PDK::Util::Filesystem.make_executable(path)
|
241
|
+
rescue Errno::EACCES
|
242
|
+
raise PDK::CLI::ExitWithError, format("You do not have permission to make '%{path}' executable", path: path)
|
243
|
+
end
|
218
244
|
end
|
219
245
|
end
|
220
246
|
end
|
data/lib/pdk/report/event.rb
CHANGED
@@ -43,7 +43,6 @@ module PDK
|
|
43
43
|
# @api private
|
44
44
|
def config_for(dest_path, sync_config_path = nil)
|
45
45
|
require 'pdk/util'
|
46
|
-
require 'pdk/analytics'
|
47
46
|
|
48
47
|
module_root = PDK::Util.module_root
|
49
48
|
sync_config_path ||= File.join(module_root, '.sync.yml') unless module_root.nil?
|
@@ -56,22 +55,20 @@ module PDK
|
|
56
55
|
@config = conf_defaults
|
57
56
|
@config.deep_merge!(@sync_config, knockout_prefix: '---') unless @sync_config.nil?
|
58
57
|
end
|
59
|
-
file_config = @config.fetch(
|
58
|
+
file_config = @config.fetch('common', {}).clone
|
60
59
|
file_config['module_metadata'] = @module_metadata
|
61
60
|
file_config.merge!(@config.fetch(dest_path, {})) unless dest_path.nil?
|
62
61
|
file_config.merge!(@config).tap do |c|
|
63
62
|
if uri.default?
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
PDK.analytics.event('TemplateDir', 'file', label: dest_path, value: file_value)
|
63
|
+
if c['unmanaged']
|
64
|
+
'unmanaged'
|
65
|
+
elsif c['delete']
|
66
|
+
'deleted'
|
67
|
+
elsif @sync_config&.key?(dest_path)
|
68
|
+
'customized'
|
69
|
+
else
|
70
|
+
'default'
|
71
|
+
end
|
75
72
|
end
|
76
73
|
end
|
77
74
|
end
|
@@ -95,7 +95,9 @@ module PDK
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
dest_executable = config['manage_execute_permissions'] && PDK::Util::Filesystem.stat(File.join(template_loc, template_file)).executable?
|
99
|
+
|
100
|
+
yield dest_path, dest_content, dest_status, dest_executable
|
99
101
|
end
|
100
102
|
end
|
101
103
|
# :nocov:
|
data/lib/pdk/template.rb
CHANGED
@@ -44,9 +44,6 @@ module PDK
|
|
44
44
|
template_dir = TemplateDir.instance(uri, fetcher.path, context)
|
45
45
|
template_dir.metadata = fetcher.metadata
|
46
46
|
|
47
|
-
template_type = uri.default? ? 'default' : 'custom'
|
48
|
-
PDK.analytics.event('TemplateDir', 'initialize', label: template_type)
|
49
|
-
|
50
47
|
yield template_dir
|
51
48
|
end
|
52
49
|
nil
|
data/lib/pdk/tests/unit.rb
CHANGED
@@ -246,10 +246,10 @@ module PDK
|
|
246
246
|
raise PDK::CLI::FatalError, format('Failed to find valid JSON in output from rspec: %{output}', output: output[:stdout]) unless rspec_json
|
247
247
|
|
248
248
|
if rspec_json['examples'].empty?
|
249
|
-
|
250
|
-
return [] if
|
249
|
+
return [] if rspec_json['messages'][0] == 'No examples found.'
|
250
|
+
return [] if rspec_json['messages'].include?("\nAll examples were filtered out")
|
251
251
|
|
252
|
-
raise PDK::CLI::FatalError, format('Unable to enumerate examples. rspec reported: %{message}', message:
|
252
|
+
raise PDK::CLI::FatalError, format('Unable to enumerate examples. rspec reported: %{message}', message: rspec_json['messages'])
|
253
253
|
else
|
254
254
|
examples = []
|
255
255
|
rspec_json['examples'].each do |example|
|
data/lib/pdk/util/filesystem.rb
CHANGED
@@ -27,6 +27,11 @@ module PDK
|
|
27
27
|
end
|
28
28
|
module_function :read_file
|
29
29
|
|
30
|
+
def make_executable(file)
|
31
|
+
FileUtils.chmod('a+x', file)
|
32
|
+
end
|
33
|
+
module_function :make_executable
|
34
|
+
|
30
35
|
# :nocov:
|
31
36
|
# These methods just wrap core Ruby functionality and
|
32
37
|
# can be ignored for code coverage
|
@@ -133,6 +138,11 @@ module PDK
|
|
133
138
|
end
|
134
139
|
end
|
135
140
|
module_function :mv
|
141
|
+
|
142
|
+
def executable?(*args)
|
143
|
+
File.executable?(*args)
|
144
|
+
end
|
145
|
+
module_function :executable?
|
136
146
|
# :nocov:
|
137
147
|
end
|
138
148
|
end
|
data/lib/pdk/util.rb
CHANGED
data/lib/pdk/version.rb
CHANGED
data/lib/pdk.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module PDK
|
2
|
-
autoload :Analytics, 'pdk/analytics'
|
3
2
|
autoload :AnswerFile, 'pdk/answer_file'
|
4
3
|
autoload :Bolt, 'pdk/bolt'
|
5
4
|
autoload :Config, 'pdk/config'
|
@@ -58,17 +57,4 @@ module PDK
|
|
58
57
|
|
59
58
|
requested_feature_flags.include?(flagname)
|
60
59
|
end
|
61
|
-
|
62
|
-
def self.analytics
|
63
|
-
@analytics ||= PDK::Analytics.build_client(
|
64
|
-
logger: PDK.logger,
|
65
|
-
disabled: PDK::Util::Env['PDK_DISABLE_ANALYTICS'] || PDK.config.get_within_scopes('analytics.disabled', ['user', 'system']),
|
66
|
-
user_id: PDK.config.get_within_scopes('analytics.user-id', ['user', 'system']),
|
67
|
-
app_id: "UA-139917834-#{PDK::Util.development_mode? ? '2' : '1'}",
|
68
|
-
client: :google_analytics,
|
69
|
-
app_name: 'pdk',
|
70
|
-
app_version: PDK::VERSION,
|
71
|
-
app_installer: PDK::Util.package_install? ? 'package' : 'gem'
|
72
|
-
)
|
73
|
-
end
|
74
60
|
end
|