Class: DPL::Provider::Deis
Instance Attribute Summary
#context, #options
Instance Method Summary
collapse
apt_get, #commit_msg, context, #create_key, #default_text_charset, #default_text_charset?, #deploy, #detect_encoding?, #encoding_for, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #setup_git_credentials, #sha, shell, #uncleanup, #user_agent, #warn
Constructor Details
This class inherits a constructor from DPL::Provider
Instance Method Details
#check_app ⇒ Object
38
39
40
41
42
|
# File 'lib/dpl/provider/deis.rb', line 38
def check_app
unless context.shell "./deis apps:info --app=#{option(:app)}"
error 'Application could not be verified.'
end
end
|
#check_auth ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/dpl/provider/deis.rb', line 30
def check_auth
unless context.shell "./deis login #{option(:controller)}" \
" --username=#{option(:username)}" \
" --password=#{option(:password)}"
error 'Login failed.'
end
end
|
#cleanup ⇒ Object
110
111
112
113
114
115
|
# File 'lib/dpl/provider/deis.rb', line 110
def cleanup
return if options[:skip_cleanup]
context.shell "mv deis ~/deis"
super
context.shell "mv ~/deis deis"
end
|
#determine_install_url ⇒ Object
Default to installing the default v1 client. Otherwise determine if this is a v2 client
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/dpl/provider/deis.rb', line 13
def determine_install_url
if option(:cli_version).nil?
return "http://deis.io/deis-cli/install.sh"
else
version_arg = Gem::Version.new(option(:cli_version).gsub(/^v?V?/,''))
if version_arg >= Gem::Version.new('2.0.0')
return "http://deis.io/deis-cli/install-v2.sh"
else
return "http://deis.io/deis-cli/install.sh"
end
end
end
|
#install_deploy_dependencies ⇒ Object
7
8
9
10
|
# File 'lib/dpl/provider/deis.rb', line 7
def install_deploy_dependencies
install_url = determine_install_url
context.shell "curl -sSL #{install_url} | bash -x -s #{option(:cli_version)}"
end
|
#needs_key? ⇒ Boolean
26
27
28
|
# File 'lib/dpl/provider/deis.rb', line 26
def needs_key?
true
end
|
#push_app ⇒ Object
98
99
100
101
102
|
# File 'lib/dpl/provider/deis.rb', line 98
def push_app
unless context.shell "bash -c 'git push #{verbose_flag} deis HEAD:refs/heads/master -f 2>&1 | tr -dc \"[:alnum:][:space:][:punct:]\" | sed -E \"s/remote: (\\[1G)+//\" | sed \"s/\\[K$//\"; exit ${PIPESTATUS[0]}'"
error 'Deploying application failed.'
end
end
|
#remove_key ⇒ Object
92
93
94
95
96
|
# File 'lib/dpl/provider/deis.rb', line 92
def remove_key
unless context.shell "./deis keys:remove #{option(:key_name)}"
error 'Removing keys failed.'
end
end
|
#run(command) ⇒ Object
104
105
106
107
108
|
# File 'lib/dpl/provider/deis.rb', line 104
def run(command)
unless context.shell "./deis run -- #{command}"
error 'Running command failed.'
end
end
|
#setup_git_ssh(path, key_path) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/dpl/provider/deis.rb', line 50
def setup_git_ssh(path, key_path)
key_path = File.expand_path(key_path)
path = File.expand_path(path)
File.open(path, 'w') do |file|
file.write "#!/bin/sh\n"
file.write "exec ssh #{verbose_flag} -o StrictHostKeychecking=no -o CheckHostIP=no -o UserKnownHostsFile=/dev/null -i #{key_path} \"$@\"\n"
end
chmod(0740, path)
context.env['GIT_SSH'] = path
unless context.shell "./deis git:remote --app=#{option(:app)}"
error 'Adding git remote failed.'
end
wait_for_git_access
end
|
#setup_key(file) ⇒ Object
44
45
46
47
48
|
# File 'lib/dpl/provider/deis.rb', line 44
def setup_key(file)
unless context.shell "./deis keys:add #{file}"
error 'Adding keys failed.'
end
end
|
#verbose_flag ⇒ Object
117
118
119
|
# File 'lib/dpl/provider/deis.rb', line 117
def verbose_flag
'-v' if options[:verbose]
end
|
#wait_for_git_access ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/dpl/provider/deis.rb', line 69
def wait_for_git_access()
retry_count=0
max_retries=30
git=Git.open("./")
git_remote=git.remote("deis").url
remote_uri=git_remote.split("ssh://")[1].split("/")[0]
remote_host, remote_port = remote_uri.split(":")
puts "Git remote is #{remote_host} at port #{remote_port}"
while retry_count < max_retries
puts "Waiting for ssh key to propagate..."
if context.shell "#{context.env['GIT_SSH']} #{remote_host} -p #{remote_port} 2>&1 | grep -c 'PTY allocation request failed' > /dev/null"
puts "SSH connection established."
break
end
retry_count += 1
sleep(1)
end
end
|