BibOpsworks 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/bib/opsworks/composer.rb +3 -3
- data/lib/bib/opsworks/google.rb +49 -0
- data/lib/bib/opsworks/version.rb +1 -1
- data/lib/bib/opsworks.rb +6 -0
- data/tests/google_test.rb +40 -0
- metadata +22 -31
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de8e87cbcd343242e47fb3be31b515f37992ba93
|
4
|
+
data.tar.gz: 6082b361f0ad392d7e4fa395f867c693ed21094a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 801fd1862ce38b8f6e69e850d5b09f30be517539a9c3cdbd90fa37dec7ab7ecbd100dac6b612610b6b24f67b94a46cba4e4ba3f76fe8f23a621ab6269c793240
|
7
|
+
data.tar.gz: bbe5d9119ea0c036eac6351b7c2852f8728d5686441e28f7fd889b413ac80ba369104a718dbf747d66fb1da33c7c9343b9a215afedceccb23a0b8a3c7fa14c89
|
@@ -21,11 +21,11 @@ module Bib
|
|
21
21
|
if ::File.exists?(vendor_dir)
|
22
22
|
fileutils_output = StringIO.new
|
23
23
|
::FileUtils.fileutils_output = fileutils_output
|
24
|
-
log.debug("Copy Vendor: Copying from #{vendor_dir} to #{release_vendor}")
|
24
|
+
log.debug("Copy Vendor: Copying from #{vendor_dir} to #{release_vendor}")
|
25
25
|
::FileUtils.cp_r vendor_dir, release_vendor, :verbose => true
|
26
26
|
log.debug(fileutils_output.string)
|
27
27
|
else
|
28
|
-
log.info(
|
28
|
+
log.info("Vendor dir #{vendor_dir} does not exist")
|
29
29
|
end
|
30
30
|
|
31
31
|
if ::File.exists?(release_vendor)
|
@@ -36,7 +36,7 @@ module Bib
|
|
36
36
|
result = ::FileUtils.chown_R deploy_username, deploy_group, release_vendor, :verbose => true
|
37
37
|
log.debug(fileutils_output.string)
|
38
38
|
else
|
39
|
-
log.info(
|
39
|
+
log.info("Release vendor dir #{release_vendor} does not exist")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module Bib
|
4
|
+
module Opsworks
|
5
|
+
class Google
|
6
|
+
|
7
|
+
include Logging
|
8
|
+
|
9
|
+
def publish_deployment(app_name, deploy_data, google_ident)
|
10
|
+
|
11
|
+
google_params = prepare_publishing_data(app_name, deploy_data)
|
12
|
+
|
13
|
+
label = "#{google_params['deployment[user]']}-#{google_params['deployment[revision]']}"
|
14
|
+
query = "tid=#{google_ident}&ea=#{app_name}&el=#{label}"
|
15
|
+
google_url = "http://www.google-analytics.com/collect?v=1&cid=555&t=event&ec=deployment&#{query}"
|
16
|
+
url = URI.parse(google_url)
|
17
|
+
|
18
|
+
request = Net::HTTP::Get.new(url.request_uri)
|
19
|
+
log.debug("google analytics sending data: " + request.inspect)
|
20
|
+
|
21
|
+
http = Net::HTTP.new(url.host, url.port)
|
22
|
+
http.use_ssl = false
|
23
|
+
resp = http.request(request)
|
24
|
+
log.debug("Google Response: " + resp.code + " " + resp.message )
|
25
|
+
resp.is_a? Net::HTTPSuccess
|
26
|
+
end
|
27
|
+
|
28
|
+
def prepare_publishing_data(app_name, deploy_data)
|
29
|
+
scm_revision = deploy_data["scm"]["revision"]
|
30
|
+
|
31
|
+
if deploy_data["deploying_user"].nil? or deploy_data["deploying_user"].empty?
|
32
|
+
deployment_user = "opsworks"
|
33
|
+
else
|
34
|
+
deployment_user = deploy_data["deploying_user"].split('/')[1]
|
35
|
+
end
|
36
|
+
|
37
|
+
google_params = {}
|
38
|
+
{
|
39
|
+
:app_name => app_name,
|
40
|
+
:user => deployment_user,
|
41
|
+
:revision => scm_revision
|
42
|
+
}.each do |k, v|
|
43
|
+
google_params["deployment[#{k}]"] = v unless v.nil? || v == ''
|
44
|
+
end
|
45
|
+
google_params
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/bib/opsworks/version.rb
CHANGED
data/lib/bib/opsworks.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'bib/opsworks/composer'
|
2
2
|
require 'bib/opsworks/newrelic'
|
3
|
+
require 'bib/opsworks/google'
|
3
4
|
require 'bib/opsworks/version'
|
4
5
|
|
5
6
|
class BibOpsworks
|
@@ -17,6 +18,11 @@ class BibOpsworks
|
|
17
18
|
newrelic.publish_deployment(app_name, deploy_data, newrelic_api_key)
|
18
19
|
end
|
19
20
|
|
21
|
+
def google_publish_deployment(app_name, deploy_data, google_ident)
|
22
|
+
google = Bib::Opsworks::Google.new
|
23
|
+
google.publish_deployment(app_name, deploy_data, google_ident)
|
24
|
+
end
|
25
|
+
|
20
26
|
def version
|
21
27
|
Bib::Opsworks::VERSION
|
22
28
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
gem 'minitest'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'bib/opsworks/google'
|
5
|
+
|
6
|
+
class GoogleTest < Minitest::Test
|
7
|
+
|
8
|
+
def test_publish_deployment_user
|
9
|
+
google = Bib::Opsworks::Google.new
|
10
|
+
|
11
|
+
deploy_data = { 'deploying_user' => 'arn:aws:iam::123456:user/gemtest', 'scm' => { 'revision' => 'rev1' } }
|
12
|
+
app_name = 'unittest'
|
13
|
+
|
14
|
+
result = google.prepare_publishing_data(app_name, deploy_data)
|
15
|
+
expected = {"deployment[app_name]"=>"unittest", "deployment[user]"=>"gemtest", "deployment[revision]"=>"rev1"}
|
16
|
+
assert_equal(expected, result)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_publish_deployment_nouser
|
20
|
+
google = Bib::Opsworks::Google.new
|
21
|
+
|
22
|
+
deploy_data = { 'scm' => { 'revision' => 'rev1' } }
|
23
|
+
app_name = 'unittest'
|
24
|
+
|
25
|
+
result = google.prepare_publishing_data(app_name, deploy_data)
|
26
|
+
expected = {"deployment[app_name]"=>"unittest", "deployment[user]"=>"opsworks", "deployment[revision]"=>"rev1"}
|
27
|
+
assert_equal(expected, result)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_publish_deployment
|
31
|
+
google = Bib::Opsworks::Google.new
|
32
|
+
|
33
|
+
deploy_data = { 'deploying_user' => 'arn:aws:iam::123456:user/gemtest', 'scm' => { 'revision' => 'rev1' } }
|
34
|
+
app_name = 'unittest'
|
35
|
+
google_ident = 'UA-1869721-12'
|
36
|
+
result = google.publish_deployment(app_name, deploy_data, google_ident)
|
37
|
+
expected = true
|
38
|
+
assert_equal(expected, result)
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BibOpsworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- fh
|
@@ -10,86 +9,76 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: json
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '0'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: bundler
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- - ~>
|
32
|
+
- - "~>"
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '1.3'
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- - ~>
|
39
|
+
- - "~>"
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '1.3'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: rake
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - ">="
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '0'
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - ">="
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: '0'
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: minitest
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
|
-
- - ~>
|
60
|
+
- - "~>"
|
69
61
|
- !ruby/object:Gem::Version
|
70
62
|
version: 5.0.8
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
|
-
- - ~>
|
67
|
+
- - "~>"
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: 5.0.8
|
79
70
|
- !ruby/object:Gem::Dependency
|
80
71
|
name: coveralls
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
73
|
requirements:
|
84
|
-
- -
|
74
|
+
- - ">="
|
85
75
|
- !ruby/object:Gem::Version
|
86
76
|
version: '0'
|
87
77
|
type: :development
|
88
78
|
prerelease: false
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
80
|
requirements:
|
92
|
-
- -
|
81
|
+
- - ">="
|
93
82
|
- !ruby/object:Gem::Version
|
94
83
|
version: '0'
|
95
84
|
description:
|
@@ -99,8 +88,8 @@ executables: []
|
|
99
88
|
extensions: []
|
100
89
|
extra_rdoc_files: []
|
101
90
|
files:
|
102
|
-
- .gitignore
|
103
|
-
- .travis.yml
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
104
93
|
- BibOpsworks.gemspec
|
105
94
|
- Gemfile
|
106
95
|
- LICENSE.txt
|
@@ -108,34 +97,36 @@ files:
|
|
108
97
|
- Rakefile
|
109
98
|
- lib/bib/opsworks.rb
|
110
99
|
- lib/bib/opsworks/composer.rb
|
100
|
+
- lib/bib/opsworks/google.rb
|
111
101
|
- lib/bib/opsworks/logging.rb
|
112
102
|
- lib/bib/opsworks/newrelic.rb
|
113
103
|
- lib/bib/opsworks/version.rb
|
114
104
|
- tests/composer_test.rb
|
105
|
+
- tests/google_test.rb
|
115
106
|
- tests/newrelic_test.rb
|
116
107
|
homepage: https://github.com/easybiblabs/bib-opsworks
|
117
108
|
licenses:
|
118
109
|
- BSD-2-Clause
|
110
|
+
metadata: {}
|
119
111
|
post_install_message:
|
120
112
|
rdoc_options: []
|
121
113
|
require_paths:
|
122
114
|
- lib
|
123
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
116
|
requirements:
|
126
|
-
- -
|
117
|
+
- - ">="
|
127
118
|
- !ruby/object:Gem::Version
|
128
119
|
version: '0'
|
129
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
121
|
requirements:
|
132
|
-
- -
|
122
|
+
- - ">="
|
133
123
|
- !ruby/object:Gem::Version
|
134
124
|
version: '0'
|
135
125
|
requirements: []
|
136
126
|
rubyforge_project:
|
137
|
-
rubygems_version:
|
127
|
+
rubygems_version: 2.2.2
|
138
128
|
signing_key:
|
139
|
-
specification_version:
|
129
|
+
specification_version: 4
|
140
130
|
summary: Tools wrapper for AWS Opsworks Deploys
|
141
131
|
test_files: []
|
132
|
+
has_rdoc:
|