kubernetes-health 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 726bc092d8f0aecff2b1149af89a0da7dd463c2e
4
+ data.tar.gz: 0f5170160a829c17eb1bcf49c3446eb9d3296283
5
+ SHA512:
6
+ metadata.gz: f6bb961d18809c7fa1358a0ccb439e041a01c1f8c89ce389c301eb363d3aad16edeaac1126f2cba5ec090feb461c60b5ec0750ffadaa4b85bf407844434fc958
7
+ data.tar.gz: 7ca5992a79ff325922299cff6a4de6abdf10d3441373d2e5faede3115363348dda5ce8622dee9b9b7a1c80ca4e50a586a91449edcfb7b1fb6da38f70ce676a1a
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kubernetes-health.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Kubernetes::Health
2
+
3
+ A simple gem that adds /_health in your APP.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'kubernetes-health'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install kubernetes-health
20
+
21
+ ## Custom check
22
+
23
+ Set Kubernetes::Health::Config.sick_if if you want to check other things.
24
+
25
+ Ex. Check if PostgreSQL is working.
26
+ ```
27
+ Kubernetes::Health::Config.sick_if = lambda { ActiveRecord::Base.connection.execute("SELECT 1").cmd_tuples != 1 }
28
+ ```
29
+
30
+ ## Custom route
31
+
32
+ Set Kubernetes::Health::Config.route if you want to use other route.
33
+
34
+ Ex.
35
+ ```
36
+ Kubernetes::Health::Config.route = '/status'
37
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ module Kubernetes
2
+ class HealthController < ::ActionController::Base
3
+ def status
4
+ if Kubernetes::Health::Config.sick_if.call
5
+ head 503
6
+ else
7
+ head 200
8
+ end
9
+ end
10
+ end
11
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kubernetes/health"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ get Kubernetes::Health::Config.route, to: 'kubernetes/health#status'
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kubernetes/health/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kubernetes-health"
8
+ spec.version = Kubernetes::Health::VERSION
9
+ spec.authors = ["Wagner Caixeta"]
10
+ spec.email = ["wagner@baladapp.com.br"]
11
+
12
+ spec.summary = %q{A simple gem to add /_health to your Rails APP.}
13
+ spec.description = %q{A simple gem to add /_health to your Rails APP for using with Kubernetes}
14
+ spec.homepage = "https://github.com/platbr/kubernetes-health"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.14"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ end
@@ -0,0 +1,24 @@
1
+ module Kubernetes
2
+ module Health
3
+ class Config
4
+ @@sick_if = lambda { false }
5
+ @@route = '/_health'
6
+
7
+ def self.route
8
+ @@route
9
+ end
10
+
11
+ def self.route=(value)
12
+ @@route
13
+ end
14
+
15
+ def self.sick_if
16
+ @@sick_if
17
+ end
18
+
19
+ def self.sick_if=(value)
20
+ @@sick_if = value
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,8 @@
1
+ module Kubernetes
2
+ module Health
3
+ class Engine < ::Rails::Engine
4
+ engine_name 'kubernetes_health'
5
+ isolate_namespace Kubernetes::Health
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Kubernetes
2
+ module Health
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require "kubernetes/health/version"
2
+ require "kubernetes/health/engine"
3
+ require "kubernetes/health/config"
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kubernetes-health
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wagner Caixeta
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: A simple gem to add /_health to your Rails APP for using with Kubernetes
56
+ email:
57
+ - wagner@baladapp.com.br
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - README.md
67
+ - Rakefile
68
+ - app/controllers/kubernetes/health_controller.rb
69
+ - bin/console
70
+ - bin/setup
71
+ - config/routes.rb
72
+ - kubernetes-health.gemspec
73
+ - lib/kubernetes/health.rb
74
+ - lib/kubernetes/health/config.rb
75
+ - lib/kubernetes/health/engine.rb
76
+ - lib/kubernetes/health/version.rb
77
+ homepage: https://github.com/platbr/kubernetes-health
78
+ licenses: []
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.6.8
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: A simple gem to add /_health to your Rails APP.
100
+ test_files: []
101
+ has_rdoc: