Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@
/spec/fixtures/modules/*
/tmp/
/vendor/
/.vendor/
/convert_report.txt
/update_report.txt
.DS_Store
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
.resource_types
.modules
.task_cache.json
.plan_cache.json
.rerun.json
bolt-debug.log
7 changes: 7 additions & 0 deletions .pdkignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@
/spec/fixtures/modules/*
/tmp/
/vendor/
/.vendor/
/convert_report.txt
/update_report.txt
.DS_Store
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
.resource_types
.modules
.task_cache.json
.plan_cache.json
.rerun.json
bolt-debug.log
/.fixtures.yml
/Gemfile
/.gitattributes
Expand Down
8 changes: 8 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require:
AllCops:
NewCops: enable
DisplayCopNames: true
TargetRubyVersion: '2.6'
TargetRubyVersion: 3.1
Include:
- "**/*.rb"
Exclude:
Expand Down
118 changes: 70 additions & 48 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,79 @@
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(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
# 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(?<url>(?:https?|git)[:@][^#]*)(?:#(?<branch>.*))?/
file_url_regex = %r{\Afile://(?<path>.*)}

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.0', require: false
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
gem "facterdb", '~> 1.18', require: false
gem "metadata-json-lint", '~> 4.0', require: false
gem "rspec-puppet-facts", '~> 3.0', require: false
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 "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 "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 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 "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.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 "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 6.0')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 1.0')
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || '~> 2')
gem "beaker-rspec"
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 4.0') if Gem::Requirement.create('< 3.2.0').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "async", '~> 1', require: false
gem "beaker-module_install_helper", require: false
gem "nokogiri", require: false
gem "async", '~> 1', require: false
gem "beaker-module_install_helper", require: false
gem "nokogiri", require: false
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", '~> 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
gem "voxpupuli-acceptance", require: false
Expand All @@ -58,31 +84,27 @@ puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil)
facter_version = ENV.fetch('FACTER_GEM_VERSION', nil)
hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil)

# 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['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

# 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
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'
require 'voxpupuli/acceptance/rake' if Gem.loaded_specs.key? 'voxpupuli-acceptance'

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"]

4 changes: 2 additions & 2 deletions lib/puppet/provider/mount/parsed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ def self.mountinstances
end
mount_output.each do |line|
if (match = regex.match(line)) && (name = match.captures.first)
instances << { name: name, mounted: :yes } # Only :name is important here
instances << { name:, mounted: :yes } # Only :name is important here
else
raise Puppet::Error, _('Could not understand line %{line} from mount output') % { line: line }
raise Puppet::Error, _('Could not understand line %{line} from mount output') % ({ line: })
end
end
instances
Expand Down
10 changes: 5 additions & 5 deletions lib/puppet/type/mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def syncothers

validate do |value|
unless Facter.value(:kernel) == 'Linux'
raise Puppet::Error, _('device must not contain whitespace: %{value}') % { value: value } if %r{\s}.match?(value)
raise Puppet::Error, _('device must not contain whitespace: %{value}') % ({ value: }) if %r{\s}.match?(value)
end
end
end
Expand All @@ -159,7 +159,7 @@ def syncothers
end

validate do |value|
raise Puppet::Error, _('blockdevice must not contain whitespace: %{value}') % { value: value } if %r{\s}.match?(value)
raise Puppet::Error, _('blockdevice must not contain whitespace: %{value}') % ({ value: }) if %r{\s}.match?(value)
end
end

Expand All @@ -168,7 +168,7 @@ def syncothers
operating system. This is a required option."

validate do |value|
raise Puppet::Error, _('fstype must not contain whitespace: %{value}') % { value: value } if %r{\s}.match?(value)
raise Puppet::Error, _('fstype must not contain whitespace: %{value}') % ({ value: }) if %r{\s}.match?(value)
raise Puppet::Error, _('fstype must not be an empty string') if value.empty?
end
end
Expand All @@ -183,7 +183,7 @@ def syncothers
the list."

validate do |value|
raise Puppet::Error, _('options must not contain whitespace: %{value}') % { value: value } if %r{\s}.match?(value)
raise Puppet::Error, _('options must not contain whitespace: %{value}') % ({ value: }) if %r{\s}.match?(value)
raise Puppet::Error, _('options must not be an empty string') if value.empty?
end
end
Expand Down Expand Up @@ -251,7 +251,7 @@ def munge(value)

