diff --git a/.github/workflows/static_code_analysis.yaml b/.github/workflows/static_code_analysis.yaml index 9ce89e1..c3be2ce 100644 --- a/.github/workflows/static_code_analysis.yaml +++ b/.github/workflows/static_code_analysis.yaml @@ -10,5 +10,5 @@ on: jobs: static_code_analysis: - uses: "puppetlabs/phoenix-github-actions/.github/workflows/static_code_analysis.yaml@main" + uses: "puppetlabs/phoenix-github-actions/.github/workflows/static_code_analysis.yaml@set-forge-token-globally" secrets: inherit diff --git a/.gitignore b/.gitignore index 3f15512..2803e56 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,3 +27,9 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.pdkignore b/.pdkignore index 862847a..84684be 100644 --- a/.pdkignore +++ b/.pdkignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,6 +27,12 @@ .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 diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece..9e15c6e 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 5a9f758..01d4a7f 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 320511d..a250166 100644 --- a/Gemfile +++ b/Gemfile @@ -1,79 +1,95 @@ -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.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 "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "serverspec", '~> 2.41', require: false - gem "voxpupuli-acceptance", require: false + 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", '~> 3.2', 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) -# 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 @@ -81,12 +97,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 41f5ec8..2138a1f 100644 --- a/Rakefile +++ b/Rakefile @@ -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"] + diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index 56daf92..5fab569 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -88,7 +88,7 @@ def parse_commands(data) sc = StringScanner.new(line) cmd = sc.scan(%r{\w+|==|!=}) formals = COMMANDS[cmd] - raise(_('Unknown command %{cmd}') % { cmd: cmd }) unless formals + raise(_('Unknown command %{cmd}') % { cmd: }) unless formals argline << cmd narg = 0 formals.each do |f| @@ -112,7 +112,7 @@ def parse_commands(data) len = sc.pos - start len -= 1 unless sc.eos? p = sc.string[start, len] - raise(_('missing path argument %{narg} for %{cmd}') % { narg: narg, cmd: cmd }) if p.nil? + raise(_('missing path argument %{narg} for %{cmd}') % { narg:, cmd: }) if p.nil? # Rip off any ticks if they are there. p = p[1, (p.size - 2)] if p[0, 1] == "'" || p[0, 1] == '"' @@ -138,12 +138,12 @@ def parse_commands(data) else argline << sc.scan(%r{[^\s]+}) end - raise(_('missing string argument %{narg} for %{cmd}') % { narg: narg, cmd: cmd }) unless argline[-1] + raise(_('missing string argument %{narg} for %{cmd}') % { narg:, cmd: }) unless argline[-1] elsif f == :comparator argline << sc.scan(%r{(==|!=|=~|<=|>=|<|>)}) unless argline[-1] puts sc.rest - raise(_('invalid comparator for command %{cmd}') % { cmd: cmd }) + raise(_('invalid comparator for command %{cmd}') % { cmd: }) end elsif f == :int argline << sc.scan(%r{\d+}).to_i @@ -270,7 +270,7 @@ def process_values(cmd_array) # Get the match paths from augeas result = @aug.match(path) || [] - raise(_("Error trying to get path '%{path}'") % { path: path }) if result == -1 + raise(_("Error trying to get path '%{path}'") % { path: }) if result == -1 # Get the values of the match paths from augeas values = result.map { |r| @aug.get(r) } @@ -318,7 +318,7 @@ def process_match(cmd_array) # Get the values from augeas result = @aug.match(path) || [] - raise(_("Error trying to match path '%{path}'") % { path: path }) if result == -1 + raise(_("Error trying to match path '%{path}'") % { path: }) if result == -1 # Now do the work case verb @@ -440,7 +440,7 @@ def need_to_run? when 'match' then return_value = process_match(cmd_array) end rescue StandardError => e - raise(_("Error sending command '%{command}' with params %{param}/%{message}") % { command: command, param: cmd_array[1..-1].inspect, message: e.message }) + raise(_("Error sending command '%{command}' with params %{param}/%{message}") % { command:, param: cmd_array[1..-1].inspect, message: e.message }) end end @@ -518,37 +518,37 @@ def do_execute_changes when 'set' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.set(cmd_array[0], cmd_array[1]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) unless rv when 'setm' if aug.respond_to?(command) debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.setm(cmd_array[0], cmd_array[1], cmd_array[2]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) if rv == -1 else - raise(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: command }) + raise(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: }) end when 'rm', 'remove' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.rm(cmd_array[0]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) if rv == -1 when 'clear' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.clear(cmd_array[0]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) unless rv when 'clearm' # Check command exists ... doesn't currently in ruby-augeas 0.4.1 if aug.respond_to?(command) debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.clearm(cmd_array[0], cmd_array[1]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) unless rv else - raise(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: command }) + raise(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: }) end when 'touch' debug("sending command '#{command}' (match, set) with params #{cmd_array.inspect}") if aug.match(cmd_array[0]).empty? rv = aug.clear(cmd_array[0]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) unless rv end when 'insert', 'ins' label = cmd_array[0] @@ -557,31 +557,31 @@ def do_execute_changes case where when 'before' then before = true when 'after' then before = false - else raise(_("Invalid value '%{where}' for where param") % { where: where }) + else raise(_("Invalid value '%{where}' for where param") % { where: }) end debug("sending command '#{command}' with params #{[label, where, path].inspect}") rv = aug.insert(path, label, before) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) if rv == -1 when 'defvar' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.defvar(cmd_array[0], cmd_array[1]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) unless rv when 'defnode' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.defnode(cmd_array[0], cmd_array[1], cmd_array[2]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) unless rv when 'mv', 'move' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.mv(cmd_array[0], cmd_array[1]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) if rv == -1 when 'rename' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.rename(cmd_array[0], cmd_array[1]) - raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 - else raise(_("Command '%{command}' is not supported") % { command: command }) + raise(_("Error sending command '%{command}' with params %{params}") % { command:, params: cmd_array.inspect }) if rv == -1 + else raise(_("Command '%{command}' is not supported") % { command: }) end rescue StandardError => e - raise(_("Error sending command '%{command}' with params %{params}/%{message}") % { command: command, params: cmd_array.inspect, message: e.message }) + raise(_("Error sending command '%{command}' with params %{params}/%{message}") % { command:, params: cmd_array.inspect, message: e.message }) end end end diff --git a/lib/puppet_x/augeas/util/parser.rb b/lib/puppet_x/augeas/util/parser.rb index e20070c..33b172c 100644 --- a/lib/puppet_x/augeas/util/parser.rb +++ b/lib/puppet_x/augeas/util/parser.rb @@ -8,22 +8,22 @@ module PuppetX::Augeas::Util; end # Container for helpers to parse user provided data contained in manifests. module PuppetX::Augeas::Util::Parser - TOKEN_ARRAY_CLOSE = %r{\s*\]\s*}.freeze - TOKEN_ARRAY_OPEN = %r{\s*\[\s*}.freeze - TOKEN_ARRAY_SEPARATOR = %r{\s*,\s*}.freeze - TOKEN_CLOSE_CURLY = %r|}|.freeze - TOKEN_DOUBLE_QUOTE = %r{"}.freeze - TOKEN_DOUBLE_QUOTE_ESCAPED_CHAR = %r{\\(["\\abtnvfres0-7xu])}.freeze - TOKEN_DOUBLE_QUOTE_UNESCAPED_CHAR = %r{[^"\\]}.freeze - TOKEN_HEX_CHAR = %r{[0-9a-fA-F]{1,2}}.freeze - TOKEN_OCTAL_CHAR = %r{[0-7]{1,3}}.freeze - TOKEN_OPEN_CURLY = %r|{|.freeze - TOKEN_SINGLE_QUOTE = %r{'}.freeze - TOKEN_SINGLE_QUOTE_ESCAPED_CHAR = %r{\\(['\\])}.freeze - TOKEN_SINGLE_QUOTE_UNESCAPED_CHAR = %r{[^'\\]}.freeze - TOKEN_SPACE = %r{\s}.freeze - TOKEN_UNICODE_LONG_HEX_CHAR = %r{[0-9a-fA-F]{1,6}}.freeze - TOKEN_UNICODE_SHORT_HEX_CHAR = %r{[0-9a-fA-F]{4}}.freeze + TOKEN_ARRAY_CLOSE = %r{\s*\]\s*} + TOKEN_ARRAY_OPEN = %r{\s*\[\s*} + TOKEN_ARRAY_SEPARATOR = %r{\s*,\s*} + TOKEN_CLOSE_CURLY = %r|}| + TOKEN_DOUBLE_QUOTE = %r{"} + TOKEN_DOUBLE_QUOTE_ESCAPED_CHAR = %r{\\(["\\abtnvfres0-7xu])} + TOKEN_DOUBLE_QUOTE_UNESCAPED_CHAR = %r{[^"\\]} + TOKEN_HEX_CHAR = %r{[0-9a-fA-F]{1,2}} + TOKEN_OCTAL_CHAR = %r{[0-7]{1,3}} + TOKEN_OPEN_CURLY = %r|{| + TOKEN_SINGLE_QUOTE = %r{'} + TOKEN_SINGLE_QUOTE_ESCAPED_CHAR = %r{\\(['\\])} + TOKEN_SINGLE_QUOTE_UNESCAPED_CHAR = %r{[^'\\]} + TOKEN_SPACE = %r{\s} + TOKEN_UNICODE_LONG_HEX_CHAR = %r{[0-9a-fA-F]{1,6}} + TOKEN_UNICODE_SHORT_HEX_CHAR = %r{[0-9a-fA-F]{4}} # Parse a string into the (nearly) equivalent Ruby array. This only handles # arrays with string members (double-, or single-quoted), and does not diff --git a/metadata.json b/metadata.json index 638a3fd..a71c196 100644 --- a/metadata.json +++ b/metadata.json @@ -54,7 +54,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" } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 04d511d..6d6dcd5 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -53,7 +53,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' diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb index 4750e7e..5814c05 100644 --- a/spec/unit/provider/augeas/augeas_spec.rb +++ b/spec/unit/provider/augeas/augeas_spec.rb @@ -1046,6 +1046,9 @@ def make_tmpname((prefix, suffix), n) end it "alsoes load lenses from pluginsync'd path" do + # Puppet must be in agent mode for this test to successfully + # complete + allow(Puppet).to receive(:run_mode).and_return(Puppet::Util::UnixRunMode.new(:agent)) Puppet[:libdir] = my_fixture_dir aug = provider.open_augeas diff --git a/spec/unit/type/augeas_spec.rb b/spec/unit/type/augeas_spec.rb index f397d74..fd82287 100644 --- a/spec/unit/type/augeas_spec.rb +++ b/spec/unit/type/augeas_spec.rb @@ -86,15 +86,15 @@ describe 'provider interaction' do it 'returns 0 if it does not need to run' do provider = instance_double('Puppet::Provider::Augeas', need_to_run?: false) - resource = instance_double('Puppet::Type::Augeas', provider: provider, line: nil, file: nil) - changes = augeas.attrclass(:returns).new(resource: resource) + resource = instance_double('Puppet::Type::Augeas', provider:, line: nil, file: nil) + changes = augeas.attrclass(:returns).new(resource:) expect(changes.retrieve).to eq(0) end it 'returns :need_to_run if it needs to run' do provider = instance_double('Puppet::Provider::Augeas', need_to_run?: true) - resource = instance_double('Puppet::Type::Augeas', provider: provider, line: nil, file: nil) - changes = augeas.attrclass(:returns).new(resource: resource) + resource = instance_double('Puppet::Type::Augeas', provider:, line: nil, file: nil) + changes = augeas.attrclass(:returns).new(resource:) expect(changes.retrieve).to eq(:need_to_run) end end