From 6b9050ea47d5a50ce81c6fc4dd921b578045d239 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Thu, 28 Aug 2025 09:53:02 +0100 Subject: [PATCH 1/5] (CAT-2375) Puppetcore update A set of changes dedicated to implementing puppetcore into our modules. This update, amongst other changes, removes Puppet 7 support. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 7fc57479..8a68ab79 100644 --- a/metadata.json +++ b/metadata.json @@ -103,7 +103,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 9.0.0" + "version_requirement": ">= 8.0.0 < 9.0.0" } ], "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", From c9f1091e19081e9b674938e7cc20367fd8016a9d Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Thu, 28 Aug 2025 09:56:08 +0100 Subject: [PATCH 2/5] PDK update --- .github/workflows/ci.yml | 2 - .github/workflows/nightly.yml | 2 - .puppet-lint.rc | 8 ++++ .rubocop.yml | 2 +- Gemfile | 89 ++++++++++++++++++++++------------- Rakefile | 9 ++++ metadata.json | 4 +- 7 files changed, 76 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42e7a6e0..a5738adb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,5 +15,3 @@ jobs: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" secrets: "inherit" - with: - runs_on: "ubuntu-24.04" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6e3017ba..1b06c471 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,5 +14,3 @@ jobs: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" secrets: "inherit" - with: - runs_on: "ubuntu-24.04" diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece0..9e15c6e0 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,9 @@ +--fail-on-warnings --relative +--no-80chars-check +--no-140chars-check +--no-class_inherits_from_params_class-check +--no-autoloader_layout-check +--no-documentation-check +--no-single_quote_string_with_variables-check +--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp diff --git a/.rubocop.yml b/.rubocop.yml index 439ea84e..47b1aadb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ require: AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.6' + TargetRubyVersion: 3.1 Include: - "**/*.rb" Exclude: diff --git a/Gemfile b/Gemfile index 2d8e1608..4e7de031 100644 --- a/Gemfile +++ b/Gemfile @@ -1,65 +1,86 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +# frozen_string_literal: true -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} +# For puppetcore, set GEM_SOURCE_PUPPETCORE = 'https://rubygems-puppetcore.puppet.com' +gemsource_default = ENV['GEM_SOURCE'] || 'https://rubygems.org' +gemsource_puppetcore = if ENV['PUPPET_FORGE_TOKEN'] + 'https://rubygems-puppetcore.puppet.com' +else + ENV['GEM_SOURCE_PUPPETCORE'] || gemsource_default +end +source gemsource_default + +def location_for(place_or_constraint, fake_constraint = nil, opts = {}) + git_url_regex = /\A(?(?:https?|git)[:@][^#]*)(?:#(?.*))?/ + file_url_regex = %r{\Afile://(?.*)} + + if place_or_constraint && (git_url = place_or_constraint.match(git_url_regex)) + # Git source → ignore :source, keep fake_constraint + [fake_constraint, { git: git_url[:url], branch: git_url[:branch], require: false }].compact + + elsif place_or_constraint && (file_url = place_or_constraint.match(file_url_regex)) + # File source → ignore :source, keep fake_constraint or default >= 0 + [fake_constraint || '>= 0', { path: File.expand_path(file_url[:path]), require: false }] - if place_or_version && (git_url = place_or_version.match(git_url_regex)) - [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact - elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) - ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] else - [place_or_version, { require: false }] + # Plain version constraint → merge opts (including :source if provided) + [place_or_constraint, { require: false }.merge(opts)] + end +end + +# Print debug information if DEBUG_GEMS or VERBOSE is set +def print_gem_statement_for(gems) + puts 'DEBUG: Gem definitions that will be generated:' + gems.each do |gem_name, gem_params| + puts "DEBUG: gem #{([gem_name.inspect] + gem_params.map(&:inspect)).join(', ')}" end end group :development do - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "deep_merge", '~> 1.2.2', require: false gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 2.1', require: false + gem "facterdb", '~> 2.1', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "facterdb", '~> 3.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "metadata-json-lint", '~> 4.0', require: false - gem "rspec-puppet-facts", '~> 4.0', require: false + gem "json-schema", '< 5.1.1', require: false + gem "rspec-puppet-facts", '~> 4.0', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "rspec-puppet-facts", '~> 5.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "dependency_checker", '~> 1.0.0', require: false gem "parallel_tests", '= 3.12.1', require: false gem "pry", '~> 0.10', require: false gem "simplecov-console", '~> 0.9', require: false - gem "puppet-debugger", '~> 1.0', require: false + gem "puppet-debugger", '~> 1.6', require: false gem "rubocop", '~> 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "rexml", '>= 3.3.9', require: false + gem "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw] end group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 7.0', require: false + gem "puppetlabs_spec_helper", '~> 8.0', require: false + gem "puppet-blacksmith", '~> 7.0', require: false end group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "puppet_litmus", '~> 2.0', require: false, platforms: [:ruby, :x64_mingw] if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty? + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] if ENV['PUPPET_FORGE_TOKEN'].to_s.empty? gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "serverspec", '~> 2.41', require: false end -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - gems = {} +puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil) +facter_version = ENV.fetch('FACTER_GEM_VERSION', nil) +hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil) -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables - -gems['facter'] = location_for(facter_version) if facter_version -gems['hiera'] = location_for(hiera_version) if hiera_version +gems['puppet'] = location_for(puppet_version, nil, { source: gemsource_puppetcore }) +gems['facter'] = location_for(facter_version, nil, { source: gemsource_puppetcore }) +gems['hiera'] = location_for(hiera_version, nil, {}) if hiera_version +# Generate the gem definitions +print_gem_statement_for(gems) if ENV['DEBUG'] gems.each do |gem_name, gem_params| gem gem_name, *gem_params end @@ -67,12 +88,14 @@ end # Evaluate Gemfile.local and ~/.gemfile if they exist extra_gemfiles = [ "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), + File.join(Dir.home, '.gemfile') ] extra_gemfiles.each do |gemfile| - if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) - end + next unless File.file?(gemfile) && File.readable?(gemfile) + + # rubocop:disable Security/Eval + eval(File.read(gemfile), binding) + # rubocop:enable Security/Eval end # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index 77590fe6..31b59305 100644 --- a/Rakefile +++ b/Rakefile @@ -7,3 +7,12 @@ require 'puppet-syntax/tasks/puppet-syntax' require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' PuppetLint.configuration.send('disable_relative') +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_autoloader_layout') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp"] + diff --git a/metadata.json b/metadata.json index 8a68ab79..b264a501 100644 --- a/metadata.json +++ b/metadata.json @@ -107,6 +107,6 @@ } ], "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", - "template-ref": "tags/3.2.0.4-0-g5d17ec1", - "pdk-version": "3.2.0" + "template-ref": "heads/main-0-g9d5b193", + "pdk-version": "3.5.0" } From 64aaa08e20066b306118fc55bf80a985fb558a57 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Thu, 28 Aug 2025 09:58:27 +0100 Subject: [PATCH 3/5] Rubocop safe autocorrections --- lib/puppet/functions/inifile/create_ini_settings.rb | 2 +- lib/puppet/provider/ini_setting/ruby.rb | 2 +- lib/puppet/type/ini_setting.rb | 2 +- lib/puppet/type/ini_subsetting.rb | 2 +- lib/puppet/util/ini_file.rb | 8 ++++---- spec/unit/puppet/provider/ini_setting/ruby_spec.rb | 2 +- spec/unit/puppet/type/ini_setting_spec.rb | 2 +- spec/unit/puppet/type/ini_subetting_spec.rb | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/puppet/functions/inifile/create_ini_settings.rb b/lib/puppet/functions/inifile/create_ini_settings.rb index 3ddd2621..54440f88 100644 --- a/lib/puppet/functions/inifile/create_ini_settings.rb +++ b/lib/puppet/functions/inifile/create_ini_settings.rb @@ -15,7 +15,7 @@ def default_impl(settings, defaults = {}) resources = settings.keys.each_with_object({}) do |section, res| unless settings[section].is_a?(Hash) raise(Puppet::ParseError, - _('create_ini_settings(): Section %{section} must contain a Hash') % { section: section }) + _('create_ini_settings(): Section %{section} must contain a Hash') % { section: }) end path = defaults.merge(settings)['path'] diff --git a/lib/puppet/provider/ini_setting/ruby.rb b/lib/puppet/provider/ini_setting/ruby.rb index c3a1f663..81aca581 100644 --- a/lib/puppet/provider/ini_setting/ruby.rb +++ b/lib/puppet/provider/ini_setting/ruby.rb @@ -19,7 +19,7 @@ def self.instances resources.push( new( name: namevar(section_name, setting), - value: value, + value:, ensure: :present, ), ) diff --git a/lib/puppet/type/ini_setting.rb b/lib/puppet/type/ini_setting.rb index 53cd5c22..f914367b 100644 --- a/lib/puppet/type/ini_setting.rb +++ b/lib/puppet/type/ini_setting.rb @@ -60,7 +60,7 @@ def munge_boolean_md5(value) newparam(:path) do desc 'The ini file Puppet will ensure contains the specified setting.' validate do |value| - raise(Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: value }) unless Puppet::Util.absolute_path?(value) + raise(Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: }) unless Puppet::Util.absolute_path?(value) end end diff --git a/lib/puppet/type/ini_subsetting.rb b/lib/puppet/type/ini_subsetting.rb index 184c4613..a639ce2d 100644 --- a/lib/puppet/type/ini_subsetting.rb +++ b/lib/puppet/type/ini_subsetting.rb @@ -52,7 +52,7 @@ def munge_boolean_md5(value) newparam(:path) do desc 'The ini file Puppet will ensure contains the specified setting.' validate do |value| - raise(Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: value }) unless Puppet::Util.absolute_path?(value) + raise(Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: }) unless Puppet::Util.absolute_path?(value) end end newparam(:show_diff) do diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb index 3acbf7a4..a4ae7b66 100644 --- a/lib/puppet/util/ini_file.rb +++ b/lib/puppet/util/ini_file.rb @@ -68,9 +68,9 @@ def set_value(*args) end complete_setting = { - setting: setting, - separator: separator, - value: value + setting:, + separator:, + value: } add_section(Section.new(section_name, nil, nil, nil, nil)) unless @sections_hash.key?(section_name) @@ -294,7 +294,7 @@ def find_commented_setting(section, setting) (section.start_line..section.end_line).each do |line_num| next unless (match = @commented_setting_regex.match(lines[line_num])) - return { match: match, line_num: line_num } if match[3] == setting + return { match:, line_num: } if match[3] == setting end nil end diff --git a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb index ef7da0eb..3dc220a3 100644 --- a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb +++ b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb @@ -721,7 +721,7 @@ def self.file_path expected = orig_content { 'section' => { 'first' => 1 } }.each_pair do |section, settings| settings.each_pair do |setting, value| - resource = Puppet::Type::Ini_setting.new(common_params.merge(section: section, setting: setting, value: value)) + resource = Puppet::Type::Ini_setting.new(common_params.merge(section:, setting:, value:)) provider = described_class.new(resource) expect(provider.exists?).to be false # byebug diff --git a/spec/unit/puppet/type/ini_setting_spec.rb b/spec/unit/puppet/type/ini_setting_spec.rb index 89923565..f7ccc159 100644 --- a/spec/unit/puppet/type/ini_setting_spec.rb +++ b/spec/unit/puppet/type/ini_setting_spec.rb @@ -6,7 +6,7 @@ describe ini_setting do describe 'path validation' do - subject(:ini_setting_path) { described_class.new(name: 'foo', path: path) } + subject(:ini_setting_path) { described_class.new(name: 'foo', path:) } context 'when on posix platforms' do before(:each) do diff --git a/spec/unit/puppet/type/ini_subetting_spec.rb b/spec/unit/puppet/type/ini_subetting_spec.rb index 9638ceae..4eb5ca2a 100644 --- a/spec/unit/puppet/type/ini_subetting_spec.rb +++ b/spec/unit/puppet/type/ini_subetting_spec.rb @@ -6,7 +6,7 @@ describe ini_subsetting do describe 'quote_char validation' do - subject(:ini_subsetting_test) { described_class.new(name: 'foo', path: path, quote_char: quote_char) } + subject(:ini_subsetting_test) { described_class.new(name: 'foo', path:, quote_char:) } context 'when on posix platforms' do let(:path) { '/absolute/path' } @@ -17,7 +17,7 @@ end describe 'path validation' do - subject(:ini_subsetting_test) { described_class.new(name: 'foo', path: path) } + subject(:ini_subsetting_test) { described_class.new(name: 'foo', path:) } context 'when on posix platforms' do before(:each) do From a86fe9fca54fd09565672d8d20fef10389bb56ba Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Thu, 28 Aug 2025 11:16:00 +0100 Subject: [PATCH 4/5] test against nightly --- .github/workflows/ci.yml | 2 ++ .github/workflows/nightly.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5738adb..2cdfc30f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,4 +14,6 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + with: + flags: "--nightly" secrets: "inherit" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1b06c471..5a39a47c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -13,4 +13,6 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + with: + flags: "--nightly" secrets: "inherit" From cedc2fa890da156f6bea638838087627a95a38d4 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Thu, 28 Aug 2025 11:28:30 +0100 Subject: [PATCH 5/5] remove outdated pin --- .fixtures.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index b24c2b1c..3048cf8f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -10,5 +10,4 @@ fixtures: facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' puppet_agent: repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - ref: v4.21.0 provision: 'https://github.com/puppetlabs/provision.git'