From c4a0d9f2f6a590a44c63c5377e02a16a3f30e545 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 17 Aug 2023 14:20:15 +0200 Subject: [PATCH 1/2] modulesync 7.0.0 --- .github/CONTRIBUTING.md | 11 +++++++---- .msync.yml | 2 +- Gemfile | 2 +- spec/spec_helper.rb | 1 + spec/spec_helper_acceptance.rb | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8b466cfb..6aaa603f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -232,18 +232,21 @@ simple tests against it after applying the module. You can run this with: ```sh -BEAKER_setfile=debian11-64 bundle exec rake beaker +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker ``` -You can replace the string `debian10` with any common operating system. +You can replace the string `debian11` with any common operating system. The following strings are known to work: -* ubuntu1804 * ubuntu2004 -* debian10 +* ubuntu2204 * debian11 * centos7 * centos8 +* centos9 +* almalinux8 +* almalinux9 +* fedora36 For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). diff --git a/.msync.yml b/.msync.yml index b929160c..dd3e9572 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '6.0.0' +modulesync_config_version: '7.0.0' diff --git a/Gemfile b/Gemfile index 98a04cfb..db21d3b5 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 6.0', :require => false + gem 'voxpupuli-test', '~> 7.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 3.0', :require => false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6542249a..7954b88f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,3 +19,4 @@ end Dir['./spec/support/**/*.rb'].sort.each { |f| require f } +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d3a6e23c..2681792e 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -5,6 +5,6 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' -configure_beaker +configure_beaker(modules: :metadata) Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } From 3296b7abeba2079901d98577c48352bf16f0a0d3 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 17 Aug 2023 23:54:04 +0200 Subject: [PATCH 2/2] rubocop: autofix --- .rubocop.yml | 2 ++ .rubocop_todo.yml | 20 +++++++++++++++++++ lib/puppet/type/archive.rb | 6 +++--- lib/puppet_x/bodeco/archive.rb | 2 +- lib/puppet_x/bodeco/util.rb | 2 +- spec/functions/archive_go_md5_spec.rb | 2 +- .../unit/puppet/provider/archive/curl_spec.rb | 2 +- spec/unit/puppet/provider/archive/gs_spec.rb | 2 +- .../unit/puppet/provider/archive/ruby_spec.rb | 2 +- 9 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 53ac1898..ea22bff8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ --- +inherit_from: .rubocop_todo.yml + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..14315837 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,20 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-08-17 21:26:09 UTC using RuboCop version 1.50.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/NonAtomicFileOperation: + Exclude: + - 'lib/puppet/provider/archive/ruby.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowComments. +Style/RedundantInitialize: + Exclude: + - 'lib/puppet_x/bodeco/util.rb' diff --git a/lib/puppet/type/archive.rb b/lib/puppet/type/archive.rb index f2e7855d..6535e86b 100644 --- a/lib/puppet/type/archive.rb +++ b/lib/puppet/type/archive.rb @@ -208,7 +208,7 @@ def should_to_s(value) desc 'optional header(s) to pass.' validate do |val| - raise ArgumentError, "headers must be an array: #{val}" unless val.is_a?(::Array) + raise ArgumentError, "headers must be an array: #{val}" unless val.is_a?(Array) end end @@ -238,12 +238,12 @@ def should_to_s(value) desc 'provider download options (affects curl, wget, gs, and only s3 downloads for ruby provider)' validate do |val| - raise ArgumentError, "download_options should be String or Array: #{val}" unless val.is_a?(::String) || val.is_a?(::Array) + raise ArgumentError, "download_options should be String or Array: #{val}" unless val.is_a?(String) || val.is_a?(Array) end munge do |val| case val - when ::String + when String [val] else val diff --git a/lib/puppet_x/bodeco/archive.rb b/lib/puppet_x/bodeco/archive.rb index 83d39762..f61fa51c 100644 --- a/lib/puppet_x/bodeco/archive.rb +++ b/lib/puppet_x/bodeco/archive.rb @@ -79,7 +79,7 @@ def win_7zip Add-Type -AssemblyName System.IO.Compression.FileSystem -erroraction "silentlycontinue" $zipFile = [System.IO.Compression.ZipFile]::openread(#{@file_path}) foreach ($zipFileEntry in $zipFile.Entries) { - $pwd = (Get-Item -Path ".\" -Verbose).FullName + $pwd = (Get-Item -Path "." -Verbose).FullName $outputFile = [io.path]::combine($pwd, $zipFileEntry.FullName) $dir = ([io.fileinfo]$outputFile).DirectoryName diff --git a/lib/puppet_x/bodeco/util.rb b/lib/puppet_x/bodeco/util.rb index a4b1508d..b1cda769 100644 --- a/lib/puppet_x/bodeco/util.rb +++ b/lib/puppet_x/bodeco/util.rb @@ -33,7 +33,7 @@ def self.puppet_download(url, filepath) status = load_file_with_any_terminus(url) raise ArgumentError, "Previous error(s) resulted in Puppet being unable to retrieve information from environment #{Puppet['environment']} source(s) #{url}'\nMost probable cause is file not found." unless status - File.open(filepath, 'wb') { |file| file.write(status.content) } + File.binwrite(filepath, status.content) end # @private diff --git a/spec/functions/archive_go_md5_spec.rb b/spec/functions/archive_go_md5_spec.rb index 26e055b6..3822c8b5 100644 --- a/spec/functions/archive_go_md5_spec.rb +++ b/spec/functions/archive_go_md5_spec.rb @@ -17,7 +17,7 @@ context 'when file doesn\'t exist' do it 'raises error' do allow(PuppetX::Bodeco::Util).to receive(:content).with(uri, username: 'user', password: 'pass').and_return(example_md5) - expect(subject).to run.with_params('user', 'pass', 'non-existent-file', url).and_raise_error(RuntimeError, "Could not parse md5 from url https://gocd\.lan/path/file\.md5 response: #{example_md5}") + expect(subject).to run.with_params('user', 'pass', 'non-existent-file', url).and_raise_error(RuntimeError, "Could not parse md5 from url https://gocd.lan/path/file.md5 response: #{example_md5}") end end end diff --git a/spec/unit/puppet/provider/archive/curl_spec.rb b/spec/unit/puppet/provider/archive/curl_spec.rb index 6638b410..b7d9e88b 100644 --- a/spec/unit/puppet/provider/archive/curl_spec.rb +++ b/spec/unit/puppet/provider/archive/curl_spec.rb @@ -58,7 +58,7 @@ it 'populates temp netrc file with credentials' do allow(provider).to receive(:delete_netrcfile) # Don't delete the file or we won't be able to examine its contents. provider.download(name) - nettc_content = File.open(tempfile.path).read + nettc_content = File.read(tempfile.path) expect(nettc_content).to eq("machine home.lan\nlogin foo\npassword bar\n") end diff --git a/spec/unit/puppet/provider/archive/gs_spec.rb b/spec/unit/puppet/provider/archive/gs_spec.rb index ede17f9d..3a629789 100644 --- a/spec/unit/puppet/provider/archive/gs_spec.rb +++ b/spec/unit/puppet/provider/archive/gs_spec.rb @@ -46,7 +46,7 @@ before do resource[:checksum_url] = url if url - allow(PuppetX::Bodeco::Util).to receive(:content).\ + allow(PuppetX::Bodeco::Util).to receive(:content). \ with(url, any_args).and_return(remote_hash) end diff --git a/spec/unit/puppet/provider/archive/ruby_spec.rb b/spec/unit/puppet/provider/archive/ruby_spec.rb index c537576a..532f4b7a 100644 --- a/spec/unit/puppet/provider/archive/ruby_spec.rb +++ b/spec/unit/puppet/provider/archive/ruby_spec.rb @@ -46,7 +46,7 @@ before do resource[:checksum_url] = url if url - allow(PuppetX::Bodeco::Util).to receive(:content).\ + allow(PuppetX::Bodeco::Util).to receive(:content). \ with(url, any_args).and_return(remote_hash) end