heroku_formation_validator 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +1 -0
- data/TODO.md +3 -0
- data/bin/heroku_formation_validator +4 -0
- data/formation.yml.sample +20 -0
- data/heroku_formation_validator.gemspec +26 -0
- data/lib/heroku_formation_validator.rb +45 -0
- data/lib/heroku_formation_validator/heroku_api.rb +34 -0
- data/lib/heroku_formation_validator/plugins/addons.rb +16 -0
- data/lib/heroku_formation_validator/plugins/papertrail.rb +14 -0
- data/lib/heroku_formation_validator/plugins/variables.rb +23 -0
- data/lib/heroku_formation_validator/runner.rb +29 -0
- data/lib/heroku_formation_validator/version.rb +3 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8db25599dfeadbc6795f83b5aed596c79b409605
|
4
|
+
data.tar.gz: 82a4061b706961ca54aac6cbc99e49c181f6cb52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 715d92f138ff1f48a46da1a16b36a483dc74747eff5685fbdf435fce2b25d95599e0123747f649041fa26f34438a312efd6e88fd78b821c033ec505cebe1984b
|
7
|
+
data.tar.gz: 5183810cd82669c520bb10dbcbf4c63578e19e94eca32d5839bfb1a269373f0f90ce7d4f3874634ba7df0327f8a3bf192aa85361f992ca2d327626438a616cbe
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tomo Nakano
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Heroku Formation Validator
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
$ gem install heroku_formation_validator
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
### Create your formation.yml
|
11
|
+
|
12
|
+
```
|
13
|
+
auth:
|
14
|
+
user: <heroku email address>
|
15
|
+
token: <heroku token>
|
16
|
+
|
17
|
+
common:
|
18
|
+
addons:
|
19
|
+
- "newrelic:stark"
|
20
|
+
- "redistogo:mini"
|
21
|
+
- "scheduler:standard"
|
22
|
+
- "sendgrid:bronze"
|
23
|
+
variables:
|
24
|
+
MONGO_DATABASE: "ABC"
|
25
|
+
papertrail: true
|
26
|
+
|
27
|
+
groups:
|
28
|
+
api:
|
29
|
+
apps:
|
30
|
+
- <your app name on heroku>
|
31
|
+
variables:
|
32
|
+
- YOUR_VARIABLE: "ABC"
|
33
|
+
```
|
34
|
+
|
35
|
+
### Run it (Usually, in CI)
|
36
|
+
|
37
|
+
```
|
38
|
+
$ heroku_formation_validator formation.yml
|
39
|
+
```
|
40
|
+
|
41
|
+
- When no errors, you will get nothing with exit code 0
|
42
|
+
- When errors, You will get errors with exit code 1
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it ( http://github.com/quipper/heroku_formation_validator/fork )
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/TODO.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
auth:
|
2
|
+
user: <heroku email address>
|
3
|
+
token: <heroku token>
|
4
|
+
|
5
|
+
common:
|
6
|
+
addons:
|
7
|
+
- "newrelic:stark"
|
8
|
+
- "redistogo:mini"
|
9
|
+
- "scheduler:standard"
|
10
|
+
- "sendgrid:bronze"
|
11
|
+
variables:
|
12
|
+
MONGO_DATABASE: "ABC"
|
13
|
+
papertrail: true
|
14
|
+
|
15
|
+
groups:
|
16
|
+
api:
|
17
|
+
apps:
|
18
|
+
- <your app name on heroku>
|
19
|
+
variables:
|
20
|
+
- YOUR_VARIABLE: "ABC"
|
@@ -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 'heroku_formation_validator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "heroku_formation_validator"
|
8
|
+
spec.version = HerokuFormationValidator::VERSION
|
9
|
+
spec.authors = ["Tomo Nakano"]
|
10
|
+
spec.email = ["tomo@quipper.com"]
|
11
|
+
spec.summary = %q{Heroku config/addons validator for multiple apps}
|
12
|
+
spec.description = %q{Heroku config/addons validator for multiple apps. It checks addons / config varibales etc}
|
13
|
+
spec.homepage = "https://github.com/quipper/heroku_formation_validator"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
23
|
+
|
24
|
+
spec.add_dependency 'httparty', "~> 0.12"
|
25
|
+
spec.add_dependency 'activesupport', "~> 4"
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "heroku_formation_validator/version"
|
2
|
+
require "heroku_formation_validator/heroku_api"
|
3
|
+
require "heroku_formation_validator/runner"
|
4
|
+
require "yaml"
|
5
|
+
require "active_support/all"
|
6
|
+
|
7
|
+
Dir[File.join(File.dirname(__FILE__), 'heroku_formation_validator', 'plugins', '*.rb')].each do |extension|
|
8
|
+
require extension
|
9
|
+
end
|
10
|
+
|
11
|
+
module HerokuFormationValidator
|
12
|
+
def self.run(config_file)
|
13
|
+
begin
|
14
|
+
cnf = YAML::load(File.open(config_file))
|
15
|
+
rescue Errno::ENOENT
|
16
|
+
$stderr.puts "File not found: #{config_file}"
|
17
|
+
return false
|
18
|
+
end
|
19
|
+
heroku_api = HerokuApi.new(cnf["auth"]["email"], cnf["auth"]["token"])
|
20
|
+
|
21
|
+
unless heroku_api.ping
|
22
|
+
$stderr.puts "Heroku API error. Heroku credential in config is not correct?"
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
|
26
|
+
success = true
|
27
|
+
cnf["groups"].each do |group, validations|
|
28
|
+
apps = validations.delete("apps")
|
29
|
+
apps.each do |app|
|
30
|
+
errors = []
|
31
|
+
cnf["common"].merge(validations).each do |plugin, values|
|
32
|
+
plugin_klass = "HerokuFormationValidator::Plugins::#{plugin.camelize}".safe_constantize
|
33
|
+
errors += plugin_klass.run(heroku_api, app, values).map{|error| "#{plugin.camelize}: #{error}"}
|
34
|
+
end
|
35
|
+
|
36
|
+
if errors.length > 0
|
37
|
+
success = false
|
38
|
+
$stderr.puts "=== #{group} #{app} ==="
|
39
|
+
$stderr.puts errors.join("\n")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
success
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
module HerokuFormationValidator
|
4
|
+
class HerokuApi
|
5
|
+
include HTTParty
|
6
|
+
base_uri 'https://api.heroku.com'
|
7
|
+
headers({"Accept" => "application/vnd.heroku+json; version=3"})
|
8
|
+
# debug_output $stderr
|
9
|
+
|
10
|
+
def initialize(email, token)
|
11
|
+
self.class.basic_auth email, token
|
12
|
+
end
|
13
|
+
|
14
|
+
def ping
|
15
|
+
apps.ok?
|
16
|
+
end
|
17
|
+
|
18
|
+
def apps
|
19
|
+
self.class.get("/apps")
|
20
|
+
end
|
21
|
+
|
22
|
+
def configvars(app_id_or_name)
|
23
|
+
self.class.get("/apps/#{app_id_or_name}/config-vars")
|
24
|
+
end
|
25
|
+
|
26
|
+
def addons(app_id_or_name)
|
27
|
+
self.class.get("/apps/#{app_id_or_name}/addons")
|
28
|
+
end
|
29
|
+
|
30
|
+
def logdrains(app_id_or_name)
|
31
|
+
self.class.get("/apps/#{app_id_or_name}/log-drains")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module HerokuFormationValidator
|
2
|
+
module Plugins
|
3
|
+
class Addons
|
4
|
+
def self.run(heroku_api, app, values)
|
5
|
+
errors = []
|
6
|
+
addons = heroku_api.addons(app)
|
7
|
+
values.each do |expected_addon|
|
8
|
+
if !addons.detect{|addon| addon["plan"]["name"] == expected_addon}
|
9
|
+
errors << "\"#{expected_addon}\" is not installed"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
errors
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module HerokuFormationValidator
|
2
|
+
module Plugins
|
3
|
+
class Papertrail
|
4
|
+
def self.run(heroku_api, app, values)
|
5
|
+
errors = []
|
6
|
+
drains = heroku_api.logdrains(app)
|
7
|
+
unless drains.detect{|drain| drain["url"] =~ /^syslog:\/\/logs.papertrailapp.com/}
|
8
|
+
errors << "not set in logdrains"
|
9
|
+
end
|
10
|
+
errors
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module HerokuFormationValidator
|
2
|
+
module Plugins
|
3
|
+
class Variables
|
4
|
+
|
5
|
+
def self.run(heroku_api, app, values)
|
6
|
+
errors = []
|
7
|
+
config = heroku_api.configvars(app)
|
8
|
+
values.each do |key, value|
|
9
|
+
if value.nil?
|
10
|
+
if config.has_key?(key)
|
11
|
+
errors << "\"#{key}\" is defined"
|
12
|
+
end
|
13
|
+
elsif !config.has_key?(key)
|
14
|
+
errors << "\"#{key}\" is not defined"
|
15
|
+
elsif config[key] != value
|
16
|
+
errors << "\"#{key}\" doesn't match. expected \"#{value}\" but \"#{config[key]}\""
|
17
|
+
end
|
18
|
+
end
|
19
|
+
errors
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module HerokuFormationValidator
|
2
|
+
class Runner
|
3
|
+
attr_reader :args
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
@args = args
|
7
|
+
run
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.execute(*args)
|
11
|
+
new(*args).execute
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
if filename = @args[0]
|
16
|
+
exit HerokuFormationValidator.run(filename) ? 0 : 1
|
17
|
+
else
|
18
|
+
puts help_text
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def help_text
|
24
|
+
<<-help
|
25
|
+
usage: heroku_formation_validator <config file name>
|
26
|
+
help
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku_formation_validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomo Nakano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-26 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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
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.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.12'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4'
|
69
|
+
description: Heroku config/addons validator for multiple apps. It checks addons /
|
70
|
+
config varibales etc
|
71
|
+
email:
|
72
|
+
- tomo@quipper.com
|
73
|
+
executables:
|
74
|
+
- heroku_formation_validator
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- TODO.md
|
84
|
+
- bin/heroku_formation_validator
|
85
|
+
- formation.yml.sample
|
86
|
+
- heroku_formation_validator.gemspec
|
87
|
+
- lib/heroku_formation_validator.rb
|
88
|
+
- lib/heroku_formation_validator/heroku_api.rb
|
89
|
+
- lib/heroku_formation_validator/plugins/addons.rb
|
90
|
+
- lib/heroku_formation_validator/plugins/papertrail.rb
|
91
|
+
- lib/heroku_formation_validator/plugins/variables.rb
|
92
|
+
- lib/heroku_formation_validator/runner.rb
|
93
|
+
- lib/heroku_formation_validator/version.rb
|
94
|
+
homepage: https://github.com/quipper/heroku_formation_validator
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.2.0
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Heroku config/addons validator for multiple apps
|
118
|
+
test_files: []
|