Skip to content

Commit c257802

Browse files
committed
pdk update.
1 parent 86938a5 commit c257802

File tree

3 files changed

+47
-27
lines changed

3 files changed

+47
-27
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require:
55
AllCops:
66
NewCops: enable
77
DisplayCopNames: true
8-
TargetRubyVersion: '2.7'
8+
TargetRubyVersion: 3.1
99
Include:
1010
- "**/*.rb"
1111
Exclude:

Gemfile

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1-
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
1+
# frozen_string_literal: true
22

3-
def location_for(place_or_version, fake_version = nil)
4-
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
5-
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
3+
# For puppetcore, set GEM_SOURCE_PUPPETCORE = 'https://rubygems-puppetcore.puppet.com'
4+
gemsource_default = ENV['GEM_SOURCE'] || 'https://rubygems.org'
5+
gemsource_puppetcore = if ENV['PUPPET_FORGE_TOKEN']
6+
'https://rubygems-puppetcore.puppet.com'
7+
else
8+
ENV['GEM_SOURCE_PUPPETCORE'] || gemsource_default
9+
end
10+
source gemsource_default
11+
12+
def location_for(place_or_constraint, fake_constraint = nil, opts = {})
13+
git_url_regex = /\A(?<url>(?:https?|git)[:@][^#]*)(?:#(?<branch>.*))?/
14+
file_url_regex = %r{\Afile://(?<path>.*)}
15+
16+
if place_or_constraint && (git_url = place_or_constraint.match(git_url_regex))
17+
# Git source → ignore :source, keep fake_constraint
18+
[fake_constraint, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
19+
20+
elsif place_or_constraint && (file_url = place_or_constraint.match(file_url_regex))
21+
# File source → ignore :source, keep fake_constraint or default >= 0
22+
[fake_constraint || '>= 0', { path: File.expand_path(file_url[:path]), require: false }]
623

7-
if place_or_version && (git_url = place_or_version.match(git_url_regex))
8-
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
9-
elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
10-
['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
1124
else
12-
[place_or_version, { require: false }]
25+
# Plain version constraint → merge opts (including :source if provided)
26+
[place_or_constraint, { require: false }.merge(opts)]
27+
end
28+
end
29+
30+
# Print debug information if DEBUG_GEMS or VERBOSE is set
31+
def print_gem_statement_for(gems)
32+
puts 'DEBUG: Gem definitions that will be generated:'
33+
gems.each do |gem_name, gem_params|
34+
puts "DEBUG: gem #{([gem_name.inspect] + gem_params.map(&:inspect)).join(', ')}"
1335
end
1436
end
1537

@@ -34,14 +56,16 @@ group :development do
3456
gem "rubocop-performance", '= 1.16.0', require: false
3557
gem "rubocop-rspec", '= 2.19.0', require: false
3658
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
59+
gem "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3760
end
3861
group :development, :release_prep do
3962
gem "puppet-strings", '~> 4.0', require: false
4063
gem "puppetlabs_spec_helper", '~> 8.0', require: false
4164
gem "puppet-blacksmith", '~> 7.0', require: false
4265
end
4366
group :system_tests do
44-
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
67+
gem "puppet_litmus", '~> 2.0', require: false, platforms: [:ruby, :x64_mingw] if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
68+
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] if ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
4569
gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw]
4670
gem "serverspec", '~> 2.41', require: false
4771
end
@@ -51,31 +75,27 @@ puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil)
5175
facter_version = ENV.fetch('FACTER_GEM_VERSION', nil)
5276
hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil)
5377

54-
# If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet
55-
# Otherwise, do as before and use location_for to fetch gems from the default source
56-
if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
57-
gems['puppet'] = ['~> 8.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }]
58-
gems['facter'] = ['~> 4.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }]
59-
else
60-
gems['puppet'] = location_for(puppet_version)
61-
gems['facter'] = location_for(facter_version) if facter_version
62-
end
63-
64-
gems['hiera'] = location_for(hiera_version) if hiera_version
78+
gems['puppet'] = location_for(puppet_version, nil, { source: gemsource_puppetcore })
79+
gems['facter'] = location_for(facter_version, nil, { source: gemsource_puppetcore })
80+
gems['hiera'] = location_for(hiera_version, nil, {}) if hiera_version
6581

82+
# Generate the gem definitions
83+
print_gem_statement_for(gems) if ENV['DEBUG']
6684
gems.each do |gem_name, gem_params|
6785
gem gem_name, *gem_params
6886
end
6987

7088
# Evaluate Gemfile.local and ~/.gemfile if they exist
7189
extra_gemfiles = [
7290
"#{__FILE__}.local",
73-
File.join(Dir.home, '.gemfile'),
91+
File.join(Dir.home, '.gemfile')
7492
]
7593

7694
extra_gemfiles.each do |gemfile|
77-
if File.file?(gemfile) && File.readable?(gemfile)
78-
eval(File.read(gemfile), binding)
79-
end
95+
next unless File.file?(gemfile) && File.readable?(gemfile)
96+
97+
# rubocop:disable Security/Eval
98+
eval(File.read(gemfile), binding)
99+
# rubocop:enable Security/Eval
80100
end
81101
# vim: syntax=ruby

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@
8585
],
8686
"pdk-version": "3.4.0",
8787
"template-url": "https://github.com/danielparks/pdk-templates#main",
88-
"template-ref": "heads/main-0-g63a199c"
88+
"template-ref": "heads/main-0-g5bc5fb3"
8989
}

0 commit comments

Comments
 (0)