Class: DPL::Provider::GAE
Constant Summary
collapse
- BASE =
'https://dl.google.com/dl/cloudsdk/channels/rapid/'
- NAME =
'google-cloud-sdk'
- EXT =
'.tar.gz'
- INSTALL =
'~'
- BOOTSTRAP =
"#{INSTALL}/#{NAME}/bin/bootstrapping/install.py"
- GCLOUD =
"#{INSTALL}/#{NAME}/bin/gcloud"
Instance Attribute Summary
#context, #options
Instance Method Summary
collapse
apt_get, #check_app, #cleanup, #commit_msg, context, #create_key, #deploy, #detect_encoding?, #encoding_for, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #user_agent, #warn
Constructor Details
This class inherits a constructor from DPL::Provider
Instance Method Details
#check_auth ⇒ Object
42
43
44
45
46
|
# File 'lib/dpl/provider/gae.rb', line 42
def check_auth
unless context.shell("#{GCLOUD} -q --verbosity debug auth activate-service-account --key-file #{keyfile}")
error 'Authentication failed.'
end
end
|
#config ⇒ Object
60
61
62
|
# File 'lib/dpl/provider/gae.rb', line 60
def config
options[:config] || 'app.yaml'
end
|
#default ⇒ Object
64
65
66
|
# File 'lib/dpl/provider/gae.rb', line 64
def default
options[:default]
end
|
#docker_build ⇒ Object
72
73
74
|
# File 'lib/dpl/provider/gae.rb', line 72
def docker_build
options[:docker_build] || 'remote'
end
|
#install_deploy_dependencies ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/dpl/provider/gae.rb', line 13
def install_deploy_dependencies
if docker_build == "remote" && !File.exists?("#{Dir.home}/.ssh/google_compute_engine")
unless context.shell('ssh-keygen -f ~/.ssh/google_compute_engine -t rsa -N \'\'')
error 'Failed to generate SSH key for remote Docker build.'
end
end
if File.exists? GCLOUD
return
end
$stderr.puts 'Downloading Google Cloud SDK ...'
unless context.shell("curl -L #{BASE + NAME + EXT} | gzip -d | tar -x -C #{INSTALL}")
error 'Could not download Google Cloud SDK.'
end
$stderr.puts 'Bootstrapping Google Cloud SDK ...'
unless context.shell("#{BOOTSTRAP} --usage-reporting=false --command-completion=false --path-update=false --additional-components=preview")
error 'Could not bootstrap Google Cloud SDK.'
end
end
|
#keyfile ⇒ Object
48
49
50
|
# File 'lib/dpl/provider/gae.rb', line 48
def keyfile
options[:keyfile] || context.env['GOOGLECLOUDKEYFILE'] || 'service-account.json'
end
|
#needs_key? ⇒ Boolean
38
39
40
|
# File 'lib/dpl/provider/gae.rb', line 38
def needs_key?
false
end
|
#project ⇒ Object
52
53
54
|
# File 'lib/dpl/provider/gae.rb', line 52
def project
options[:project] || context.env['GOOGLECLOUDPROJECT'] || context.env['CLOUDSDK_CORE_PROJECT'] || File.dirname(context.env['TRAVIS_REPO_SLUG'] || '')
end
|
#push_app ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/dpl/provider/gae.rb', line 76
def push_app
command = GCLOUD
command << ' --quiet'
command << " --verbosity \"#{verbosity}\""
command << " --project \"#{project}\""
command << " preview app deploy \"#{config}\""
command << " --version \"#{version}\""
command << " --docker-build \"#{docker_build}\""
command << (default ? ' --set-default' : '')
unless context.shell(command)
error 'Deployment failed.'
end
end
|
#verbosity ⇒ Object
68
69
70
|
# File 'lib/dpl/provider/gae.rb', line 68
def verbosity
options[:verbosity] || 'warning'
end
|
#version ⇒ Object
56
57
58
|
# File 'lib/dpl/provider/gae.rb', line 56
def version
options[:version] || ''
end
|