Class: DPL::Provider::ExoScale
Instance Attribute Summary collapse
#context, #options
Instance Method Summary
collapse
apt_get, #cleanup, #commit_msg, context, #create_key, #default_text_charset, #default_text_charset?, #deploy, #detect_encoding?, #encoding_for, #error, experimental, #log, #needs_key?, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #user_agent, #warn
Constructor Details
#initialize(context, options) ⇒ ExoScale
Returns a new instance of ExoScale.
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/dpl/provider/exoscale.rb', line 11
def initialize(context, options)
super
option(:email) && option(:password) && option(:deployment)
@app_name, @dep_name = options[:deployment].split('/')
@http = Net::HTTP.new('api.app.exo.io', 443)
@http.use_ssl = true
@tokenHttp = Net::HTTP.new('portal.exoscale.ch', 443)
@tokenHttp.use_ssl = true
end
|
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
8
9
10
|
# File 'lib/dpl/provider/exoscale.rb', line 8
def app_name
@app_name
end
|
#dep_name ⇒ Object
Returns the value of attribute dep_name.
9
10
11
|
# File 'lib/dpl/provider/exoscale.rb', line 9
def dep_name
@dep_name
end
|
Instance Method Details
#check_app ⇒ Object
27
28
29
30
31
|
# File 'lib/dpl/provider/exoscale.rb', line 27
def check_app
response = api_call('GET', "/app/#{ app_name }/deployment/#{ dep_name }")
error('application check failed') if response.code != '200'
@repository = JSON.parse(response.body)["branch"]
end
|
#check_auth ⇒ Object
23
24
25
|
# File 'lib/dpl/provider/exoscale.rb', line 23
def check_auth
end
|
#push_app ⇒ Object
46
47
48
49
50
|
# File 'lib/dpl/provider/exoscale.rb', line 46
def push_app
branch = (dep_name == 'default') ? 'master' : dep_name
context.shell "git push #{ @repository } HEAD:#{ branch } -f"
deploy_app
end
|
#remove_key ⇒ Object
41
42
43
44
|
# File 'lib/dpl/provider/exoscale.rb', line 41
def remove_key
response = api_call('DELETE', "/user/#{ user['username']}/key/#{ @ssh_key_id }")
error('key removal failed') if response.code != '204'
end
|
#setup_key(file) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/dpl/provider/exoscale.rb', line 33
def setup_key(file)
data = { 'key' => File.read(file).chomp }
response = api_call('POST', "/user/#{ user['username'] }/key", JSON.dump(data))
error('adding key failed') if response.code != '200'
key = JSON.parse response.body
@ssh_key_id = key['key_id']
end
|