]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
rubocop fixes and pdk update convert_to_litmus
authorlionce <loredana.ionce@puppet.com>
Fri, 30 Aug 2019 11:40:06 +0000 (14:40 +0300)
committerlionce <loredana.ionce@puppet.com>
Wed, 11 Sep 2019 06:58:04 +0000 (09:58 +0300)
.rubocop.yml
.travis.yml
Gemfile
Rakefile
lib/puppet/provider/firewall/iptables.rb
metadata.json
spec/acceptance/firewall_attributes_exceptions_spec.rb
spec/acceptance/rules_spec.rb
spec/spec_helper_acceptance.rb
spec/spec_helper_acceptance_local.rb

index 3cd2b0e5a9770b6200f94ce58e8868cca049fd6f..8a9014f18afb0da256961d197e1e2741044067e8 100644 (file)
@@ -108,6 +108,8 @@ Metrics/ParameterLists:
   Enabled: false
 Metrics/PerceivedComplexity:
   Enabled: false
+Metrics/BlockNesting:
+  Enabled: false
 RSpec/DescribeClass:
   Enabled: false
 RSpec/ExampleLength:
index b6064dd0bc92fc60b03cf209d38409c4f2c8dcea..0b2378e38c1e0e6174aca8efa604271a6253f2ab 100644 (file)
@@ -1,5 +1,4 @@
 ---
-dist: xenial
 language: ruby
 cache: bundler
 before_install:
@@ -24,22 +23,33 @@ matrix:
   fast_finish: true
   include:
     -
-      bundler_args: 
+      bundler_args:
       dist: trusty
-      env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply
+      env: PLATFORMS=deb_puppet5
       rvm: 2.5.3
-      script: bundle exec rake beaker
+      before_script:
+      - bundle exec rake 'litmus:provision_list[travis_deb]'
+      - bundle exec bolt command run 'apt-get install wget -y' --inventoryfile inventory.yaml --nodes='localhost*'
+      - bundle exec rake 'litmus:install_agent[puppet5]'
+      - bundle exec rake litmus:install_module
+      script:
+      - bundle exec rake litmus:acceptance:parallel
       services: docker
       stage: acceptance
       sudo: required
     -
-      bundler_args: 
+      bundler_args:
       dist: trusty
-      env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply
+      env: PLATFORM=deb_puppet6
       rvm: 2.5.3
-      script: bundle exec rake beaker
+      before_script:
+      - bundle exec rake 'litmus:provision_list[travis_deb]'
+      - bundle exec bolt command run 'apt-get install wget -y' --inventoryfile inventory.yaml --nodes='localhost*'
+      - bundle exec rake 'litmus:install_agent[puppet6]'
+      - bundle exec rake litmus:install_module
+      script:
+      - bundle exec rake litmus:acceptance:parallel
       services: docker
-      stage: acceptance
       sudo: required
     -
       env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
diff --git a/Gemfile b/Gemfile
index 9c4c79b69a982fd4d2d657a3caeeb50520e81741..0e395e7ecbf02b49b6256e46126da8eac57527e3 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -30,10 +30,6 @@ group :development do
   gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3',       require: false, platforms: [:mswin, :mingw, :x64_mingw]
   gem "github_changelog_generator",                              require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')
 end
-group :system_tests do
-  gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
-  gem "puppet-module-win-system-r#{minor_version}",   require: false, platforms: [:mswin, :mingw, :x64_mingw]
-end
 
 puppet_version = ENV['PUPPET_GEM_VERSION']
 facter_version = ENV['FACTER_GEM_VERSION']
index d9b223c62a837547c1e819c7ea30ad3ef45a0ef7..395df547d4f278b6354fb15a14b32781e75a4e46 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -15,8 +15,17 @@ end
 
 def changelog_project
   return unless Rake.application.top_level_tasks.include? "changelog"
-  returnVal = nil || JSON.load(File.read('metadata.json'))['source'].match(%r{.*/([^/]*)})[1]
-  raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
+
+  returnVal = nil
+  returnVal ||= begin
+    metadata_source = JSON.load(File.read('metadata.json'))['source']
+    metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z})
+
+    metadata_source_match && metadata_source_match[1]
+  end
+
+  raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil?
+
   puts "GitHubChangelogGenerator project:#{returnVal}"
   returnVal
 end
index f3a334bde563c65a775ec6f63f2dc13f82c95c9c..f108b43ad8094e08473ce88e527a1e2c07d51305 100644 (file)
@@ -781,7 +781,6 @@ Puppet::Type.type(:firewall).provide :iptables, parent: Puppet::Provider::Firewa
         end
         if should_negate
           resource_value, wrong_values = resource_value.map { |value|
-            # rubocop:disable Metrics/BlockNesting
             if value.is_a?(String)
               wrong = value unless value =~ %r{^!\s+}
               [value.sub(%r{^!\s*}, ''), wrong]
index 5bc4ce9112b46d5bf5fd9e2231b33b819bab64c5..a763216d71e98252ed5fa4e6418dd588009ff404 100644 (file)
@@ -76,6 +76,6 @@
     }
   ],
   "template-url": "https://github.com/puppetlabs/pdk-templates#master",
