diff --git a/.bonsai.yml b/.bonsai.yml new file mode 100644 index 0000000..1e05986 --- /dev/null +++ b/.bonsai.yml @@ -0,0 +1,62 @@ +--- +description: "#{repo}" +builds: +- platform: "alpine" + arch: "amd64" + asset_filename: "#{repo}_#{version}_alpine_linux_amd64.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.arch == 'amd64'" + - "entity.system.platform == 'alpine'" + - "entity.system.platform_version.split('.')[0] == '3'" +- platform: "alpine3.8" + arch: "amd64" + asset_filename: "#{repo}_#{version}_alpine3.8_linux_amd64.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.arch == 'amd64'" + - "entity.system.platform == 'alpine'" +- platform: "centos" + arch: "amd64" + asset_filename: "#{repo}_#{version}_centos_linux_amd64.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.arch == 'amd64'" + - "entity.system.platform_family == 'rhel'" +- platform: "centos6" + arch: "amd64" + asset_filename: "#{repo}_#{version}_centos6_linux_amd64.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.arch == 'amd64'" + - "entity.system.platform_family == 'rhel'" + - "entity.system.platform_version.split('.')[0] == '6'" +- platform: "centos7" + arch: "amd64" + asset_filename: "#{repo}_#{version}_centos7_linux_amd64.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.arch == 'amd64'" + - "entity.system.platform_family == 'rhel'" + - "entity.system.platform_version.split('.')[0] == '7'" +- platform: "debian" + arch: "amd64" + asset_filename: "#{repo}_#{version}_debian_linux_amd64.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.arch == 'amd64'" + - "entity.system.platform_family == 'debian'" +- platform: "debian9" + arch: "amd64" + asset_filename: "#{repo}_#{version}_debian9_linux_amd64.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.arch == 'amd64'" + diff --git a/.travis.yml b/.travis.yml index a385895..4414654 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: ruby +services: +- docker cache: - bundler install: - bundle install rvm: -- 2.1 -- 2.2 - 2.3.0 - 2.4.1 notifications: @@ -18,16 +18,23 @@ script: - bundle exec rake default - gem build sensu-plugins-puppet.gemspec - gem install sensu-plugins-puppet-*.gem +- bash -c "[ ! -d bonsai/ ] && git clone https://github.com/sensu/sensu-go-bonsai-asset.git bonsai || echo 'bonsai/ exists, skipping git clone'" deploy: - provider: rubygems +- provider: rubygems api_key: secure: i6RFvnFPoE21r7Cglk2vQ4KgZyP6hsG53YtdBmyXKofvHwL3nlIc+WCInLSOLOaJH8fbT+NAIcpQQehDwL0WQH9J0bp3Lkp4DoLxCcyNKrztkNcVkeo8kYp9TCqDRS6vBtdkASoykO0dxeEtfk2Wa9yC9yS24o4xHlB5vdKZB1NC3W5P6S151aiizyb3NDlYc+Rp/1Grd9BETDrJvglhh7OwbFbtrEo28FSTjaoUsim2vW+622pIJps7pCwDf5Zc/lID/s0VPrUo8+JmwE/fb8TToj9nd88KFRPTT1EEC3tkUQMb93NuTjiYV9OSAAtFTTS8EBqQwUcr4rO4ikdybqwDcoYZm2v2Z0tQv2vJVRfIdl7WWMNoaMFS6L1m0oxofMOX5uaBZ09ujoH7av9RkmQZxpizfYNT8gf8umpVnSVe0myyVr08EmqppBbOaG1aa388fT4fFM8DnqPRHa1LHJHwFhW4ab//a/fiFSCR1xeSMwDFH3Op7znEYkp9Il6QMZcMflJlVHowx+9zyHfZalKujFtXdX7XE6JOGjdrzP7RkQoRONLNpYAgSytk2PBY42EZS7NprW21IrrGD51SwoB/lf1c25uEVcZvsHtvni7KSBYVHHJ0iW/jA4tR4Q386x3puzmYVcJHFznYnnd15p4dBmFcFI59tirhEZWgKpE= gem: sensu-plugins-puppet on: tags: true all_branches: true - rvm: 2.1 - rvm: 2.2 rvm: 2.3.0 rvm: 2.4.1 repo: sensu-plugins/sensu-plugins-puppet +- provider: script + script: bonsai/ruby-runtime/travis-build-ruby-plugin-assets.sh sensu-plugins-puppet + skip_cleanup: true + on: + tags: true + all_branches: true + rvm: 2.4.1 + diff --git a/CHANGELOG.md b/CHANGELOG.md index 00f7db2..cb684d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins ## [Unreleased] +### Breaking Change +- Removed Ruby 2.1 and 2.2 + +### Added +- Bonsai asset build bits + +### Changed +- Updated bundler to '~> 2.1' +- Updated rubocop to '~> 0.80.1' +- Updated sensu-plugin to '~> 4.0' +- Remediated rubocop warnings + ## [2.2.0] - 2019-12-17 ### Added - Adding support windows by default without overriding options by checking the platform and adjusting the paths automatically (@bodgit) diff --git a/Gemfile b/Gemfile index 58b8e32..9b87889 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' # Specify your gem's dependencies in sensu-plugins-puppet.gemspec diff --git a/README.md b/README.md index 1830154..dd494af 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ ## Sensu-Plugins-puppet +[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-puppet) [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-puppet.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-puppet) [![Gem Version](https://badge.fury.io/rb/sensu-plugins-puppet.svg)](http://badge.fury.io/rb/sensu-plugins-puppet) [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-puppet/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-puppet) diff --git a/Rakefile b/Rakefile index f435305..07be8fe 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/gem_tasks' require 'github/markup' require 'redcarpet' @@ -27,7 +29,7 @@ desc 'Test for binstubs' task :check_binstubs do bin_list = Gem::Specification.load('sensu-plugins-puppet.gemspec').executables bin_list.each do |b| - `which #{ b }` + `which #{b}` unless $CHILD_STATUS.success? puts "#{b} was not a binstub" exit diff --git a/bin/check-puppet-errors.rb b/bin/check-puppet-errors.rb index 7517108..c90d762 100755 --- a/bin/check-puppet-errors.rb +++ b/bin/check-puppet-errors.rb @@ -1,4 +1,6 @@ #! /usr/bin/env ruby +# frozen_string_literal: true + # # check-puppet-errors # @@ -35,15 +37,15 @@ class PuppetErrors < Sensu::Plugin::Check::CLI option :summary_file, - short: '-s PATH', - long: '--summary-file PATH', - default: SensuPluginsPuppet::SUMMARY_FILE, + short: '-s PATH', + long: '--summary-file PATH', + default: SensuPluginsPuppet::SUMMARY_FILE, description: 'Location of last_run_summary.yaml file' option :agent_disabled_file, - short: '-a PATH', - long: '--agent-disabled-file PATH', - default: SensuPluginsPuppet::AGENT_DISABLED_FILE, + short: '-a PATH', + long: '--agent-disabled-file PATH', + default: SensuPluginsPuppet::AGENT_DISABLED_FILE, description: 'Path to agent disabled lock file' def run @@ -73,7 +75,7 @@ def run end end - if @failures > 0 + if @failures > 0 # rubocop:disable Style/NumericPredicate @message += " had #{@failures} failures" critical @message else diff --git a/bin/check-puppet-last-run.rb b/bin/check-puppet-last-run.rb index 07fd5c0..5b9bb3b 100755 --- a/bin/check-puppet-last-run.rb +++ b/bin/check-puppet-last-run.rb @@ -1,4 +1,6 @@ #! /usr/bin/env ruby +# frozen_string_literal: true + # # check-puppet-last-run # @@ -35,64 +37,64 @@ class PuppetLastRun < Sensu::Plugin::Check::CLI option :summary_file, - short: '-s PATH', - long: '--summary-file PATH', - default: SensuPluginsPuppet::SUMMARY_FILE, + short: '-s PATH', + long: '--summary-file PATH', + default: SensuPluginsPuppet::SUMMARY_FILE, description: 'Location of last_run_summary.yaml file' option :warn_age, - short: '-w N', - long: '--warn-age SECONDS', - default: 3600, - proc: proc(&:to_i), + short: '-w N', + long: '--warn-age SECONDS', + default: 3600, + proc: proc(&:to_i), description: 'Age in seconds to be a warning' option :crit_age, - short: '-c N', - long: '--crit-age SECONDS', - default: 7200, - proc: proc(&:to_i), + short: '-c N', + long: '--crit-age SECONDS', + default: 7200, + proc: proc(&:to_i), description: 'Age in seconds to be a critical' option :agent_disabled_file, - short: '-a PATH', - long: '--agent-disabled-file PATH', - default: SensuPluginsPuppet::AGENT_DISABLED_FILE, + short: '-a PATH', + long: '--agent-disabled-file PATH', + default: SensuPluginsPuppet::AGENT_DISABLED_FILE, description: 'Path to agent disabled lock file' option :disabled_age_limits, - short: '-d', - long: '--disabled-age-limits', - boolean: true, - default: false, + short: '-d', + long: '--disabled-age-limits', + boolean: true, + default: false, description: 'Consider disabled age limits, otherwise use main limits' option :warn_age_disabled, - short: '-W N', - long: '--warn-age-disabled SECONDS', - default: 3600, - proc: proc(&:to_i), + short: '-W N', + long: '--warn-age-disabled SECONDS', + default: 3600, + proc: proc(&:to_i), description: 'Age in seconds to warn when agent is disabled' option :crit_age_disabled, - short: '-C N', - long: '--crit-age-disabled SECONDS', - default: 7200, - proc: proc(&:to_i), + short: '-C N', + long: '--crit-age-disabled SECONDS', + default: 7200, + proc: proc(&:to_i), description: 'Age in seconds to crit when agent is disabled' option :report_restart_failures, - short: '-r', - long: '--report-restart-failures', - boolean: true, - default: false, + short: '-r', + long: '--report-restart-failures', + boolean: true, + default: false, description: 'Raise alerts if restart failures have happened' option :ignore_failures, - short: '-i', - long: '--ignore-failures', - boolean: true, - default: false, + short: '-i', + long: '--ignore-failures', + boolean: true, + default: false, description: 'Ignore Puppet failures' def run @@ -138,11 +140,11 @@ def run end end - if @failures > 0 + if @failures > 0 # rubocop:disable Style/NumericPredicate @message += " with #{@failures} failures" end - if @restart_failures > 0 + if @restart_failures > 0 # rubocop:disable Style/NumericPredicate @message += " with #{@restart_failures} restart failures" end @@ -156,7 +158,7 @@ def run end end - if @now - @last_run > config[:crit_age] || @failures > 0 || @restart_failures > 0 + if @now - @last_run > config[:crit_age] || @failures > 0 || @restart_failures > 0 # rubocop:disable Style/NumericPredicate critical @message elsif @now - @last_run > config[:warn_age] warning @message @@ -170,7 +172,7 @@ def formatted_duration(total_seconds) minutes = (total_seconds / 60) % 60 seconds = total_seconds % 60 - if hours <= 0 && minutes > 0 + if hours <= 0 && minutes > 0 # rubocop:disable Style/NumericPredicate "#{minutes}m #{seconds}s" elsif minutes <= 0 "#{seconds}s" diff --git a/bin/metrics-puppet-run.rb b/bin/metrics-puppet-run.rb index 3c431fd..7dce6b2 100755 --- a/bin/metrics-puppet-run.rb +++ b/bin/metrics-puppet-run.rb @@ -1,4 +1,6 @@ #! /usr/bin/env ruby +# frozen_string_literal: true + # # metrics-puppet-run # @@ -31,9 +33,9 @@ class PuppetRun < Sensu::Plugin::Metric::CLI::Graphite option :summary_file, - short: '-p PATH', - long: '--summary-file PATH', - default: SensuPluginsPuppet::SUMMARY_FILE, + short: '-p PATH', + long: '--summary-file PATH', + default: SensuPluginsPuppet::SUMMARY_FILE, description: 'Location of last_run_summary.yaml file' option :scheme, diff --git a/lib/sensu-plugins-puppet.rb b/lib/sensu-plugins-puppet.rb index b0a4c34..d74646f 100644 --- a/lib/sensu-plugins-puppet.rb +++ b/lib/sensu-plugins-puppet.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: false + require 'sensu-plugins-puppet/version' module SensuPluginsPuppet diff --git a/lib/sensu-plugins-puppet/version.rb b/lib/sensu-plugins-puppet/version.rb index 9be4cbf..7fc281c 100644 --- a/lib/sensu-plugins-puppet/version.rb +++ b/lib/sensu-plugins-puppet/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SensuPluginsPuppet module Version MAJOR = 2 diff --git a/sensu-plugins-puppet.gemspec b/sensu-plugins-puppet.gemspec index ae8f220..4253c2a 100644 --- a/sensu-plugins-puppet.gemspec +++ b/sensu-plugins-puppet.gemspec @@ -1,9 +1,11 @@ -lib = File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'date' require_relative 'lib/sensu-plugins-puppet' -Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength +Gem::Specification.new do |s| s.authors = ['Sensu-Plugins and contributors'] s.date = Date.today.to_s @@ -15,30 +17,30 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength s.files = Dir.glob('{bin,lib}/**/*') + %w[LICENSE README.md CHANGELOG.md] s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-puppet' s.license = 'MIT' - s.metadata = { 'maintainer' => 'sensu-plugin', + s.metadata = { 'maintainer' => 'sensu-plugin', 'development_status' => 'active', - 'production_status' => 'unstable - testing recommended', - 'release_draft' => 'false', + 'production_status' => 'unstable - testing recommended', + 'release_draft' => 'false', 'release_prerelease' => 'false' } s.name = 'sensu-plugins-puppet' s.platform = Gem::Platform::RUBY s.post_install_message = 'You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu' s.require_paths = ['lib'] - s.required_ruby_version = '>= 2.1.0' + s.required_ruby_version = '>= 2.3' s.summary = 'Sensu plugins for puppet' s.test_files = s.files.grep(%r{^(test|spec|features)/}) s.version = SensuPluginsPuppet::Version::VER_STRING - s.add_runtime_dependency 'sensu-plugin', '~> 1.2' + s.add_runtime_dependency 'sensu-plugin', '~> 4.0' - s.add_development_dependency 'bundler', '~> 1.7' + s.add_development_dependency 'bundler', '~> 2.1' s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0' s.add_development_dependency 'github-markup', '~> 3.0' s.add_development_dependency 'pry', '~> 0.10' s.add_development_dependency 'rake', '~> 12.3' s.add_development_dependency 'redcarpet', '~> 3.2' s.add_development_dependency 'rspec', '~> 3.1' - s.add_development_dependency 'rubocop', '~> 0.51.0' + s.add_development_dependency 'rubocop', '~> 0.80.1' s.add_development_dependency 'yard', '~> 0.8' end diff --git a/test/spec_helper.rb b/test/spec_helper.rb index 9797982..3bb6bfe 100644 --- a/test/spec_helper.rb +++ b/test/spec_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + require 'codeclimate-test-reporter' CodeClimate::TestReporter.start