diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93cd3406b7..046aaccb93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,4 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" - with: - runs_on: "ubuntu-24.04" secrets: "inherit" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c6539f7e37..c3d6729772 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -15,6 +15,4 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" - with: - runs_on: "ubuntu-24.04" secrets: "inherit" diff --git a/.puppet-lint.rc b/.puppet-lint.rc index f01626d456..e7fe02efc3 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,3 +1,11 @@ +--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 --no-anchor_resource-check --no-params_empty_string_assignment-check diff --git a/.rubocop.yml b/.rubocop.yml index 439ea84ee8..47b1aadbe6 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 7a1566ddb4..58203d2ece 100644 --- a/Gemfile +++ b/Gemfile @@ -14,22 +14,22 @@ def location_for(place_or_version, fake_version = nil) 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", '~> 1.18', 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", '~> 2.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 @@ -38,26 +38,32 @@ group :development do 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 +# If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet +# Otherwise, do as before and use location_for to fetch gems from the default source +if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty? + gems['puppet'] = ['~> 8.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }] + gems['facter'] = ['~> 4.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }] +else + gems['puppet'] = location_for(puppet_version) + gems['facter'] = location_for(facter_version) if facter_version +end -gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version gems.each do |gem_name, gem_params| diff --git a/Rakefile b/Rakefile index 32f4fa9e14..e5ee87d8b5 100644 --- a/Rakefile +++ b/Rakefile @@ -9,3 +9,11 @@ require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' PuppetLint.configuration.send('disable_relative') PuppetLint.configuration.send('disable_anchor_resource') PuppetLint.configuration.send('disable_params_empty_string_assignment') +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/lib/puppet/functions/postgresql/postgresql_password.rb b/lib/puppet/functions/postgresql/postgresql_password.rb index a444d5cd01..13b43a5bb6 100644 --- a/lib/puppet/functions/postgresql/postgresql_password.rb +++ b/lib/puppet/functions/postgresql/postgresql_password.rb @@ -65,7 +65,7 @@ def pg_sha256(password, salt) def digest_key(password, salt) OpenSSL::KDF.pbkdf2_hmac( password, - salt: salt, + salt:, iterations: 4096, length: 32, hash: OpenSSL::Digest.new('SHA256'), diff --git a/lib/puppet/provider/postgresql_conf/ruby.rb b/lib/puppet/provider/postgresql_conf/ruby.rb index f21caf2b5c..c55988fdfa 100644 --- a/lib/puppet/provider/postgresql_conf/ruby.rb +++ b/lib/puppet/provider/postgresql_conf/ruby.rb @@ -29,7 +29,7 @@ def parse_config else matches[:value].delete("'") end - attributes_hash = { line_number: line_number, key: matches[:key], ensure: 'present', value: value, comment: matches[:comment] } + attributes_hash = { line_number:, key: matches[:key], ensure: 'present', value:, comment: matches[:comment] } active_settings.push(attributes_hash) end end diff --git a/lib/puppet/provider/postgresql_replication_slot/ruby.rb b/lib/puppet/provider/postgresql_replication_slot/ruby.rb index 31271cc51b..257de341a3 100644 --- a/lib/puppet/provider/postgresql_replication_slot/ruby.rb +++ b/lib/puppet/provider/postgresql_replication_slot/ruby.rb @@ -7,7 +7,7 @@ def self.instances run_sql_command('SELECT * FROM pg_replication_slots;')[0].split("\n").select { |l| l.include?('|') }.map do |l| name, *_others = l.strip.split(%r{\s+\|\s+}) - new(name: name, + new(name:, ensure: :present) end end diff --git a/metadata.json b/metadata.json index 552a48b38b..2584ff591b 100644 --- a/metadata.json +++ b/metadata.json @@ -98,10 +98,10 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 9.0.0" + "version_requirement": ">= 8.0.0 < 9.0.0" } ], - "pdk-version": "3.2.0", + "pdk-version": "3.5.0", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "tags/3.2.0.4-0-g5d17ec1" + "template-ref": "heads/main-0-g11c0f3d" } diff --git a/spec/defines/server/pg_hba_rule_spec.rb b/spec/defines/server/pg_hba_rule_spec.rb index 7d1187001c..302d2848e8 100644 --- a/spec/defines/server/pg_hba_rule_spec.rb +++ b/spec/defines/server/pg_hba_rule_spec.rb @@ -25,7 +25,7 @@ class { 'postgresql::server': } user: 'all', address: '1.1.1.1/24', auth_method: 'md5', - target: target + target: } end @@ -47,7 +47,7 @@ class { 'postgresql::server': } database: 'all', user: 'all', auth_method: 'ident', - target: target + target: } end @@ -71,7 +71,7 @@ class { 'postgresql::server': } address: '0.0.0.0/0', auth_method: 'ldap', auth_option: 'foo=bar', - target: target + target: } end @@ -98,7 +98,7 @@ class { 'postgresql::server': } user: 'all', address: '0.0.0.0/0', auth_method: 'peer', - target: target + target: } end @@ -126,7 +126,7 @@ class { 'postgresql::server': } user: 'all', address: '0.0.0.0/0', auth_method: 'scram-sha-256', - target: target + target: } end @@ -240,7 +240,7 @@ class { 'postgresql::server': } user: 'all', address: '.domain.tld', auth_method: 'md5', - target: target + target: } end @@ -263,7 +263,7 @@ class { 'postgresql::server': } user: 'all', address: '/45', auth_method: 'md5', - target: target + target: } end diff --git a/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb b/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb index 9f2c3b55e1..5e3c705547 100644 --- a/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb +++ b/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb @@ -5,7 +5,7 @@ describe Puppet::Type.type(:postgresql_psql).provider(:ruby) do let(:name) { 'rspec psql test' } let(:resource) do - Puppet::Type.type(:postgresql_psql).new({ name: name, provider: :ruby }.merge(attributes)) + Puppet::Type.type(:postgresql_psql).new({ name:, provider: :ruby }.merge(attributes)) end let(:provider) { resource.provider } diff --git a/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb b/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb index 032ceac752..676d783f18 100644 --- a/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb +++ b/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb @@ -20,7 +20,7 @@ def success? let(:name) { 'standby' } let(:resource) do - type.new({ name: name, provider: :ruby }.merge(attributes)) + type.new({ name:, provider: :ruby }.merge(attributes)) end let(:sql_instances) do "abc | | physical | | | t | | | 0/3000420 diff --git a/spec/unit/puppet/type/postgresql_psql_spec.rb b/spec/unit/puppet/type/postgresql_psql_spec.rb index 871645534d..ed8a3b1b4a 100644 --- a/spec/unit/puppet/type/postgresql_psql_spec.rb +++ b/spec/unit/puppet/type/postgresql_psql_spec.rb @@ -132,7 +132,7 @@ [true, :true].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly } + { refreshonly: } end context 'not refreshing' @@ -141,7 +141,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly } + { refreshonly: } end context 'refreshing' @@ -152,7 +152,7 @@ [false, :false].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly } + { refreshonly: } end context 'not refreshing' @@ -161,7 +161,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly } + { refreshonly: } end context 'refreshing' @@ -176,7 +176,7 @@ [true, :true].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly, unless: 'SELECT something' } + { refreshonly:, unless: 'SELECT something' } end context 'not refreshing' @@ -185,7 +185,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly, unless: 'SELECT something' } + { refreshonly:, unless: 'SELECT something' } end context 'refreshing' @@ -196,7 +196,7 @@ [false, :false].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly, unless: 'SELECT something' } + { refreshonly:, unless: 'SELECT something' } end context 'not refreshing' @@ -205,7 +205,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly, unless: 'SELECT something' } + { refreshonly:, unless: 'SELECT something' } end context 'refreshing' @@ -220,7 +220,7 @@ [true, :true].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly, unless: 'SELECT something' } + { refreshonly:, unless: 'SELECT something' } end context 'not refreshing' @@ -229,7 +229,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly, unless: 'SELECT something' } + { refreshonly:, unless: 'SELECT something' } end context 'refreshing' @@ -240,7 +240,7 @@ [false, :false].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly, unless: 'SELECT something' } + { refreshonly:, unless: 'SELECT something' } end context 'not refreshing' @@ -249,7 +249,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: refreshonly, unless: 'SELECT something' } + { refreshonly:, unless: 'SELECT something' } end context 'refreshing'