Skip to content

Commit

Permalink
basic skel
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Abrams <[email protected]>
  • Loading branch information
majormoses committed Apr 28, 2018
1 parent d4eebcf commit d1d603b
Show file tree
Hide file tree
Showing 19 changed files with 421 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Pull Request Checklist

**Is this in reference to an existing issue?**

#### General

- [ ] Update Changelog following the conventions laid out [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

- [ ] Update README with any necessary configuration snippets

- [ ] Binstubs are created if needed

- [ ] RuboCop passes

- [ ] Existing tests pass

#### New Plugins

- [ ] Tests

- [ ] Add the plugin to the README

- [ ] Does it have a complete header as outlined [here](http://sensu-plugins.io/docs/developer_guidelines.html#coding-style)

#### Purpose

#### Known Compatibility Issues
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
*.bundle
*.so
*.o
*.a
mkmf.log
.vagrant/*
.DS_Store
.idea/*
*.gem


# test-kitchen
.kitchen/
.kitchen.list.yml
23 changes: 23 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
driver:
name: docker
use_sudo: false

provisioner:
name: shell
data_path: .
script: test/fixtures/bootstrap.sh

verifier:
ruby_bindir: /usr/local/bin

platforms:
- name: debian-8

suites:
- name: ruby-230
driver:
image: ruby:2.3.0-slim
- name: ruby-241
driver:
image: ruby:2.4.1-slim
30 changes: 30 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

MethodLength:
Max: 200

LineLength:
Max: 160

AbcSize:
Max: 100

FileName:
Enabled: false

PerceivedComplexity:
Enabled: false

CyclomaticComplexity:
Enabled: false

ClassLength:
Enabled: false

IfUnlessModifier:
Enabled: false

RegexpLiteral:
Enabled: false

Style/Documentation:
Enabled: false
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
sudo: true
service: docker
language: ruby
cache:
- bundler
before_install:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables
-N DOCKER )
- gem install bundler -v 1.15
install:
- bundle install
rvm:
- 2.3.0
- 2.4.1
notifications:
email:
recipients:
- [email protected]
on_success: change
on_failure: always
script:
- gem build sensu-plugins-kafka.gemspec
- gem install sensu-plugins-kafka-*.gem
- bundle exec rake quick
- bundle exec rake kitchen:ruby-`echo $TRAVIS_RUBY_VERSION | sed -e "s/\.//g"`-debian-8
deploy:
provider: rubygems
api_key:
secure: mZhCJKtOyUqcpJwZS2CmQPLu5bnyStuFAHYhxEfBhggac+zxAUJkNodAgZGiNmX9JHpuZ4SlpZuuyec7EvGeKWFFBEVPoWC7STzWhgM3se74Us1k/QCcQ0NP/Bh9Ic8RPev5d0ZCT1qiQ+wQonzbfFGRZEoXvQabEHPi0bfd+KsgVVkwcTRsmxC8Ml4xb020PigqOuPP5N9wHDfKAQJPJiPF9C6HzaVE1uoQz+jYYg9NPsgYmNlHefXn/s61PHP5556dOL8+tL8JDaTzFnYyKfQ+4L6LXiLVMVVCM+fJp0YVfCYCmyrJRJGgyxbyIeC72drEAGKH7Z+CQyVlwC3bXZKv1v80eFCRujMTj5JvaqXCRArIxlkQNhvhQmFTtXf8Y552JBzsU8Ej6L1XRzWFtZSLkZ1WSv44STexEBow7hEWntVcbGAWx+eQD+buBuqZXzGZ0epxuNMpLQRnCw6M3i6rJ2lfxuF2s2tBh216u70NmR7vuxgm1o4odAOv0YNKhu6xYZ2zw3CkcZwtb5KNXIrEk+q2iuJV6MbXDlJHZh1m0jncuVVvjYtTIcc8nm/tOWtkIiG9EciOjLnbrYbXfm0HBtFjHuIYguXTedOXLbnvkiB9CWU2EaqxurCoXV+DFf0jLaboUY5biYJbzimtL+soSvDO5nPnu3kuEfwU3uA=
gem: sensu-plugins-kafka
on:
tags: true
all_branches: true
rvm: 2.4.1
repo: sensu-plugins/sensu-plugins-kafka
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

This CHANGELOG follows the format located [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]

### Added
- Basic Skel to be used to make new plugin repo setup easier.
- PR template
- Rubocop config
- basic testing setup
- removing EOL versions of ruby
- patching for any known CVEs

[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-kafka/compare/d4eebcfed091899571e21c0e433cceb3e386d2c7...HEAD
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gemspec
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2016 Sensu Community Plugins

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# sensu-plugins-kafka
Sensu Plugins for kafka
## Sensu-Plugins-kafka

[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-skel.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-skel)
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-skel.svg)](http://badge.fury.io/rb/sensu-plugins-skel)
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-skel.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-skel)
[![Community Slack](https://slack.sensu.io/badge.svg)](https://slack.sensu.io/badge)

## Functionality

## Files

## Usage

## Installation

[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)

## Notes
49 changes: 49 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'github/markup'
require 'redcarpet'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'yard'
require 'yard/rake/yardoc_task'
require 'English'
require 'kitchen/rake_tasks'

YARD::Rake::YardocTask.new do |t|
OTHER_PATHS = %w[].freeze
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS]
t.options = %w[--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md]
end

RuboCop::RakeTask.new

RSpec::Core::RakeTask.new(:spec) do |r|
r.pattern = FileList['**/**/*_spec.rb']
end

desc 'Make all plugins executable'
task :make_bin_executable do
`chmod -R +x bin/*`
end

desc 'Test for binstubs'
task :check_binstubs do
unless Dir.glob('bin/**/*.rb').empty?
bin_list = Gem::Specification.load('sensu-plugins-skel.gemspec').executables
bin_list.each do |b|
`which #{ b }`
unless $CHILD_STATUS.success?
puts "#{b} was not a binstub"
exit
end
end
end
end

Kitchen::RakeTasks.new
desc 'Alias for kitchen:all'
task integration: 'kitchen:all'

task default: %i[spec make_bin_executable yard rubocop check_binstubs integration]
task quick: %i[make_bin_executable yard rubocop check_binstubs]
1 change: 1 addition & 0 deletions lib/sensu-plugins-kafka.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'sensu-plugins-kafka/version'
9 changes: 9 additions & 0 deletions lib/sensu-plugins-kafka/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module SensuPluginsKafka
module Version
MAJOR = 0
MINOR = 0
PATCH = 1

VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
end
end
46 changes: 46 additions & 0 deletions sensu-plugins-kafka.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

require 'date'
require_relative 'lib/sensu-plugins-kafka'

Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
s.authors = ['Sensu-Plugins and contributors']
s.date = Date.today.to_s
s.description = 'Sensu kafka plugins'
s.email = '<[email protected]>'
s.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) }
s.files = Dir.glob('{bin,lib}/**/*') + %w[LICENSE README.md CHANGELOG.md]
s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-kafka'
s.license = 'MIT'
s.metadata = { 'maintainer' => 'sensu-plugin',
'development_status' => 'active',
'production_status' => 'unstable - testing recommended',
'release_draft' => 'false',
'release_prerelease' => 'false' }
s.name = 'sensu-plugins-kafka'
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.3.0'
s.summary = 'Sensu plugins for kafka'
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.version = SensuPluginsKafka::Version::VER_STRING

s.add_runtime_dependency 'sensu-plugin', '~> 2.0'

s.add_development_dependency 'bundler', '~> 1.15'
s.add_development_dependency 'github-markup', '~> 1.3'
s.add_development_dependency 'kitchen-docker', '~> 2.6'
s.add_development_dependency 'kitchen-localhost', '~> 0.3'
s.add_development_dependency 'pry', '~> 0.10'
s.add_development_dependency 'rake', '~> 12.0'
s.add_development_dependency 'redcarpet', '~> 3.2'
s.add_development_dependency 'rspec', '~> 3.4'
s.add_development_dependency 'rubocop', '~> 0.49.0'
s.add_development_dependency 'serverspec', '~> 2.36.1'
s.add_development_dependency 'test-kitchen', '~> 1.6'
s.add_development_dependency 'yard', '~> 0.9.11'
end
28 changes: 28 additions & 0 deletions test/fixtures/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Set up a super simple web server and make it accept GET and POST requests
# for Sensu plugin testing.
#

set -e

# base utilities that need to exist to start bootatraping
apt-get update
# apt-get install -y wget

# setup the rubies
source /etc/profile
DATA_DIR=/tmp/kitchen/data
RUBY_HOME=${MY_RUBY_HOME}

# Start bootatraping

## install some required deps for pg_gem to install


# End of Actual bootatrap

# Install gems
cd $DATA_DIR
SIGN_GEM=false gem build sensu-plugins-kafka.gemspec
gem install sensu-plugins-kafka-*.gem
53 changes: 53 additions & 0 deletions test/integration/helpers/serverspec/check-example-dns_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

# require 'spec_helper'
# require 'shared_spec'
#
# gem_path = '/usr/local/bin'
# check_name = 'check-dns.rb'
# check = "#{gem_path}/#{check_name}"
# domain = 'benabrams.it'
#
# describe 'ruby environment' do
# it_behaves_like 'ruby checks', check
# end
#
# describe command("#{check} --domain #{domain}") do
# its(:exit_status) { should eq 0 }
# its(:stdout) { should match(/DNS OK: Resolved benabrams.it A/) }
# end
#
# describe command("#{check} --domain sensutest-a.#{domain} --result 1.1.1.1") do
# its(:exit_status) { should eq 0 }
# its(:stdout) { should match(/DNS OK: Resolved UNCHECKED sensutest-a.benabrams.it A included 1.1.1.1/) }
# end
#
# describe command("#{check} --domain sensutest-a.#{domain} --result 1.1.2.2") do
# its(:exit_status) { should eq 0 }
# its(:stdout) { should match(/DNS OK: Resolved UNCHECKED sensutest-a.benabrams.it A included 1.1.2.2/) }
# end
#
# describe command("#{check} --domain sensutest-a.#{domain} --result 1.1.1.1,1.1.2.2") do
# its(:exit_status) { should eq 0 }
# its(:stdout) { should match(/DNS OK: Resolved UNCHECKED sensutest-a.benabrams.it A included 1.1.1.1,1.1.2.2/) }
# end
#
# describe command(check.to_s) do
# its(:exit_status) { should eq 3 }
# its(:stdout) { should match(/DNS UNKNOWN: No domain specified/) }
# end
#
# describe command("#{check} --domain some.non.existent.domain.tld --timeout 1") do
# its(:exit_status) { should eq 2 }
# its(:stdout) { should match(/DNS CRITICAL: 0% of tests succeeded: Could not resolve some.non.existent.domain.tld A record/) }
# end
#
# describe command("#{check} --domain sensutest-a.#{domain} --request_count 2") do
# its(:exit_status) { should eq 0 }
# its(:stdout) { should match(/DNS OK: Resolved sensutest-a.benabrams.it A/) }
# end
#
# describe command("#{check} --domain sensutest-a.#{domain} --request_count 5") do
# its(:exit_status) { should eq 0 }
# its(:stdout) { should match(/DNS OK: Resolved sensutest-a.benabrams.it A/) }
# end
Loading

0 comments on commit d1d603b

Please sign in to comment.