graphite-notify 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -1
- data/Changelog.md +8 -0
- data/Gemfile +1 -1
- data/README.md +3 -0
- data/Rakefile +0 -1
- data/graphite-notify.gemspec +20 -18
- data/lib/graphite-notify/capistrano.rb +38 -17
- data/lib/graphite-notify/version.rb +1 -1
- data/spec/capistrano_spec.rb +13 -13
- metadata +30 -12
data/.rubocop.yml
ADDED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.3-
|
1
|
+
1.9.3-p551
|
data/Changelog.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/graphite-notify.gemspec
CHANGED
@@ -1,31 +1,33 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
lib = File.expand_path('../lib/', __FILE__)
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
5
|
require 'graphite-notify/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name =
|
8
|
+
s.name = 'graphite-notify'
|
9
9
|
s.version = GraphiteNotify::VERSION
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
|
-
s.authors = [
|
12
|
-
s.email = [
|
13
|
-
s.homepage =
|
14
|
-
s.summary =
|
15
|
-
s.description =
|
11
|
+
s.authors = ['Vincent Hellot']
|
12
|
+
s.email = ['hellvinz@gmail.com']
|
13
|
+
s.homepage = 'https://github.com/hellvinz/graphite-notify'
|
14
|
+
s.summary = 'notify graphite on deploy or rollback'
|
15
|
+
s.description = 'notify graphite on deploy or rollback'
|
16
|
+
s.license = 'MIT'
|
16
17
|
|
17
|
-
s.required_ruby_version =
|
18
|
-
s.required_rubygems_version =
|
18
|
+
s.required_ruby_version = '>= 1.8.7'
|
19
|
+
s.required_rubygems_version = '>= 1.3.6'
|
19
20
|
|
20
|
-
git_files = `git ls-files`.split("\n")
|
21
|
+
git_files = `git ls-files`.split("\n")
|
21
22
|
s.files = git_files
|
22
|
-
s.require_paths = [
|
23
|
+
s.require_paths = ['lib']
|
23
24
|
|
24
|
-
s.add_dependency
|
25
|
-
s.
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
28
|
-
s.add_development_dependency
|
29
|
-
s.add_development_dependency
|
30
|
-
s.add_development_dependency
|
25
|
+
s.add_dependency 'capistrano', '<3'
|
26
|
+
s.add_dependency 'json', '<3'
|
27
|
+
s.add_development_dependency 'rake'
|
28
|
+
s.add_development_dependency 'rspec', '~> 2.14'
|
29
|
+
s.add_development_dependency 'webmock', '~> 1.20.4'
|
30
|
+
s.add_development_dependency 'capistrano-spec', '~>0.6.3'
|
31
|
+
s.add_development_dependency 'yard'
|
32
|
+
s.add_development_dependency 'redcarpet', '~>2.3.0'
|
31
33
|
end
|
@@ -1,43 +1,64 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'capistrano'
|
3
3
|
require 'uri'
|
4
|
+
require 'json'
|
4
5
|
|
5
6
|
module Capistrano
|
6
7
|
module Graphite
|
7
|
-
# Called when a Capistrano::Configuration.instance exists. Will define two tasks:
|
8
|
-
# * graphite:notify_deploy
|
9
|
-
# * graphite:notify_restart
|
8
|
+
# Called when a Capistrano::Configuration.instance exists. Will define two tasks:
|
9
|
+
# * graphite:notify_deploy notify graphite of an app deploy with the user in tags and a message
|
10
|
+
# * graphite:notify_restart notify graphite of an app rollback with the user in tags and a message
|
10
11
|
# @param [Capistrano::Configuration] configuration the current capistrano configuration instance
|
11
12
|
def self.load_into(configuration)
|
12
13
|
configuration.load do
|
13
14
|
|
14
|
-
after
|
15
|
-
after
|
15
|
+
after 'deploy:restart', 'graphite:notify_deploy'
|
16
|
+
after 'rollback:restart', 'graphite:notify_rollback'
|
16
17
|
|
17
18
|
local_user = ENV['USER'] || ENV['USERNAME']
|
18
19
|
|
19
20
|
namespace :graphite do
|
20
21
|
desc 'notify graphite that a deployment occured'
|
21
22
|
task :notify_deploy, :on_error => :continue do
|
22
|
-
uri = URI
|
23
|
-
Net::HTTP.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
uri = URI(graphite_url)
|
24
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
25
|
+
http.use_ssl = true if uri.scheme == 'https'
|
26
|
+
begin
|
27
|
+
http.start do |h|
|
28
|
+
if respond_to?(:stage)
|
29
|
+
h.post(uri.path, { 'what' => "deploy #{application} in #{stage}",
|
30
|
+
'tags' => "#{application},#{stage},#{real_revision},deploy",
|
31
|
+
'data' => "#{local_user}" }.to_json)
|
32
|
+
else
|
33
|
+
h.post(uri.path, { 'what' => "deploy #{application}",
|
34
|
+
'tags' => "#{application},#{real_revision},deploy",
|
35
|
+
'data' => "#{local_user}" }.to_json)
|
36
|
+
end
|
28
37
|
end
|
38
|
+
rescue => e
|
39
|
+
puts "graphite:notify_deploy failed: #{e.message}"
|
29
40
|
end
|
30
41
|
end
|
31
42
|
|
32
43
|
desc 'notify graphite that a rollback occured'
|
33
44
|
task :notify_rollback, :on_error => :continue do
|
34
|
-
uri = URI
|
35
|
-
Net::HTTP.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
45
|
+
uri = URI(graphite_url)
|
46
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
47
|
+
http.use_ssl = true if uri.scheme == 'https'
|
48
|
+
begin
|
49
|
+
http.start do |h|
|
50
|
+
if respond_to?(:stage)
|
51
|
+
h.post(uri.path, { 'what' => "rollback #{application} in #{stage}",
|
52
|
+
'tags' => "#{application},#{stage},#{real_revision},rollback",
|
53
|
+
'data' => "#{local_user}" }.to_json)
|
54
|
+
else
|
55
|
+
h.post(uri.path, { 'what' => "rollback #{application}",
|
56
|
+
'tags' => "#{application},#{real_revision},rollback",
|
57
|
+
'data' => "#{local_user}" }.to_json)
|
58
|
+
end
|
40
59
|
end
|
60
|
+
rescue => e
|
61
|
+
puts "graphite:notify_rollback failed: #{e.message}"
|
41
62
|
end
|
42
63
|
end
|
43
64
|
end
|
data/spec/capistrano_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
require './lib/graphite-notify/capistrano'
|
4
4
|
|
5
|
-
describe Capistrano::Graphite,
|
5
|
+
describe Capistrano::Graphite, 'loaded into a configuration' do
|
6
6
|
before do
|
7
7
|
ENV['USER'] = 'testuser'
|
8
8
|
@configuration = Capistrano::Configuration.new
|
@@ -19,17 +19,17 @@ describe Capistrano::Graphite, "loaded into a configuration" do
|
|
19
19
|
|
20
20
|
context 'without capistrano-multistage support' do
|
21
21
|
it 'should notify graphite of a deploy' do
|
22
|
-
stub_request(:post,
|
23
|
-
with(:body =>
|
24
|
-
to_return(:status => 200, :body =>
|
22
|
+
stub_request(:post, 'http://localhost/').
|
23
|
+
with(:body => {"what"=>"deploy testapp","tags"=>"testapp,randomsha,deploy","data"=>"testuser"}.to_json).
|
24
|
+
to_return(:status => 200, :body => '', :headers => {})
|
25
25
|
@configuration.find_and_execute_task('graphite:notify_deploy')
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should notify graphite of a rollback' do
|
30
|
-
stub_request(:post,
|
31
|
-
with(:body =>
|
32
|
-
to_return(:status => 200, :body =>
|
30
|
+
stub_request(:post, 'http://localhost/').
|
31
|
+
with(:body => {"what"=>"rollback testapp","tags"=>"testapp,randomsha,rollback","data"=>"testuser"}.to_json).
|
32
|
+
to_return(:status => 200, :body => '', :headers => {})
|
33
33
|
@configuration.find_and_execute_task('graphite:notify_rollback')
|
34
34
|
end
|
35
35
|
end
|
@@ -39,17 +39,17 @@ describe Capistrano::Graphite, "loaded into a configuration" do
|
|
39
39
|
@configuration.set :stage, 'test'
|
40
40
|
end
|
41
41
|
it 'should notify graphite of a deploy' do
|
42
|
-
stub_request(:post,
|
43
|
-
with(:body =>
|
44
|
-
to_return(:status => 200, :body =>
|
42
|
+
stub_request(:post, 'http://localhost/').
|
43
|
+
with(:body => {"what"=>"deploy testapp in test","tags"=>"testapp,test,randomsha,deploy","data"=>"testuser"}.to_json).
|
44
|
+
to_return(:status => 200, :body => '', :headers => {})
|
45
45
|
@configuration.find_and_execute_task('graphite:notify_deploy')
|
46
46
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should notify graphite of a rollback' do
|
50
|
-
stub_request(:post,
|
51
|
-
with(:body =>
|
52
|
-
to_return(:status => 200, :body =>
|
50
|
+
stub_request(:post, 'http://localhost/').
|
51
|
+
with(:body => {"what"=>"rollback testapp in test","tags"=>"testapp,test,randomsha,rollback","data"=>"testuser"}.to_json).
|
52
|
+
to_return(:status => 200, :body => '', :headers => {})
|
53
53
|
@configuration.find_and_execute_task('graphite:notify_rollback')
|
54
54
|
end
|
55
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphite-notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - <
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - <
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - <
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - <
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rake
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +82,7 @@ dependencies:
|
|
66
82
|
requirements:
|
67
83
|
- - ~>
|
68
84
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
85
|
+
version: 1.20.4
|
70
86
|
type: :development
|
71
87
|
prerelease: false
|
72
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +90,7 @@ dependencies:
|
|
74
90
|
requirements:
|
75
91
|
- - ~>
|
76
92
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
93
|
+
version: 1.20.4
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: capistrano-spec
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +98,7 @@ dependencies:
|
|
82
98
|
requirements:
|
83
99
|
- - ~>
|
84
100
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
101
|
+
version: 0.6.3
|
86
102
|
type: :development
|
87
103
|
prerelease: false
|
88
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +106,7 @@ dependencies:
|
|
90
106
|
requirements:
|
91
107
|
- - ~>
|
92
108
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
109
|
+
version: 0.6.3
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
name: yard
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,6 +147,7 @@ extensions: []
|
|
131
147
|
extra_rdoc_files: []
|
132
148
|
files:
|
133
149
|
- .gitignore
|
150
|
+
- .rubocop.yml
|
134
151
|
- .ruby-version
|
135
152
|
- .travis.yml
|
136
153
|
- Changelog.md
|
@@ -145,7 +162,8 @@ files:
|
|
145
162
|
- spec/spec.opts
|
146
163
|
- spec/spec_helper.rb
|
147
164
|
homepage: https://github.com/hellvinz/graphite-notify
|
148
|
-
licenses:
|
165
|
+
licenses:
|
166
|
+
- MIT
|
149
167
|
post_install_message:
|
150
168
|
rdoc_options: []
|
151
169
|
require_paths:
|
@@ -164,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
182
|
version: 1.3.6
|
165
183
|
requirements: []
|
166
184
|
rubyforge_project:
|
167
|
-
rubygems_version: 1.8.23
|
185
|
+
rubygems_version: 1.8.23.2
|
168
186
|
signing_key:
|
169
187
|
specification_version: 3
|
170
188
|
summary: notify graphite on deploy or rollback
|