validate do |value|
unless Facter.value(:kernel) == 'Linux'
raise Puppet::Error, _('name must not contain whitespace: %{value}') % { value: value } if %r{\s}.match?(value)
raise Puppet::Error, _('name must not contain whitespace: %{value}') % ({ value: }) if %r{\s}.match?(value)
end
end

Expand Down
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"version_requirement": ">= 6.0.0 < 9.0.0"
}
],
"pdk-version": "3.2.0",
"template-url": "https://github.com/puppetlabs/pdk-templates#3.2.0",
"template-ref": "tags/3.2.0-0-gb257ef1"
"pdk-version": "3.5.1",
"template-url": "https://github.com/puppetlabs/pdk-templates#3.5.1",
"template-ref": "tags/3.5.1-0-g9d5b193"
}
2 changes: 1 addition & 1 deletion spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def run_puppet_install_helper

agent_sha = ENV['BEAKER_PUPPET_AGENT_SHA'] || ENV['PUPPET_AGENT_SHA']
if agent_sha.nil? || agent_sha.empty?
install_puppet_agent_on(hosts, options.merge(version: version))
install_puppet_agent_on(hosts, options.merge(version:))
else
# If we have a development sha, assume we're testing internally
dev_builds_url = ENV['DEV_BUILDS_URL'] || 'http://builds.delivery.puppetlabs.net'
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/type/mount_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
end

let :resource do
described_class.new(name: 'yay', audit: :ensure, provider: provider)
described_class.new(name: 'yay', audit: :ensure, provider:)
end

let :ensureprop do
Expand Down Expand Up @@ -466,7 +466,7 @@
end

describe 'when responding to refresh' do
pending '2.6.x specifies slightly different behavior and the desired behavior needs to be clarified and revisited. See ticket #4904' do

Check warning on line 469 in spec/unit/type/mount_spec.rb

View workflow job for this annotation

GitHub Actions / Released / Puppet8 gem on Ruby 3.1 on macOS

Puppet::Type::Mount when responding to refresh 2.6.x specifies slightly different behavior and the desired behavior needs to be clarified and revisited. See ticket #4904 Failure/Error: it 'remounts if it is supposed to be mounted' do resource[:ensure] = 'mounted' expect(provider).to receive(:remount) resource.refresh end `it` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block). raise WrongScopeError, ^^^^^

Check warning on line 469 in spec/unit/type/mount_spec.rb

View workflow job for this annotation

GitHub Actions / Released / Puppet8 gem on Ruby 3.1 on Linux

Puppet::Type::Mount when responding to refresh 2.6.x specifies slightly different behavior and the desired behavior needs to be clarified and revisited. See ticket #4904 Failure/Error: it 'remounts if it is supposed to be mounted' do resource[:ensure] = 'mounted' expect(provider).to receive(:remount) resource.refresh end `it` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block). raise WrongScopeError, ^^^^^

Check warning on line 469 in spec/unit/type/mount_spec.rb

View workflow job for this annotation

GitHub Actions / Nightly / Puppet8 gem on Ruby 3.1 on Linux

Puppet::Type::Mount when responding to refresh 2.6.x specifies slightly different behavior and the desired behavior needs to be clarified and revisited. See ticket #4904 Failure/Error: it 'remounts if it is supposed to be mounted' do resource[:ensure] = 'mounted' expect(provider).to receive(:remount) resource.refresh end `it` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block). raise WrongScopeError, ^^^^^
it 'remounts if it is supposed to be mounted' do
resource[:ensure] = 'mounted'
expect(provider).to receive(:remount)
Expand Down Expand Up @@ -528,7 +528,7 @@
end

let :resource do
described_class.new(initial_values.merge(provider: provider))
described_class.new(initial_values.merge(provider:))
end

let :provider do
Expand Down Expand Up @@ -577,8 +577,8 @@
def create_file_resource(path)
file_class = Puppet::Type.type(:file)
file_class.new(
path: path,
provider: file_class.new(path: path).provider,
path:,
provider: file_class.new(path:).provider,
)
end

Expand Down
Loading