factor-connector-bitballoon 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.
- data/lib/factor/connector/bitballoon.rb +69 -0
- metadata +78 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'factor-connector-api'
|
2
|
+
require 'bitballoon'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
Factor::Connector.service 'bitballoon' do
|
7
|
+
action 'deploy' do |params|
|
8
|
+
api_key = params['api_key']
|
9
|
+
site_id = params['site'] || params['site_id']
|
10
|
+
content = params['content']
|
11
|
+
|
12
|
+
fail 'API Key must be specified' unless api_key
|
13
|
+
fail 'Site ID must be spcified' unless site_id
|
14
|
+
fail 'Content must be specified' unless content
|
15
|
+
|
16
|
+
info 'Getting the resource files from previous step'
|
17
|
+
begin
|
18
|
+
source = Tempfile.new('source')
|
19
|
+
source.write open(content).read
|
20
|
+
source.rewind
|
21
|
+
rescue => ex
|
22
|
+
fail 'Internal error: failed to get resource files', exception: ex
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
bitballoon_settings = {
|
27
|
+
client_id: ENV['BITBALLOON_OAUTH_ID'],
|
28
|
+
client_secret: ENV['BITBALLOON_OAUTH_SECRET'],
|
29
|
+
access_token: api_key
|
30
|
+
}
|
31
|
+
bb = BitBalloon::Client.new(bitballoon_settings)
|
32
|
+
rescue => ex
|
33
|
+
fail "Couldn't initialize BitBalloon connection", exception: ex
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
site = begin
|
38
|
+
bb.sites.get(site_id)
|
39
|
+
rescue
|
40
|
+
bb.sites.get("#{site_id}.bitballoon.com")
|
41
|
+
end
|
42
|
+
rescue => BitBalloon::Client::AuthenticationError
|
43
|
+
fail 'API Key is incorrect. Try refreshing.'
|
44
|
+
end
|
45
|
+
fail "No site found with name, id or url `#{site_id}`" if !site
|
46
|
+
|
47
|
+
begin
|
48
|
+
site.update(zip: source)
|
49
|
+
rescue => ex
|
50
|
+
fail 'BitBalloon had an error when uploading the site.', exception: ex
|
51
|
+
end
|
52
|
+
|
53
|
+
info 'Waiting for processing'
|
54
|
+
begin
|
55
|
+
site.wait_for_ready do |site_state|
|
56
|
+
info "Polling state '#{site_state.state}'"
|
57
|
+
end
|
58
|
+
rescue
|
59
|
+
warn "Couldn't poll status"
|
60
|
+
end
|
61
|
+
|
62
|
+
deploy_info = begin
|
63
|
+
site.deploys.find { |d| d.state == 'current' }.attributes
|
64
|
+
rescue
|
65
|
+
{}
|
66
|
+
end
|
67
|
+
action_callback deploy_info
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: factor-connector-bitballoon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Maciej Skierkowski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bitballoon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.1.6
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: factor-connector-api
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.0.1
|
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: 0.0.1
|
46
|
+
description:
|
47
|
+
email:
|
48
|
+
- maciej@factor.io
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/factor/connector/bitballoon.rb
|
54
|
+
homepage: https://factor.io
|
55
|
+
licenses: []
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.8.25
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: BitBalloon Factor.io Connector
|
78
|
+
test_files: []
|