Class: DPL::Provider::CloudControl
Instance Attribute Summary collapse
#context, #options
Instance Method Summary
collapse
apt_get, #cleanup, #commit_msg, context, #create_key, #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, #warn
Constructor Details
#initialize(context, options) ⇒ CloudControl
Returns a new instance of CloudControl.
11
12
13
14
15
16
17
18
|
# File 'lib/dpl/provider/cloudcontrol.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.cloudcontrol.com', 443)
@http.use_ssl = true
end
|
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
8
9
10
|
# File 'lib/dpl/provider/cloudcontrol.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/cloudcontrol.rb', line 9
def dep_name
@dep_name
end
|
Instance Method Details
#check_app ⇒ Object
24
25
26
27
28
|
# File 'lib/dpl/provider/cloudcontrol.rb', line 24
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
20
21
22
|
# File 'lib/dpl/provider/cloudcontrol.rb', line 20
def check_auth
end
|
#push_app ⇒ Object
43
44
45
46
47
|
# File 'lib/dpl/provider/cloudcontrol.rb', line 43
def push_app
branch = (dep_name == 'default') ? 'master' : dep_name
context.shell "git push #{ @repository } HEAD:#{ branch } -f"
deploy_app
end
|
#remove_key ⇒ Object
38
39
40
41
|
# File 'lib/dpl/provider/cloudcontrol.rb', line 38
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
30
31
32
33
34
35
36
|
# File 'lib/dpl/provider/cloudcontrol.rb', line 30
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
|