-  "template-ref": "1.12.0-0-g55d9ae2",
-  "pdk-version": "1.12.0"
+  "template-ref": "tags/1.13.0-0-g66e1443",
+  "pdk-version": "1.13.0"
 }
index cf1bb105d00ff31933bb49b3e6bedc39cc0df586..12650bb664d22ebab09de09e430980e4e5ee950f 100644 (file)
@@ -357,8 +357,7 @@ describe 'firewall basics', docker: true do
     end
   end
 
-
-  describe 'nflog', unless: get_iptables_version < '1.3.7' do
+  describe 'nflog', unless: iptables_version < '1.3.7' do
     describe 'nflog_group' do
       it 'applies' do
         pp2 = <<-PUPPETCODE
@@ -451,7 +450,7 @@ describe 'firewall basics', docker: true do
     PUPPETCODE
     it 'throws an error' do
       res = apply_manifest(pp1, expect_failures: true)
-      expect(res[:exit_code]).to eql(0)
+      expect(res[:exit_code]).to be(0)
     end
   end
 
@@ -1131,7 +1130,7 @@ describe 'firewall basics', docker: true do
               }
         PUPPETCODE
         it "changes the value to #{value}" do
-          apply_manifest(pp1, catch_failures: true)
+          apply_manifest(pp1, catch_failures: true)
           apply_manifest(pp1, catch_changes: true)
 
           run_shell('iptables-save -t raw') do |r|
index ff86d119a39b8178319bf7d953681320e32a9de5..b8af79936fe4197ae024077e0a4b9e27c0e10c9d 100644 (file)
@@ -240,9 +240,8 @@ describe 'rules spec' do
     PUPPETCODE
     it 'applies cleanly' do
       # Run it twice and test for idempotency
-      r = apply_manifest(pp2, catch_failures: true, expect_failures: true)
-
-      r=apply_manifest(pp2, catch_changes: true, expect_failures: true)
+      apply_manifest(pp2, catch_failures: true, expect_failures: true)
+      apply_manifest(pp2, catch_changes: true, expect_failures: true)
     end
 
     regex_values = [
@@ -273,4 +272,4 @@ describe 'rules spec' do
       end
     end
   end
-end
\ No newline at end of file
+end
index 7a54362cdbd682a2f19a18ebb5c98510737b0671..8c423fbd36c46ef4bedd57b20bff2802071baea2 100644 (file)
@@ -28,26 +28,26 @@ else
     options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil?
 
     options[:verify_host_key] = if node_config.dig('ssh', 'host-key-check').nil?
-      # Fall back to SSH behavior. This variable will only be set in net-ssh 5.3+.
-      if @strict_host_key_checking.nil? || @strict_host_key_checking
-        Net::SSH::Verifiers::Always.new
-      else
-        # SSH's behavior with StrictHostKeyChecking=no: adds new keys to known_hosts.
-        # If known_hosts points to /dev/null, then equivalent to :never where it
-        # accepts any key beacuse they're all new.
-        Net::SSH::Verifiers::AcceptNewOrLocalTunnel.new
-      end
-    elsif node_config.dig('ssh', 'host-key-check')
-      if defined?(Net::SSH::Verifiers::Always)
-        Net::SSH::Verifiers::Always.new
-      else
-        Net::SSH::Verifiers::Secure.new
-      end
-    elsif defined?(Net::SSH::Verifiers::Never)
-      Net::SSH::Verifiers::Never.new
-    else
-      Net::SSH::Verifiers::Null.new
-    end
+                                  # Fall back to SSH behavior. This variable will only be set in net-ssh 5.3+.
+                                  if @strict_host_key_checking.nil? || @strict_host_key_checking
+                                    Net::SSH::Verifiers::Always.new
+                                  else
+                                    # SSH's behavior with StrictHostKeyChecking=no: adds new keys to known_hosts.
+                                    # If known_hosts points to /dev/null, then equivalent to :never where it
+                                    # accepts any key beacuse they're all new.
+                                    Net::SSH::Verifiers::AcceptNewOrLocalTunnel.new
+                                  end
+                                elsif node_config.dig('ssh', 'host-key-check')
+                                  if defined?(Net::SSH::Verifiers::Always)
+                                    Net::SSH::Verifiers::Always.new
+                                  else
+                                    Net::SSH::Verifiers::Secure.new
+                                  end
+                                elsif defined?(Net::SSH::Verifiers::Never)
+                                  Net::SSH::Verifiers::Never.new
+                                else
+                                  Net::SSH::Verifiers::Null.new
+                                end
 
     host = if ENV['TARGET_HOST'].include?(':')
              ENV['TARGET_HOST'].split(':').first
index d0c3f6e1769c94d3929b2d05f0bdba7e6b0e5372..7514c423d26dc4f63a294133be3d435cdb852d36 100644 (file)
@@ -10,7 +10,7 @@ def ip6tables_flush_all_tables
   end
 end
 
-def get_iptables_version
-  x=run_shell('iptables -V')
+def iptables_version
+  x = run_shell('iptables -V')
   x.stdout.split(' ')[1][1..-1]
-end
\ No newline at end of file
+end