pdk 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pdk might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/lib/pdk/cli/convert.rb +3 -1
- data/lib/pdk/cli/update.rb +3 -1
- data/lib/pdk/config/namespace.rb +1 -1
- data/lib/pdk/module/convert.rb +7 -2
- data/lib/pdk/module/metadata.rb +1 -1
- 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 +1 -1
- data/lib/pdk/template/renderer/v1/renderer.rb +3 -1
- data/lib/pdk/util/filesystem.rb +10 -0
- data/lib/pdk/version.rb +2 -2
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e824852c696a8dd7175afffbb7888cded4e0cbd24fb2ce93e69a57027e6860
|
4
|
+
data.tar.gz: d79ad0059c08e5612a67ef6747c1509b3fc882f6f07e260196a3a3bd1d8dd7ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b91bde6c3589f1fa0ec86772996ba1f2f06693abd53bddc4ed62e6deff6f6fc636abd37cc5cdc8783e9335553250dd07bb6ce9cfc2759dd34d52b1063bda9a08
|
7
|
+
data.tar.gz: 7919c2789897e9604af4196a240fb3570096acc7193fe234f23c745af52efd5f3a11b6a03915bc4ae74e707641c831938985d41ad358a51ca78728eb94a0b118
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
|
6
6
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
|
7
7
|
|
8
|
-
## [v3.0
|
8
|
+
## [v3.1.0](https://github.com/puppetlabs/pdk/tree/v3.1.0) - 2024-04-11
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.0.1...v3.1.0)
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Allow `pdk convert` and `pdk update` to work in a ControlRepo context [#1310](https://github.com/puppetlabs/pdk/pull/1310) ([garrettrowell](https://github.com/garrettrowell))
|
15
|
+
- Support executable templates [#1289](https://github.com/puppetlabs/pdk/pull/1289) ([nabertrand](https://github.com/nabertrand))
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- (CAT-1796) Fix missing locale gem [#1337](https://github.com/puppetlabs/pdk/pull/1337) ([LukasAud](https://github.com/LukasAud))
|
20
|
+
- (CAT-1703) Convert concurrent-ruby from a pin to a pessimistic constraint [#1312](https://github.com/puppetlabs/pdk/pull/1312) ([david22swan](https://github.com/david22swan))
|
21
|
+
|
22
|
+
## [v3.0.1](https://github.com/puppetlabs/pdk/tree/v3.0.1) - 2023-12-13
|
9
23
|
|
10
24
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.0.0...v3.0.1)
|
11
25
|
|
data/lib/pdk/cli/convert.rb
CHANGED
@@ -18,7 +18,9 @@ module PDK
|
|
18
18
|
# Write the context information to the debug log
|
19
19
|
PDK.context.to_debug_log
|
20
20
|
|
21
|
-
|
21
|
+
unless PDK.context.is_a?(PDK::Context::Module) || PDK.context.is_a?(PDK::Context::ControlRepo)
|
22
|
+
raise PDK::CLI::ExitWithError, '`pdk convert` can only be run from inside a valid module directory.'
|
23
|
+
end
|
22
24
|
|
23
25
|
raise PDK::CLI::ExitWithError, 'You can not specify --noop and --force when converting a module' if opts[:noop] && opts[:force]
|
24
26
|
|
data/lib/pdk/cli/update.rb
CHANGED
@@ -14,7 +14,9 @@ module PDK
|
|
14
14
|
# Write the context information to the debug log
|
15
15
|
PDK.context.to_debug_log
|
16
16
|
|
17
|
-
|
17
|
+
unless PDK.context.is_a?(PDK::Context::Module) || PDK.context.is_a?(PDK::Context::ControlRepo)
|
18
|
+
raise PDK::CLI::ExitWithError, '`pdk update` can only be run from inside a valid module directory.'
|
19
|
+
end
|
18
20
|
|
19
21
|
raise PDK::CLI::ExitWithError, 'This module does not appear to be PDK compatible. To make the module compatible with PDK, run `pdk convert`.' unless PDK::Util.module_pdk_compatible?
|
20
22
|
|
data/lib/pdk/config/namespace.rb
CHANGED
@@ -162,7 +162,7 @@ module PDK
|
|
162
162
|
new_hash = {}
|
163
163
|
settings.each_pair { |k, v| new_hash[k] = v.value }
|
164
164
|
@mounts.each_pair { |k, mount_point| new_hash[k] = mount_point.to_h if mount_point.include_in_parent? }
|
165
|
-
new_hash.delete_if { |_k, v| v.nil? }
|
165
|
+
new_hash.delete_if { |_k, v| v.nil? }
|
166
166
|
new_hash
|
167
167
|
end
|
168
168
|
|
data/lib/pdk/module/convert.rb
CHANGED
@@ -148,7 +148,7 @@ module PDK
|
|
148
148
|
module_name = new_metadata.nil? ? 'new-module' : new_metadata.data['name']
|
149
149
|
metadata_for_render = new_metadata.nil? ? {} : new_metadata.data
|
150
150
|
|
151
|
-
template_dir.render_new_module(module_name, metadata_for_render) do |relative_file_path, file_content, file_status|
|
151
|
+
template_dir.render_new_module(module_name, metadata_for_render) do |relative_file_path, file_content, file_status, file_executable|
|
152
152
|
absolute_file_path = File.join(module_dir, relative_file_path)
|
153
153
|
case file_status
|
154
154
|
when :unmanage
|
@@ -156,12 +156,17 @@ module PDK
|
|
156
156
|
when :delete
|
157
157
|
update_manager.remove_file(absolute_file_path)
|
158
158
|
when :init
|
159
|
-
|
159
|
+
if convert? && !PDK::Util::Filesystem.exist?(absolute_file_path)
|
160
|
+
update_manager.add_file(absolute_file_path, file_content)
|
161
|
+
update_manager.make_file_executable(absolute_file_path) if file_executable
|
162
|
+
end
|
160
163
|
when :manage
|
161
164
|
if PDK::Util::Filesystem.exist?(absolute_file_path)
|
162
165
|
update_manager.modify_file(absolute_file_path, file_content)
|
166
|
+
update_manager.make_file_executable(absolute_file_path) if file_executable && !PDK::Util::Filesystem.executable?(absolute_file_path)
|
163
167
|
else
|
164
168
|
update_manager.add_file(absolute_file_path, file_content)
|
169
|
+
update_manager.make_file_executable(absolute_file_path) if file_executable
|
165
170
|
end
|
166
171
|
end
|
167
172
|
end
|
data/lib/pdk/module/metadata.rb
CHANGED
@@ -117,7 +117,7 @@ module PDK
|
|
117
117
|
def to_json(*_args)
|
118
118
|
require 'json'
|
119
119
|
|
120
|
-
JSON.pretty_generate(@data.dup.delete_if { |_key, value| value.nil? })
|
120
|
+
JSON.pretty_generate(@data.dup.delete_if { |_key, value| value.nil? })
|
121
121
|
end
|
122
122
|
|
123
123
|
def write!(path)
|
@@ -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
@@ -56,7 +56,7 @@ module PDK
|
|
56
56
|
@config = conf_defaults
|
57
57
|
@config.deep_merge!(@sync_config, knockout_prefix: '---') unless @sync_config.nil?
|
58
58
|
end
|
59
|
-
file_config = @config.fetch(
|
59
|
+
file_config = @config.fetch('common', {}).clone
|
60
60
|
file_config['module_metadata'] = @module_metadata
|
61
61
|
file_config.merge!(@config.fetch(dest_path, {})) unless dest_path.nil?
|
62
62
|
file_config.merge!(@config).tap do |c|
|
@@ -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.executable?(File.join(template_loc, template_file))
|
99
|
+
|
100
|
+
yield dest_path, dest_content, dest_status, dest_executable
|
99
101
|
end
|
100
102
|
end
|
101
103
|
# :nocov:
|
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/version.rb
CHANGED
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: 3.0
|
4
|
+
version: 3.1.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:
|
11
|
+
date: 2024-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -208,16 +208,16 @@ dependencies:
|
|
208
208
|
name: concurrent-ruby
|
209
209
|
requirement: !ruby/object:Gem::Requirement
|
210
210
|
requirements:
|
211
|
-
- -
|
211
|
+
- - "~>"
|
212
212
|
- !ruby/object:Gem::Version
|
213
|
-
version: 1.
|
213
|
+
version: '1.0'
|
214
214
|
type: :runtime
|
215
215
|
prerelease: false
|
216
216
|
version_requirements: !ruby/object:Gem::Requirement
|
217
217
|
requirements:
|
218
|
-
- -
|
218
|
+
- - "~>"
|
219
219
|
- !ruby/object:Gem::Version
|
220
|
-
version: 1.
|
220
|
+
version: '1.0'
|
221
221
|
- !ruby/object:Gem::Dependency
|
222
222
|
name: facter
|
223
223
|
requirement: !ruby/object:Gem::Requirement
|
@@ -246,6 +246,20 @@ dependencies:
|
|
246
246
|
- - "~>"
|
247
247
|
- !ruby/object:Gem::Version
|
248
248
|
version: 2.8.3
|
249
|
+
- !ruby/object:Gem::Dependency
|
250
|
+
name: locale
|
251
|
+
requirement: !ruby/object:Gem::Requirement
|
252
|
+
requirements:
|
253
|
+
- - "~>"
|
254
|
+
- !ruby/object:Gem::Version
|
255
|
+
version: 2.1.0
|
256
|
+
type: :runtime
|
257
|
+
prerelease: false
|
258
|
+
version_requirements: !ruby/object:Gem::Requirement
|
259
|
+
requirements:
|
260
|
+
- - "~>"
|
261
|
+
- !ruby/object:Gem::Version
|
262
|
+
version: 2.1.0
|
249
263
|
- !ruby/object:Gem::Dependency
|
250
264
|
name: deep_merge
|
251
265
|
requirement: !ruby/object:Gem::Requirement
|