BibOpsworks 0.0.2 → 0.0.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bib/opsworks.rb +7 -10
- data/lib/bib/opsworks/composer.rb +7 -7
- data/lib/bib/opsworks/newrelic.rb +9 -19
- data/lib/bib/opsworks/version.rb +1 -1
- data/tests/composer_test.rb +7 -7
- data/tests/newrelic_test.rb +10 -10
- data/tests/opsworks_test.rb +11 -0
- metadata +3 -3
- data/tests/bib_test.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adae563a8593de469e4cbf116f07573b5212498a
|
4
|
+
data.tar.gz: 425726bfe06f281f9324621747dd038afe8c9955
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 133a277ee9bf1ae15e2d164da697c1783b9f3eebe21ca87915fddebdd7c9a503b8ebe3c44437bd0743ac4c56187ffe371c08ea6a23371a3a03fb69b37565cf42
|
7
|
+
data.tar.gz: 7ac2cff747a03524db8dff63100b5e1451f17ae52f2f2f548b0c4c54623cc9b4bec8e438a79fac6c0a798ea531f0db89ab9f545e5175373d0ac6d8b979da9d20
|
data/Gemfile.lock
CHANGED
data/lib/bib/opsworks.rb
CHANGED
@@ -3,21 +3,18 @@ require 'bib/opsworks/newrelic'
|
|
3
3
|
require 'bib/opsworks/version'
|
4
4
|
|
5
5
|
class BibOpsworks
|
6
|
-
def initialize(deploy_data)
|
7
|
-
@deploy_data = deploy_data
|
8
|
-
end
|
9
6
|
|
10
|
-
def copy_composer(release_path)
|
11
|
-
composer = Bib::Opsworks::Composer.new
|
12
|
-
composer.copy_vendor(release_path,
|
7
|
+
def copy_composer(release_path, deploy_user)
|
8
|
+
composer = Bib::Opsworks::Composer.new
|
9
|
+
composer.copy_vendor(release_path, deploy_user)
|
13
10
|
end
|
14
11
|
|
15
|
-
def newrelic_publish_deployment(app_name, newrelic_api_key)
|
16
|
-
newrelic = Bib::Opsworks::Newrelic.new
|
17
|
-
newrelic.publish_deployment(app_name,
|
12
|
+
def newrelic_publish_deployment(app_name, deploy_data, newrelic_api_key)
|
13
|
+
newrelic = Bib::Opsworks::Newrelic.new
|
14
|
+
newrelic.publish_deployment(app_name, deploy_data, newrelic_api_key)
|
18
15
|
end
|
19
16
|
|
20
17
|
def version
|
21
|
-
|
18
|
+
Bib::Opsworks::VERSION
|
22
19
|
end
|
23
20
|
end
|
@@ -2,18 +2,18 @@ module Bib
|
|
2
2
|
module Opsworks
|
3
3
|
class Composer
|
4
4
|
|
5
|
-
def copy_vendor(release_path,
|
5
|
+
def copy_vendor(release_path, deploy_user)
|
6
6
|
app_current = ::File.expand_path("#{release_path}/../../current")
|
7
7
|
vendor_dir = "#{app_current}/vendor"
|
8
|
-
|
9
|
-
|
10
|
-
deploy_group
|
8
|
+
|
9
|
+
deploy_username = deploy_user['user']
|
10
|
+
deploy_group = deploy_user['group']
|
11
11
|
|
12
12
|
release_vendor = "#{release_path}/vendor"
|
13
|
-
|
13
|
+
|
14
14
|
::FileUtils.cp_r vendor_dir, release_vendor if ::File.exists?(vendor_dir)
|
15
|
-
::FileUtils.chown_R
|
15
|
+
::FileUtils.chown_R deploy_username, deploy_group, release_vendor if ::File.exists?(release_vendor)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -4,27 +4,20 @@ module Bib
|
|
4
4
|
class Newrelic
|
5
5
|
|
6
6
|
def publish_deployment(app_name, deploy_data, newrelic_api_key)
|
7
|
-
|
8
7
|
newrelic_body = prepare_publishing_data(app_name, deploy_data)
|
9
|
-
|
8
|
+
|
10
9
|
newrelic_url = "https://rpm.newrelic.com/deployments.xml"
|
11
10
|
url = URI.parse(newrelic_url)
|
12
11
|
request = Net::HTTP::Post.new(url.request_uri)
|
13
12
|
request.add_field('X-License-Key', newrelic_api_key)
|
14
13
|
request.body = newrelic_body
|
15
14
|
resp = Net::HTTP.new(url.host, url.port).start do |http|
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
case resp
|
20
|
-
when Net::HTTPOK
|
21
|
-
return true
|
22
|
-
else
|
23
|
-
return false
|
15
|
+
http.request(request)
|
24
16
|
end
|
25
|
-
|
17
|
+
|
18
|
+
resp.is_a? Net::HTTPOK
|
26
19
|
end
|
27
|
-
|
20
|
+
|
28
21
|
def prepare_publishing_data(app_name, deploy_data)
|
29
22
|
scm_revision = deploy_data["scm"]["revision"]
|
30
23
|
|
@@ -33,16 +26,13 @@ module Bib
|
|
33
26
|
else
|
34
27
|
deployment_user = deploy_data["deploying_user"].split('/')[1]
|
35
28
|
end
|
36
|
-
|
29
|
+
|
37
30
|
newrelic_appid_body = "deployment[app_name]=#{app_name}"
|
38
31
|
newrelic_user_body = "deployment[user]=#{deployment_user}"
|
39
32
|
newrelic_revision_body = "deployment[revision]=#{scm_revision}"
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
return newrelic_body
|
44
|
-
|
33
|
+
|
34
|
+
"#{newrelic_appid_body}&#{newrelic_user_body}&#{newrelic_revision_body}"
|
45
35
|
end
|
46
36
|
end
|
47
37
|
end
|
48
|
-
end
|
38
|
+
end
|
data/lib/bib/opsworks/version.rb
CHANGED
data/tests/composer_test.rb
CHANGED
@@ -8,7 +8,7 @@ class ComposerTest < Minitest::Test
|
|
8
8
|
@fixtures_path ||= Pathname.new(File.expand_path('../tmp-fixtures/', __FILE__)).tap{|path|
|
9
9
|
FileUtils.mkdir_p path.to_s
|
10
10
|
}
|
11
|
-
|
11
|
+
|
12
12
|
@release_path = Pathname.new(File.expand_path('releases/123/', @fixtures_path))
|
13
13
|
FileUtils.mkdir_p @release_path
|
14
14
|
FileUtils.mkdir_p Pathname.new(File.expand_path('current/vendor/some-lib', @fixtures_path))
|
@@ -17,14 +17,14 @@ class ComposerTest < Minitest::Test
|
|
17
17
|
def teardown
|
18
18
|
FileUtils.rm_rf @fixtures_path
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def test_composer_copy
|
22
|
-
composervendor = Bib::Opsworks::Composer.new
|
23
|
-
|
22
|
+
composervendor = Bib::Opsworks::Composer.new
|
23
|
+
|
24
24
|
#do not use www-data, or the test will fail on systems without that user
|
25
|
-
|
26
|
-
|
27
|
-
composervendor.copy_vendor(@release_path,
|
25
|
+
deploy_user = { 'user' => Process.uid, 'group' => Process.gid }
|
26
|
+
|
27
|
+
composervendor.copy_vendor(@release_path, deploy_user)
|
28
28
|
assert_equal(true,::File.exists?(File.expand_path('releases/123/vendor/some-lib',@fixtures_path)))
|
29
29
|
end
|
30
30
|
end
|
data/tests/newrelic_test.rb
CHANGED
@@ -4,24 +4,24 @@ require 'minitest/autorun'
|
|
4
4
|
require 'bib/opsworks/newrelic'
|
5
5
|
|
6
6
|
class NewrelicTest < Minitest::Test
|
7
|
-
|
7
|
+
|
8
8
|
def test_publish_deployment
|
9
|
-
newrelic = Bib::Opsworks::Newrelic.new
|
10
|
-
|
9
|
+
newrelic = Bib::Opsworks::Newrelic.new
|
10
|
+
|
11
11
|
deploy_data = { 'deploying_user' => 'arn:aws:iam::123456:user/gemtest', 'scm' => { 'revision' => 'rev1' } }
|
12
12
|
app_name = 'unittest'
|
13
|
-
|
13
|
+
|
14
14
|
result = newrelic.prepare_publishing_data(app_name, deploy_data)
|
15
|
-
assert_equal("deployment[app_name]=unittest&deployment[user]=gemtest
|
15
|
+
assert_equal("deployment[app_name]=unittest&deployment[user]=gemtest&deployment[revision]=rev1", result)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def test_publish_deployment_nouser
|
19
|
-
newrelic = Bib::Opsworks::Newrelic.new
|
20
|
-
|
19
|
+
newrelic = Bib::Opsworks::Newrelic.new
|
20
|
+
|
21
21
|
deploy_data = { 'scm' => { 'revision' => 'rev1' } }
|
22
22
|
app_name = 'unittest'
|
23
|
-
|
23
|
+
|
24
24
|
result = newrelic.prepare_publishing_data(app_name, deploy_data)
|
25
|
-
assert_equal("deployment[app_name]=unittest&deployment[user]=opsworks
|
25
|
+
assert_equal("deployment[app_name]=unittest&deployment[user]=opsworks&deployment[revision]=rev1", result)
|
26
26
|
end
|
27
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BibOpsworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fh
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -99,9 +99,9 @@ files:
|
|
99
99
|
- lib/bib/opsworks/composer.rb
|
100
100
|
- lib/bib/opsworks/newrelic.rb
|
101
101
|
- lib/bib/opsworks/version.rb
|
102
|
-
- tests/bib_test.rb
|
103
102
|
- tests/composer_test.rb
|
104
103
|
- tests/newrelic_test.rb
|
104
|
+
- tests/opsworks_test.rb
|
105
105
|
homepage: https://github.com/easybiblabs/bib-opsworks
|
106
106
|
licenses: []
|
107
107
|
metadata: {}
|