pdk 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +25 -0
- data/README.md +41 -0
- data/lib/pdk.rb +0 -13
- data/lib/pdk/analytics.rb +18 -2
- data/lib/pdk/analytics/client/google_analytics.rb +3 -0
- data/lib/pdk/answer_file.rb +4 -1
- data/lib/pdk/cli.rb +7 -2
- data/lib/pdk/cli/build.rb +2 -2
- data/lib/pdk/cli/bundle.rb +7 -1
- data/lib/pdk/cli/console.rb +148 -0
- data/lib/pdk/cli/convert.rb +2 -2
- data/lib/pdk/cli/exec.rb +14 -14
- data/lib/pdk/cli/exec/command.rb +16 -11
- data/lib/pdk/cli/exec/interactive_command.rb +4 -0
- data/lib/pdk/cli/exec_group.rb +5 -5
- data/lib/pdk/cli/module/build.rb +0 -2
- data/lib/pdk/cli/module/generate.rb +1 -2
- data/lib/pdk/cli/new.rb +1 -1
- data/lib/pdk/cli/new/defined_type.rb +2 -0
- data/lib/pdk/cli/new/provider.rb +2 -0
- data/lib/pdk/cli/new/task.rb +2 -0
- data/lib/pdk/cli/new/{unit_test.rb → test.rb} +16 -12
- data/lib/pdk/cli/new/transport.rb +2 -0
- data/lib/pdk/cli/test/unit.rb +5 -3
- data/lib/pdk/cli/update.rb +2 -3
- data/lib/pdk/cli/util.rb +45 -14
- data/lib/pdk/cli/util/spinner.rb +2 -2
- data/lib/pdk/cli/validate.rb +6 -2
- data/lib/pdk/config.rb +20 -8
- data/lib/pdk/config/analytics_schema.json +26 -0
- data/lib/pdk/config/json.rb +14 -3
- data/lib/pdk/config/json_schema_namespace.rb +143 -0
- data/lib/pdk/config/json_schema_setting.rb +53 -0
- data/lib/pdk/config/json_with_schema.rb +50 -0
- data/lib/pdk/config/namespace.rb +84 -76
- data/lib/pdk/config/setting.rb +132 -0
- data/lib/pdk/config/yaml.rb +15 -3
- data/lib/pdk/config/yaml_with_schema.rb +59 -0
- data/lib/pdk/generate.rb +0 -2
- data/lib/pdk/generate/module.rb +29 -16
- data/lib/pdk/generate/puppet_object.rb +31 -28
- data/lib/pdk/module.rb +2 -2
- data/lib/pdk/module/build.rb +21 -8
- data/lib/pdk/module/convert.rb +64 -7
- data/lib/pdk/module/metadata.rb +5 -1
- data/lib/pdk/module/templatedir.rb +24 -7
- data/lib/pdk/module/update.rb +5 -1
- data/lib/pdk/module/update_manager.rb +21 -13
- data/lib/pdk/report.rb +4 -3
- data/lib/pdk/report/event.rb +5 -3
- data/lib/pdk/tests/unit.rb +36 -7
- data/lib/pdk/util.rb +20 -8
- data/lib/pdk/util/bundler.rb +14 -6
- data/lib/pdk/util/filesystem.rb +5 -0
- data/lib/pdk/util/git.rb +6 -0
- data/lib/pdk/util/puppet_strings.rb +24 -2
- data/lib/pdk/util/puppet_version.rb +25 -10
- data/lib/pdk/util/ruby_version.rb +13 -1
- data/lib/pdk/util/template_uri.rb +23 -2
- data/lib/pdk/util/vendored_file.rb +28 -24
- data/lib/pdk/util/version.rb +5 -5
- data/lib/pdk/validate/base_validator.rb +5 -4
- data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -4
- data/lib/pdk/validate/metadata/metadata_syntax.rb +5 -3
- data/lib/pdk/validate/metadata_validator.rb +0 -2
- data/lib/pdk/validate/puppet/puppet_epp.rb +4 -4
- data/lib/pdk/validate/puppet/puppet_lint.rb +0 -3
- data/lib/pdk/validate/puppet/puppet_syntax.rb +4 -4
- data/lib/pdk/validate/puppet_validator.rb +0 -2
- data/lib/pdk/validate/ruby/rubocop.rb +0 -5
- data/lib/pdk/validate/ruby_validator.rb +0 -2
- data/lib/pdk/validate/tasks/metadata_lint.rb +9 -5
- data/lib/pdk/validate/tasks/name.rb +4 -2
- data/lib/pdk/validate/tasks_validator.rb +0 -2
- data/lib/pdk/validate/yaml/syntax.rb +4 -4
- data/lib/pdk/validate/yaml_validator.rb +0 -2
- data/lib/pdk/version.rb +1 -1
- data/locales/pdk.pot +351 -311
- metadata +11 -7
- data/lib/pdk/config/validator.rb +0 -31
- data/lib/pdk/config/value.rb +0 -94
data/lib/pdk/report.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
require 'time'
|
3
1
|
require 'pdk/report/event'
|
4
|
-
require 'socket'
|
5
2
|
|
6
3
|
module PDK
|
7
4
|
class Report
|
@@ -48,6 +45,10 @@ module PDK
|
|
48
45
|
# @param target [#write] an IO object that the report will be written to.
|
49
46
|
# Defaults to PDK::Report.default_target.
|
50
47
|
def write_junit(target = self.class.default_target)
|
48
|
+
require 'rexml/document'
|
49
|
+
require 'time'
|
50
|
+
require 'socket'
|
51
|
+
|
51
52
|
# Open a File Object for IO if target is a string containing a filename or path
|
52
53
|
target = File.open(target, 'w') if target.is_a? String
|
53
54
|
|
data/lib/pdk/report/event.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
1
|
module PDK
|
5
2
|
class Report
|
6
3
|
class Event
|
@@ -132,6 +129,8 @@ module PDK
|
|
132
129
|
#
|
133
130
|
# @return [REXML::Element] The rendered event.
|
134
131
|
def to_junit
|
132
|
+
require 'rexml/document'
|
133
|
+
|
135
134
|
testcase = REXML::Element.new('testcase')
|
136
135
|
testcase.attributes['classname'] = [source, test].compact.join('.')
|
137
136
|
testcase.attributes['name'] = [file, line, column].compact.join(':')
|
@@ -195,6 +194,9 @@ module PDK
|
|
195
194
|
raise ArgumentError, _('File must be a String.')
|
196
195
|
end
|
197
196
|
|
197
|
+
require 'pathname'
|
198
|
+
require 'pdk/util'
|
199
|
+
|
198
200
|
path = Pathname.new(value)
|
199
201
|
|
200
202
|
if path.absolute?
|
data/lib/pdk/tests/unit.rb
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
require 'pdk/cli/exec'
|
3
|
-
require 'pdk/util/bundler'
|
4
|
-
require 'json'
|
5
|
-
|
6
1
|
module PDK
|
7
2
|
module Test
|
8
3
|
class Unit
|
@@ -13,14 +8,23 @@ module PDK
|
|
13
8
|
end
|
14
9
|
|
15
10
|
def self.rake_bin
|
11
|
+
require 'pdk/util'
|
12
|
+
|
16
13
|
@rake ||= File.join(PDK::Util.module_root, 'bin', 'rake')
|
17
14
|
end
|
18
15
|
|
19
|
-
def self.
|
16
|
+
def self.cmd_with_args(task)
|
17
|
+
require 'pdk/util/ruby_version'
|
18
|
+
|
20
19
|
argv = [rake_bin, task]
|
21
20
|
argv.unshift(File.join(PDK::Util::RubyVersion.bin_path, 'ruby.exe')) if Gem.win_platform?
|
21
|
+
argv
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
+
def self.rake(task, spinner_text, environment = {})
|
25
|
+
require 'pdk/cli/exec/command'
|
26
|
+
|
27
|
+
command = PDK::CLI::Exec::Command.new(*cmd_with_args(task)).tap do |c|
|
24
28
|
c.context = :module
|
25
29
|
c.add_spinner(spinner_text) if spinner_text
|
26
30
|
c.environment = environment
|
@@ -29,6 +33,19 @@ module PDK
|
|
29
33
|
command.execute!
|
30
34
|
end
|
31
35
|
|
36
|
+
def self.interactive_rake(task, environment)
|
37
|
+
require 'pdk/cli/exec/interactive_command'
|
38
|
+
|
39
|
+
command = PDK::CLI::Exec::InteractiveCommand.new(*cmd_with_args(task)).tap do |c|
|
40
|
+
c.context = :module
|
41
|
+
c.environment = environment.reject do |key, _|
|
42
|
+
key == 'CI_SPEC_OPTIONS'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
command.execute!
|
47
|
+
end
|
48
|
+
|
32
49
|
def self.parallel_with_no_tests?(ran_in_parallel, json_result, result)
|
33
50
|
ran_in_parallel && json_result.empty? &&
|
34
51
|
((!result[:exit_code].zero? && result[:stderr].strip =~ %r{Pass files or folders to run$}) ||
|
@@ -64,6 +81,9 @@ module PDK
|
|
64
81
|
end
|
65
82
|
|
66
83
|
def self.invoke(report, options = {})
|
84
|
+
require 'pdk/util'
|
85
|
+
require 'pdk/util/bundler'
|
86
|
+
|
67
87
|
PDK::Util::Bundler.ensure_binstubs!('rake', 'rspec-core')
|
68
88
|
|
69
89
|
setup
|
@@ -73,6 +93,12 @@ module PDK
|
|
73
93
|
environment = { 'CI_SPEC_OPTIONS' => '--format j' }
|
74
94
|
environment['PUPPET_GEM_VERSION'] = options[:puppet] if options[:puppet]
|
75
95
|
spinner_msg = options[:parallel] ? _('Running unit tests in parallel.') : _('Running unit tests.')
|
96
|
+
|
97
|
+
if options[:interactive]
|
98
|
+
result = interactive_rake(cmd(tests, options), environment)
|
99
|
+
return result[:exit_code]
|
100
|
+
end
|
101
|
+
|
76
102
|
result = rake(cmd(tests, options), spinner_msg, environment)
|
77
103
|
|
78
104
|
json_result = if options[:parallel]
|
@@ -184,6 +210,9 @@ module PDK
|
|
184
210
|
|
185
211
|
# @return array of { :id, :full_description }
|
186
212
|
def self.list(options = {})
|
213
|
+
require 'pdk/util'
|
214
|
+
require 'pdk/util/bundler'
|
215
|
+
|
187
216
|
PDK::Util::Bundler.ensure_binstubs!('rake')
|
188
217
|
|
189
218
|
environment = {}
|
data/lib/pdk/util.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'pdk/util/version'
|
1
|
+
# PDK::Util::Windows can not be lazy loaded because it conditionally requires
|
2
|
+
# other files on Windows only. This can probably be fixed up with a later
|
3
|
+
# refactoring.
|
5
4
|
require 'pdk/util/windows'
|
6
|
-
require 'pdk/util/vendored_file'
|
7
|
-
require 'pdk/util/filesystem'
|
8
|
-
require 'pdk/util/template_uri'
|
9
|
-
require 'pdk/util/puppet_strings'
|
10
5
|
|
11
6
|
module PDK
|
12
7
|
module Util
|
@@ -45,6 +40,8 @@ module PDK
|
|
45
40
|
#
|
46
41
|
# @return [String] The temporary directory path.
|
47
42
|
def make_tmpdir_name(base)
|
43
|
+
require 'tmpdir'
|
44
|
+
|
48
45
|
t = Time.now.strftime('%Y%m%d')
|
49
46
|
name = "#{base}#{t}-#{Process.pid}-#{rand(0x100000000).to_s(36)}"
|
50
47
|
File.join(Dir.tmpdir, name)
|
@@ -69,11 +66,15 @@ module PDK
|
|
69
66
|
module_function :canonical_path
|
70
67
|
|
71
68
|
def package_install?
|
69
|
+
require 'pdk/util/version'
|
70
|
+
|
72
71
|
!PDK::Util::Version.version_file.nil?
|
73
72
|
end
|
74
73
|
module_function :package_install?
|
75
74
|
|
76
75
|
def development_mode?
|
76
|
+
require 'pdk/util/version'
|
77
|
+
|
77
78
|
(!PDK::Util::Version.git_ref.nil? || PDK::VERSION.end_with?('.pre'))
|
78
79
|
end
|
79
80
|
module_function :development_mode?
|
@@ -85,6 +86,7 @@ module PDK
|
|
85
86
|
|
86
87
|
def pdk_package_basedir
|
87
88
|
raise PDK::CLI::FatalError, _('Package basedir requested for non-package install.') unless package_install?
|
89
|
+
require 'pdk/util/version'
|
88
90
|
|
89
91
|
File.dirname(PDK::Util::Version.version_file)
|
90
92
|
end
|
@@ -132,6 +134,14 @@ module PDK
|
|
132
134
|
end
|
133
135
|
module_function :module_root
|
134
136
|
|
137
|
+
# The module's fixtures directory for spec testing
|
138
|
+
# @return [String] - the path to the module's fixtures directory
|
139
|
+
def module_fixtures_dir
|
140
|
+
dir = module_root
|
141
|
+
File.join(module_root, 'spec', 'fixtures') unless dir.nil?
|
142
|
+
end
|
143
|
+
module_function :module_fixtures_dir
|
144
|
+
|
135
145
|
# Returns true or false depending on if any of the common directories in a module
|
136
146
|
# are found in the current directory
|
137
147
|
#
|
@@ -210,6 +220,8 @@ module PDK
|
|
210
220
|
|
211
221
|
# TO-DO: Refactor replacement of lib/pdk/module/build.rb:metadata to use this function instead
|
212
222
|
def module_metadata
|
223
|
+
require 'pdk/module/metadata'
|
224
|
+
|
213
225
|
PDK::Module::Metadata.from_file(File.join(module_root, 'metadata.json')).data
|
214
226
|
end
|
215
227
|
module_function :module_metadata
|
data/lib/pdk/util/bundler.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
require 'digest'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'pdk/util'
|
5
|
-
require 'pdk/cli/exec'
|
6
|
-
|
7
1
|
module PDK
|
8
2
|
module Util
|
9
3
|
module Bundler
|
10
4
|
class BundleHelper; end
|
11
5
|
|
12
6
|
def self.ensure_bundle!(gem_overrides = nil)
|
7
|
+
require 'fileutils'
|
8
|
+
|
13
9
|
bundle = BundleHelper.new
|
14
10
|
|
15
11
|
# This will default ensure_bundle! to re-resolving everything to latest
|
@@ -70,6 +66,8 @@ module PDK
|
|
70
66
|
end
|
71
67
|
|
72
68
|
def self.bundle_cache_key(gemfile, gem_overrides)
|
69
|
+
require 'digest'
|
70
|
+
|
73
71
|
override_sig = (gem_overrides || {}).sort_by { |gem, _| gem.to_s }.to_s
|
74
72
|
Digest::MD5.hexdigest(gemfile.to_s + override_sig)
|
75
73
|
end
|
@@ -77,6 +75,7 @@ module PDK
|
|
77
75
|
|
78
76
|
class BundleHelper
|
79
77
|
def gemfile
|
78
|
+
require 'pdk/util'
|
80
79
|
@gemfile ||= PDK::Util.find_upwards('Gemfile')
|
81
80
|
end
|
82
81
|
|
@@ -108,6 +107,10 @@ module PDK
|
|
108
107
|
end
|
109
108
|
|
110
109
|
def lock!
|
110
|
+
require 'pdk/util'
|
111
|
+
require 'fileutils'
|
112
|
+
require 'pdk/util/ruby_version'
|
113
|
+
|
111
114
|
if PDK::Util.package_install?
|
112
115
|
# In packaged installs, use vendored Gemfile.lock as a starting point.
|
113
116
|
# Subsequent 'bundle install' will still pick up any new dependencies.
|
@@ -185,6 +188,8 @@ module PDK
|
|
185
188
|
end
|
186
189
|
|
187
190
|
def install!(gem_overrides = {})
|
191
|
+
require 'pdk/util/ruby_version'
|
192
|
+
|
188
193
|
argv = ['install', "--gemfile=#{gemfile}"]
|
189
194
|
argv << '-j4' unless Gem.win_platform? && Gem::Version.new(PDK::Util::RubyVersion.active_ruby_version) < Gem::Version.new('2.3.5')
|
190
195
|
|
@@ -239,6 +244,9 @@ module PDK
|
|
239
244
|
end
|
240
245
|
|
241
246
|
def bundle_command(*args)
|
247
|
+
require 'pdk/cli/exec'
|
248
|
+
require 'pdk/cli/exec/command'
|
249
|
+
|
242
250
|
PDK::CLI::Exec::Command.new(PDK::CLI::Exec.bundle_bin, *args).tap do |c|
|
243
251
|
c.context = :module
|
244
252
|
end
|
data/lib/pdk/util/filesystem.rb
CHANGED
data/lib/pdk/util/git.rb
CHANGED
@@ -36,6 +36,8 @@ module PDK
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.git_bin
|
39
|
+
require 'pdk/cli/exec'
|
40
|
+
|
39
41
|
git_bin = Gem.win_platform? ? 'git.exe' : 'git'
|
40
42
|
vendored_bin_path = File.join(git_bindir, git_bin)
|
41
43
|
|
@@ -43,12 +45,16 @@ module PDK
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def self.git(*args)
|
48
|
+
require 'pdk/cli/exec'
|
49
|
+
|
46
50
|
PDK::CLI::Exec.ensure_bin_present!(git_bin, 'git')
|
47
51
|
|
48
52
|
PDK::CLI::Exec.execute(git_bin, *args)
|
49
53
|
end
|
50
54
|
|
51
55
|
def self.git_with_env(env, *args)
|
56
|
+
require 'pdk/cli/exec'
|
57
|
+
|
52
58
|
PDK::CLI::Exec.ensure_bin_present!(git_bin, 'git')
|
53
59
|
|
54
60
|
PDK::CLI::Exec.execute_with_env(env, git_bin, *args)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'pdk/cli/exec'
|
2
|
-
|
3
1
|
module PDK
|
4
2
|
module Util
|
5
3
|
module PuppetStrings
|
@@ -13,6 +11,8 @@ module PDK
|
|
13
11
|
#
|
14
12
|
# @return [Hash{Symbol=>Object}] the result of the command execution.
|
15
13
|
def self.puppet(*args)
|
14
|
+
require 'pdk/cli/exec/command'
|
15
|
+
|
16
16
|
PDK::Util::Bundler.ensure_binstubs!('puppet')
|
17
17
|
|
18
18
|
argv = [File.join(PDK::Util.module_root, 'bin', 'puppet')] + args
|
@@ -80,6 +80,26 @@ module PDK
|
|
80
80
|
[generator, known_objects[object_type].find { |obj| object_names.include?(obj['name']) }]
|
81
81
|
end
|
82
82
|
|
83
|
+
# Generate a list of all objects that PDK has a generator for.
|
84
|
+
#
|
85
|
+
# @returns [Array[Array[PDK::Generate::PuppetObject,
|
86
|
+
# Array[Hash{String=>Object}]]]] an associative array where the first
|
87
|
+
# element of each pair is the generator class and the second element of
|
88
|
+
# each pair is an array of description hashes from puppet-strings.
|
89
|
+
def self.all_objects
|
90
|
+
require 'pdk/generate'
|
91
|
+
|
92
|
+
generators = PDK::Generate::GENERATORS.select do |gen|
|
93
|
+
gen.respond_to?(:puppet_strings_type) && !gen.puppet_strings_type.nil?
|
94
|
+
end
|
95
|
+
|
96
|
+
known_objects = generate_hash
|
97
|
+
|
98
|
+
generators.map { |gen| [gen, known_objects[gen.puppet_strings_type]] }.reject do |_, obj|
|
99
|
+
obj.nil? || obj.empty?
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
83
103
|
# Evaluates the mapping of puppet-strings object type to PDK generator
|
84
104
|
# class.
|
85
105
|
#
|
@@ -92,6 +112,8 @@ module PDK
|
|
92
112
|
# PDK::Util::PuppetStrings.find_generator('puppet_classes')
|
93
113
|
# => PDK::Generate::PuppetClass
|
94
114
|
def self.find_generator(type)
|
115
|
+
require 'pdk/generate'
|
116
|
+
|
95
117
|
PDK::Generate::GENERATORS.find do |gen|
|
96
118
|
gen.respond_to?(:puppet_strings_type) && gen.puppet_strings_type == type
|
97
119
|
end
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'pdk/util'
|
2
|
-
require 'pdk/util/git'
|
3
|
-
|
4
1
|
module PDK
|
5
2
|
module Util
|
6
3
|
class PuppetVersion
|
@@ -21,6 +18,8 @@ module PDK
|
|
21
18
|
DEFAULT_PUPPET_DEV_BRANCH = 'master'.freeze
|
22
19
|
|
23
20
|
def puppet_dev_env
|
21
|
+
require 'pdk/util/ruby_version'
|
22
|
+
|
24
23
|
{
|
25
24
|
gem_version: 'file://%{path}' % { path: puppet_dev_path },
|
26
25
|
ruby_version: PDK::Util::RubyVersion.latest_ruby_version,
|
@@ -28,6 +27,8 @@ module PDK
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def puppet_dev_path
|
30
|
+
require 'pdk/util'
|
31
|
+
|
31
32
|
File.join(PDK::Util.cachedir, 'src', 'puppet')
|
32
33
|
end
|
33
34
|
|
@@ -42,6 +43,9 @@ module PDK
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def fetch_puppet_dev
|
46
|
+
require 'pdk/util/git'
|
47
|
+
require 'fileutils'
|
48
|
+
|
45
49
|
# Check if the source is cloned and is a readable git repo
|
46
50
|
unless PDK::Util::Git.remote_repo? puppet_dev_path
|
47
51
|
# Check if the path has something in it already. Delete it and prepare for clone if so.
|
@@ -133,6 +137,9 @@ module PDK
|
|
133
137
|
end
|
134
138
|
|
135
139
|
def from_module_metadata(metadata = nil)
|
140
|
+
require 'pdk/module/metadata'
|
141
|
+
require 'pdk/util'
|
142
|
+
|
136
143
|
if metadata.nil?
|
137
144
|
metadata_file = PDK::Util.find_upwards('metadata.json')
|
138
145
|
|
@@ -191,6 +198,8 @@ module PDK
|
|
191
198
|
end
|
192
199
|
|
193
200
|
def fetch_pe_version_map
|
201
|
+
require 'pdk/util/vendored_file'
|
202
|
+
|
194
203
|
map = PDK::Util::VendoredFile.new('pe_versions.json', PE_VERSIONS_URL).read
|
195
204
|
|
196
205
|
JSON.parse(map)
|
@@ -205,17 +214,19 @@ module PDK
|
|
205
214
|
end
|
206
215
|
|
207
216
|
def rubygems_puppet_versions
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
217
|
+
@rubygems_puppet_versions ||= begin
|
218
|
+
fetcher = Gem::SpecFetcher.fetcher
|
219
|
+
puppet_tuples = fetcher.detect(:released) do |spec_tuple|
|
220
|
+
spec_tuple.name == 'puppet' && Gem::Platform.match(spec_tuple.platform)
|
221
|
+
end
|
222
|
+
puppet_versions = puppet_tuples.map { |name, _| name.version }.uniq
|
223
|
+
puppet_versions.sort { |a, b| b <=> a }
|
213
224
|
end
|
214
|
-
puppet_versions = puppet_tuples.map { |name, _| name.version }.uniq
|
215
|
-
@rubygems_puppet_versions = puppet_versions.sort { |a, b| b <=> a }
|
216
225
|
end
|
217
226
|
|
218
227
|
def find_gem(requirement)
|
228
|
+
require 'pdk/util'
|
229
|
+
|
219
230
|
if PDK::Util.package_install?
|
220
231
|
find_in_package_cache(requirement)
|
221
232
|
else
|
@@ -224,11 +235,15 @@ module PDK
|
|
224
235
|
end
|
225
236
|
|
226
237
|
def find_in_rubygems(requirement)
|
238
|
+
require 'pdk/util/ruby_version'
|
239
|
+
|
227
240
|
version = rubygems_puppet_versions.find { |r| requirement.satisfied_by?(r) }
|
228
241
|
version.nil? ? nil : { gem_version: version, ruby_version: PDK::Util::RubyVersion.default_ruby_version }
|
229
242
|
end
|
230
243
|
|
231
244
|
def find_in_package_cache(requirement)
|
245
|
+
require 'pdk/util/ruby_version'
|
246
|
+
|
232
247
|
PDK::Util::RubyVersion.versions.each do |ruby_version, _|
|
233
248
|
PDK::Util::RubyVersion.use(ruby_version)
|
234
249
|
version = PDK::Util::RubyVersion.available_puppet_versions.find { |r| requirement.satisfied_by?(r) }
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'pdk/util'
|
2
1
|
require 'forwardable'
|
3
2
|
|
4
3
|
module PDK
|
@@ -41,6 +40,8 @@ module PDK
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def scan_for_packaged_rubies
|
43
|
+
require 'pdk/util'
|
44
|
+
|
44
45
|
ruby_basedir = File.join(PDK::Util.pdk_package_basedir, 'private', 'ruby', '*')
|
45
46
|
Dir[ruby_basedir].sort.map { |ruby_dir|
|
46
47
|
version = File.basename(ruby_dir)
|
@@ -49,6 +50,9 @@ module PDK
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def default_ruby_version
|
53
|
+
require 'pdk/util'
|
54
|
+
require 'pdk/util/puppet_version'
|
55
|
+
|
52
56
|
@default_ruby_version ||= if PDK::Util.package_install?
|
53
57
|
# Default to the ruby that supports the latest puppet gem. If you wish to default to a
|
54
58
|
# specific Puppet Gem version use the following example;
|
@@ -69,6 +73,8 @@ module PDK
|
|
69
73
|
end
|
70
74
|
|
71
75
|
def versions
|
76
|
+
require 'pdk/util'
|
77
|
+
|
72
78
|
@versions ||= if PDK::Util.package_install?
|
73
79
|
scan_for_packaged_rubies
|
74
80
|
else
|
@@ -84,6 +90,8 @@ module PDK
|
|
84
90
|
end
|
85
91
|
|
86
92
|
def bin_path
|
93
|
+
require 'pdk/util'
|
94
|
+
|
87
95
|
if PDK::Util.package_install?
|
88
96
|
File.join(PDK::Util.pdk_package_basedir, 'private', 'ruby', ruby_version, 'bin')
|
89
97
|
else
|
@@ -92,6 +100,8 @@ module PDK
|
|
92
100
|
end
|
93
101
|
|
94
102
|
def gem_paths_raw
|
103
|
+
require 'pdk/util'
|
104
|
+
|
95
105
|
if PDK::Util.package_install?
|
96
106
|
# Subprocesses use their own set of gems which are managed by pdk or
|
97
107
|
# installed with the package. We also include the separate gem path
|
@@ -115,6 +125,8 @@ module PDK
|
|
115
125
|
end
|
116
126
|
|
117
127
|
def gem_home
|
128
|
+
require 'pdk/util'
|
129
|
+
|
118
130
|
# `bundle install --path` ignores all "system" installed gems and
|
119
131
|
# causes unnecessary package installs. `bundle install` (without
|
120
132
|
# --path) installs into GEM_HOME, which by default is non-user
|