appengine 0.4.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,6 @@
1
- # Copyright 2017 Google Inc. All rights reserved.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 Google LLC
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
4
6
  # you may not use this file except in compliance with the License.
@@ -11,19 +13,14 @@
11
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
- ;
15
16
 
16
- # This file should be loaded or required from a Rakefile to define AppEngine
17
- # related tasks.
18
17
 
19
18
  require "shellwords"
20
19
 
21
20
  require "appengine/util/gcloud"
22
21
  require "appengine/exec"
23
22
 
24
-
25
23
  module AppEngine
26
-
27
24
  ##
28
25
  # # App Engine Rake Tasks.
29
26
  #
@@ -66,6 +63,16 @@ module AppEngine
66
63
  #
67
64
  # The following environment variable parameters are supported:
68
65
  #
66
+ # #### GAE_TIMEOUT
67
+ #
68
+ # Amount of time to wait before appengine:exec terminates the command.
69
+ # Expressed as a string formatted like: "2h15m10s". Default is "10m".
70
+ #
71
+ # #### GAE_PROJECT
72
+ #
73
+ # The ID of your Google Cloud project. If not specified, uses the current
74
+ # project from gcloud.
75
+ #
69
76
  # #### GAE_CONFIG
70
77
  #
71
78
  # Path to the App Engine config file, used when your app has multiple
@@ -74,22 +81,47 @@ module AppEngine
74
81
  #
75
82
  # #### GAE_SERVICE
76
83
  #
77
- # Name of the service to be used. If both `GAE_CONFIG` and `GAE_SERVICE` are
78
- # provided and imply different service names, an error will be raised.
84
+ # Name of the service to be used. Overrides any service name specified in
85
+ # your config file.
86
+ #
87
+ # #### GAE_EXEC_STRATEGY
88
+ #
89
+ # The execution strategy to use. Valid values are "deployment" (which is the
90
+ # default for App Engine Standard apps) and "cloud_build" (which is the
91
+ # default for App Engine Flexible apps).
92
+ #
93
+ # Normally you should leave the strategy set to the default. The main reason
94
+ # to change it is if your app runs on the Flexible Environment and talks to
95
+ # a database over a VPC (using a private IP address). The "cloud_build"
96
+ # strategy used by default for Flexible apps cannot connect to a VPC, so you
97
+ # should use "deployment" in this case. (But note that, otherwise, the
98
+ # "deployment" strategy is significantly slower for apps on the Flexible
99
+ # environment.)
79
100
  #
80
101
  # #### GAE_VERSION
81
102
  #
82
103
  # The version of the service, used to identify which application image to
83
104
  # use to run your command. If not specified, uses the most recently created
84
105
  # version, regardless of whether that version is actually serving traffic.
106
+ # Applies only to the "cloud_build" strategy. (The "deployment" strategy
107
+ # deploys its own temporary version of your app.)
85
108
  #
86
- # #### GAE_TIMEOUT
109
+ # #### GAE_EXEC_WRAPPER_IMAGE
87
110
  #
88
- # Amount of time to wait before appengine:exec terminates the command.
89
- # Expressed as a string formatted like: "2h15m10s". Default is "10m".
111
+ # The fully-qualified name of the wrapper image to use. (This is a Docker
112
+ # image that emulates the App Engine environment in Google Cloud Build for
113
+ # the "cloud_build" strategy, and applies only to that strategy.) Normally,
114
+ # you should not override this unless you are testing a new wrapper.
115
+ #
116
+ # #### CLOUD_BUILD_GCS_LOG_DIR
90
117
  #
118
+ # GCS bucket name of the cloud build log when GAE_STRATEGY is "cloud_build".
119
+ # (ex. "gs://BUCKET-NAME/FOLDER-NAME")
91
120
  module Tasks
92
-
121
+ ## @private
122
+ PROJECT_ENV = "GAE_PROJECT"
123
+ ## @private
124
+ STRATEGY_ENV = "GAE_EXEC_STRATEGY"
93
125
  ## @private
94
126
  CONFIG_ENV = "GAE_CONFIG"
95
127
  ## @private
@@ -100,11 +132,12 @@ module AppEngine
100
132
  TIMEOUT_ENV = "GAE_TIMEOUT"
101
133
  ## @private
102
134
  WRAPPER_IMAGE_ENV = "GAE_EXEC_WRAPPER_IMAGE"
135
+ ## @private
136
+ GCS_LOG_DIR = "CLOUD_BUILD_GCS_LOG_DIR"
103
137
 
104
138
  @defined = false
105
139
 
106
140
  class << self
107
-
108
141
  ##
109
142
  # @private
110
143
  # Define rake tasks.
@@ -123,189 +156,230 @@ module AppEngine
123
156
 
124
157
  def setup_exec_task
125
158
  ::Rake.application.last_description =
126
- "Execute the given command in Google App Engine."
127
- ::Rake::Task.define_task "appengine:exec", [:cmd] do |t, args|
159
+ "Execute the given command in Google App Engine."
160
+ ::Rake::Task.define_task "appengine:exec", [:cmd] do |_t, args|
128
161
  verify_gcloud_and_report_errors
129
- if args[:cmd]
130
- command = ::Shellwords.split args[:cmd]
131
- else
132
- i = (::ARGV.index{ |a| a.to_s == "--" } || -1) + 1
133
- if i == 0
134
- report_error <<-MESSAGE
135
- No command provided for appengine:exec.
136
- Did you remember to delimit it with two dashes? e.g.
137
- bundle exec rake appengine:exec -- bundle exec ruby myscript.rb
138
- For detailed usage instructions, provide two dashes but no command:
139
- bundle exec rake appengine:exec --
140
- MESSAGE
141
- end
142
- command = ::ARGV[i..-1]
143
- if command.empty?
144
- show_usage
145
- exit
146
- end
147
- end
148
- app_exec = Exec.new \
149
- command,
150
- service: ::ENV[SERVICE_ENV],
151
- config_path: ::ENV[CONFIG_ENV],
152
- version: ::ENV[VERSION_ENV],
153
- timeout: ::ENV[TIMEOUT_ENV],
154
- wrapper_image: ::ENV[WRAPPER_IMAGE_ENV]
162
+ command = extract_command args[:cmd], ::ARGV
163
+ app_exec = Exec.new command,
164
+ project: ::ENV[PROJECT_ENV],
165
+ service: ::ENV[SERVICE_ENV],
166
+ config_path: ::ENV[CONFIG_ENV],
167
+ version: ::ENV[VERSION_ENV],
168
+ timeout: ::ENV[TIMEOUT_ENV],
169
+ wrapper_image: ::ENV[WRAPPER_IMAGE_ENV],
170
+ strategy: ::ENV[STRATEGY_ENV],
171
+ gcs_log_dir: ::ENV[GCS_LOG_DIR]
155
172
  start_and_report_errors app_exec
156
173
  exit
157
174
  end
158
175
  end
159
176
 
177
+ def extract_command cmd, argv
178
+ if cmd
179
+ ::Shellwords.split cmd
180
+ else
181
+ i = (argv.index { |a| a.to_s == "--" } || -1) + 1
182
+ if i.zero?
183
+ report_error <<~MESSAGE
184
+ No command provided for appengine:exec.
185
+ Did you remember to delimit it with two dashes? e.g.
186
+ bundle exec rake appengine:exec -- bundle exec ruby myscript.rb
187
+ For detailed usage instructions, provide two dashes but no command:
188
+ bundle exec rake appengine:exec --
189
+ MESSAGE
190
+ end
191
+ command = ::ARGV[i..-1]
192
+ if command.empty?
193
+ show_usage
194
+ exit
195
+ end
196
+ command
197
+ end
198
+ end
199
+
160
200
  def show_usage
161
- puts <<-USAGE
162
- rake appengine:exec
201
+ puts <<~USAGE
202
+ rake appengine:exec
203
+
204
+ This Rake task executes a given command in the context of an App Engine
205
+ application, using App Engine remote execution. For more information,
206
+ on this capability, see the AppEngine::Exec documentation at
207
+ http://www.rubydoc.info/gems/appengine/AppEngine/Exec
208
+
209
+ The command to be run may either be provided as a rake argument, or as
210
+ command line arguments delimited by two dashes `--`. (The dashes are
211
+ needed to separate your command from rake arguments and flags.)
212
+ For example, to run a production database migration, you can run either
213
+ of the following equivalent commands:
214
+
215
+ bundle exec rake "appengine:exec[bundle exec bin/rails db:migrate]"
216
+ bundle exec rake appengine:exec -- bundle exec bin/rails db:migrate
217
+
218
+ To display these usage instructions, provide two dashes but no command:
163
219
 
164
- This Rake task executes a given command in the context of an App Engine
165
- application, using App Engine remote execution. For more information,
166
- on this capability, see the AppEngine::Exec documentation at
167
- http://www.rubydoc.info/gems/appengine/AppEngine/Exec
220
+ bundle exec rake appengine:exec --
168
221
 
169
- The command to be run may either be provided as a rake argument, or as
170
- command line arguments delimited by two dashes `--`. (The dashes are
171
- needed to separate your command from rake arguments and flags.)
172
- For example, to run a production database migration, you can run either
173
- of the following equivalent commands:
222
+ You may customize the behavior of App Engine execution through a few
223
+ enviroment variable parameters. These are set via the normal mechanism at
224
+ the end of a rake command line but before the double dash. For example, to
225
+ set GAE_CONFIG:
174
226
 
175
- bundle exec rake "appengine:exec[bundle exec bin/rails db:migrate]"
176
- bundle exec rake appengine:exec -- bundle exec bin/rails db:migrate
227
+ bundle exec rake appengine:exec GAE_CONFIG=myservice.yaml -- bundle exec bin/rails db:migrate
177
228
 
178
- To display these usage instructions, provide two dashes but no command:
229
+ Be sure to set these parameters before the double dash. Any arguments
230
+ following the double dash are interpreted as part of the command itself.
179
231
 
180
- bundle exec rake appengine:exec --
232
+ The following environment variable parameters are supported:
181
233
 
182
- You may customize the behavior of App Engine execution through a few
183
- enviroment variable parameters. These are set via the normal mechanism at
184
- the end of a rake command line. For example, to set GAE_CONFIG:
234
+ GAE_TIMEOUT
185
235
 
186
- bundle exec rake appengine:exec GAE_CONFIG=myservice.yaml -- bundle exec bin/rails db:migrate
236
+ Amount of time to wait before appengine:exec terminates the command.
237
+ Expressed as a string formatted like: "2h15m10s". Default is "10m".
187
238
 
188
- Be sure to set these parameters before the double dash. Any arguments
189
- following the double dash are interpreted as part of the command itself.
239
+ GAE_PROJECT
190
240
 
191
- The following environment variable parameters are supported:
241
+ The ID of your Google Cloud project. If not specified, uses the current
242
+ project from gcloud.
192
243
 
193
- GAE_CONFIG
244
+ GAE_CONFIG
194
245
 
195
- Path to the App Engine config file, used when your app has multiple
196
- services, or the config file is otherwise not called `./app.yaml`. The
197
- config file is used to determine the name of the App Engine service.
246
+ Path to the App Engine config file, used when your app has multiple
247
+ services, or the config file is otherwise not called `./app.yaml`. The
248
+ config file is used to determine the name of the App Engine service.
198
249
 
199
- GAE_SERVICE
250
+ GAE_SERVICE
200
251
 
201
- Name of the service to be used. If both `GAE_CONFIG` and `GAE_SERVICE`
202
- are provided and imply different service names, an error will be raised.
252
+ Name of the service to be used. Overrides any service name specified in
253
+ your config file.
203
254
 
204
- GAE_VERSION
255
+ GAE_EXEC_STRATEGY
205
256
 
206
- The version of the service, used to identify which application image to
207
- use to run your command. If not specified, uses the most recently created
208
- version, regardless of whether that version is actually serving traffic.
257
+ The execution strategy to use. Valid values are "deployment" (which is the
258
+ default for App Engine Standard apps) and "cloud_build" (which is the
259
+ default for App Engine Flexible apps).
209
260
 
210
- GAE_TIMEOUT
261
+ Normally you should leave the strategy set to the default. The main reason
262
+ to change it is if your app runs on the Flexible Environment and talks to
263
+ a database over a VPC (using a private IP address). The "cloud_build"
264
+ strategy used by default for Flexible apps cannot connect to a VPC, so you
265
+ should use "deployment" in this case. (But note that, otherwise, the
266
+ "deployment" strategy is significantly slower for apps on the Flexible
267
+ environment.)
211
268
 
212
- Amount of time to wait before appengine:exec terminates the command.
213
- Expressed as a string formatted like: "2h15m10s". Default is "10m".
269
+ GAE_VERSION
214
270
 
215
- This rake task is provided by the "appengine" gem. To make these tasks
216
- available, add the following line to your Rakefile:
271
+ The version of the service, used to identify which application image to
272
+ use to run your command. If not specified, uses the most recently created
273
+ version, regardless of whether that version is actually serving traffic.
274
+ Applies only to the "cloud_build" strategy. (The "deployment" strategy
275
+ deploys its own temporary version of your app.)
217
276
 
218
- require "appengine/tasks"
277
+ GAE_EXEC_WRAPPER_IMAGE
219
278
 
220
- If your app uses Ruby on Rails, the gem provides a railtie that adds its
221
- tasks automatically, so you don't have to do anything beyond adding the
222
- gem to your Gemfile.
279
+ The fully-qualified name of the wrapper image to use. (This is a Docker
280
+ image that emulates the App Engine environment in Google Cloud Build for
281
+ the "cloud_build" strategy, and applies only to that strategy.) Normally,
282
+ you should not override this unless you are testing a new wrapper.
223
283
 
224
- For more information or to report issues, visit the Github page:
225
- https://github.com/GoogleCloudPlatform/appengine-ruby
284
+ CLOUD_BUILD_GCS_LOG_DIR
285
+
286
+ GCS bucket name of the cloud build log when GAE_STRATEGY is "cloud_build".
287
+ (ex. "gs://BUCKET-NAME/FOLDER-NAME")
288
+
289
+ This rake task is provided by the "appengine" gem. To make these tasks
290
+ available, add the following line to your Rakefile:
291
+
292
+ require "appengine/tasks"
293
+
294
+ If your app uses Ruby on Rails, the gem provides a railtie that adds its
295
+ tasks automatically, so you don't have to do anything beyond adding the
296
+ gem to your Gemfile.
297
+
298
+ For more information or to report issues, visit the Github page:
299
+ https://github.com/GoogleCloudPlatform/appengine-ruby
226
300
  USAGE
227
301
  end
228
302
 
229
303
  def verify_gcloud_and_report_errors
230
304
  Util::Gcloud.verify!
231
305
  rescue Util::Gcloud::BinaryNotFound
232
- report_error <<-MESSAGE
233
- Could not find the `gcloud` binary in your system path.
234
- This tool requires the Google Cloud SDK. To download and install it,
235
- visit https://cloud.google.com/sdk/downloads
306
+ report_error <<~MESSAGE
307
+ Could not find the `gcloud` binary in your system path.
308
+ This tool requires the Google Cloud SDK. To download and install it,
309
+ visit https://cloud.google.com/sdk/downloads
236
310
  MESSAGE
237
311
  rescue Util::Gcloud::GcloudNotAuthenticated
238
- report_error <<-MESSAGE
239
- The gcloud authorization has not been completed. If you have not yet
240
- initialized the Google Cloud SDK, we recommend running the `gcloud init`
241
- command as described at https://cloud.google.com/sdk/docs/initializing
242
- Alternately, you may log in directly by running `gcloud auth login`.
312
+ report_error <<~MESSAGE
313
+ The gcloud authorization has not been completed. If you have not yet
314
+ initialized the Google Cloud SDK, we recommend running the `gcloud init`
315
+ command as described at https://cloud.google.com/sdk/docs/initializing
316
+ Alternately, you may log in directly by running `gcloud auth login`.
243
317
  MESSAGE
244
318
  rescue Util::Gcloud::ProjectNotSet
245
- report_error <<-MESSAGE
246
- The gcloud project configuration has not been set. If you have not yet
247
- initialized the Google Cloud SDK, we recommend running the `gcloud init`
248
- command as described at https://cloud.google.com/sdk/docs/initializing
249
- Alternately, you may set the default project configuration directly by
250
- running `gcloud config set project <project-name>`.
319
+ report_error <<~MESSAGE
320
+ The gcloud project configuration has not been set. If you have not yet
321
+ initialized the Google Cloud SDK, we recommend running the `gcloud init`
322
+ command as described at https://cloud.google.com/sdk/docs/initializing
323
+ Alternately, you may set the default project configuration directly by
324
+ running `gcloud config set project <project-name>`.
251
325
  MESSAGE
252
326
  end
253
327
 
254
328
  def start_and_report_errors app_exec
255
329
  app_exec.start
256
- rescue Exec::ConfigFileNotFound => ex
257
- report_error <<-MESSAGE
258
- Could not determine which service should run this command because the App
259
- Engine config file "#{ex.config_path}" was not found.
260
- Specify the config file using the GAE_CONFIG argument. e.g.
261
- bundle exec rake appengine:exec GAE_CONFIG=myapp.yaml -- myscript.sh
262
- Alternately, you may specify a service name directly with GAE_SERVICE. e.g.
263
- bundle exec rake appengine:exec GAE_SERVICE=myservice -- myscript.sh
264
- MESSAGE
265
- rescue Exec::BadConfigFileFormat => ex
266
- report_error <<-MESSAGE
267
- Could not determine which service should run this command because the App
268
- Engine config file "#{ex.config_path}" was malformed.
269
- It must be a valid YAML file.
270
- Specify the config file using the GAE_CONFIG argument. e.g.
271
- bundle exec rake appengine:exec GAE_CONFIG=myapp.yaml -- myscript.sh
272
- Alternately, you may specify a service name directly with GAE_SERVICE. e.g.
273
- bundle exec rake appengine:exec GAE_SERVICE=myservice -- myscript.sh
274
- MESSAGE
275
- rescue Exec::NoSuchVersion => ex
276
- if ex.version
277
- report_error <<-MESSAGE
278
- Could not find version "#{ex.version}" of service "#{ex.service}".
279
- Please double-check the version exists. To use the most recent version by
280
- default, omit the GAE_VERSION argument.
281
- MESSAGE
330
+ rescue Exec::ConfigFileNotFound => e
331
+ report_error <<~MESSAGE
332
+ Could not determine which service should run this command because the App
333
+ Engine config file "#{e.config_path}" was not found.
334
+ Specify the config file using the GAE_CONFIG argument. e.g.
335
+ bundle exec rake appengine:exec GAE_CONFIG=myapp.yaml -- myscript.sh
336
+ Alternately, you may specify a service name directly with GAE_SERVICE. e.g.
337
+ bundle exec rake appengine:exec GAE_SERVICE=myservice -- myscript.sh
338
+ MESSAGE
339
+ rescue Exec::BadConfigFileFormat => e
340
+ report_error <<~MESSAGE
341
+ Could not determine which service should run this command because the App
342
+ Engine config file "#{e.config_path}" was malformed.
343
+ It must be a valid YAML file.
344
+ Specify the config file using the GAE_CONFIG argument. e.g.
345
+ bundle exec rake appengine:exec GAE_CONFIG=myapp.yaml -- myscript.sh
346
+ Alternately, you may specify a service name directly with GAE_SERVICE. e.g.
347
+ bundle exec rake appengine:exec GAE_SERVICE=myservice -- myscript.sh
348
+ MESSAGE
349
+ rescue Exec::NoSuchVersion => e
350
+ if e.version
351
+ report_error <<~MESSAGE
352
+ Could not find version "#{e.version}" of service "#{e.service}".
353
+ Please double-check the version exists. To use the most recent version by
354
+ default, omit the GAE_VERSION argument.
355
+ MESSAGE
282
356
  else
283
- report_error <<-MESSAGE
284
- Could not find any versions of service "#{ex.service}".
285
- Please double-check that you have deployed this service. If you want to run
286
- a command against a different service, you may provide a GAE_CONFIG argument
287
- pointing to your App Engine config file, or a GAE_SERVICE argument to specify
288
- a service directly.
289
- MESSAGE
357
+ report_error <<~MESSAGE
358
+ Could not find any versions of service "#{e.service}".
359
+ Please double-check that you have deployed this service. If you want to run
360
+ a command against a different service, you may provide a GAE_CONFIG argument
361
+ pointing to your App Engine config file, or a GAE_SERVICE argument to specify
362
+ a service directly.
363
+ MESSAGE
290
364
  end
291
- rescue Exec::ServiceNameConflict => ex
292
- report_error <<-MESSAGE
293
- The explicit service name "#{ex.service_name}" was requested
294
- but conflicts with the service "#{ex.config_name}" from the
295
- config file "#{ex.config_path}"
296
- You should specify either GAE_SERVICE or GAE_CONFIG but not both.
297
- MESSAGE
365
+ rescue Exec::NoDefaultProject
366
+ report_error <<~MESSAGE
367
+ Could not get the default project from gcloud.
368
+ Please either set the current project using
369
+ gcloud config set project my-project-id
370
+ or specify the project by setting the GAE_PROJECT argument. e.g.
371
+ bundle exec rake appengine:exec GAE_PROJECT=my-project-id -- myscript.sh
372
+ MESSAGE
373
+ rescue Exec::UsageError => e
374
+ report_error e.message
298
375
  end
299
376
 
300
377
  def report_error str
301
- ::STDERR.puts str
378
+ warn str
302
379
  exit 1
303
380
  end
304
-
305
381
  end
306
-
307
382
  end
308
383
  end
309
384
 
310
-
311
385
  ::AppEngine::Tasks.define
@@ -1,4 +1,6 @@
1
- # Copyright 2017 Google Inc. All rights reserved.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 Google LLC
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
4
6
  # you may not use this file except in compliance with the License.
@@ -11,20 +13,18 @@
11
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
- ;
15
16
 
16
- require "shellwords"
17
17
 
18
+ require "shellwords"
19
+ require "English"
18
20
 
19
21
  module AppEngine
20
22
  module Util
21
-
22
23
  ##
23
24
  # A collection of utility functions and classes for interacting with an
24
25
  # installation of the gcloud SDK.
25
26
  #
26
27
  module Gcloud
27
-
28
28
  ##
29
29
  # Base class for gcloud related errors.
30
30
  #
@@ -68,7 +68,6 @@ module AppEngine
68
68
  end
69
69
 
70
70
  class << self
71
-
72
71
  ##
73
72
  # @private
74
73
  # Returns the path to the gcloud binary, or nil if the binary could
@@ -78,12 +77,13 @@ module AppEngine
78
77
  #
79
78
  def binary_path
80
79
  unless defined? @binary_path
81
- if Gem.win_platform?
82
- @binary_path = `where gcloud` == '' ? nil : 'gcloud'
83
- else
84
- @binary_path = `which gcloud`.strip
85
- @binary_path = nil if @binary_path.empty?
86
- end
80
+ @binary_path =
81
+ if ::Gem.win_platform?
82
+ `where gcloud` == "" ? nil : "gcloud"
83
+ else
84
+ path = `which gcloud`.strip
85
+ path.empty? ? nil : path
86
+ end
87
87
  end
88
88
  @binary_path
89
89
  end
@@ -111,9 +111,10 @@ module AppEngine
111
111
  #
112
112
  def current_project
113
113
  unless defined? @current_project
114
- @current_project = execute [
114
+ params = [
115
115
  "config", "list", "core/project", "--format=value(core.project)"
116
- ], capture: true
116
+ ]
117
+ @current_project = execute params, capture: true
117
118
  @current_project = nil if @current_project.empty?
118
119
  end
119
120
  @current_project
@@ -147,7 +148,7 @@ module AppEngine
147
148
  binary_path!
148
149
  current_project!
149
150
  auths = execute ["auth", "list", "--format=value(account)"],
150
- capture: true
151
+ capture: true
151
152
  raise GcloudNotAuthenticated if auths.empty?
152
153
  end
153
154
 
@@ -166,13 +167,17 @@ module AppEngine
166
167
  # depending on the value of the `capture` parameter.
167
168
  #
168
169
  def execute args, echo: false, capture: false, assert: true
169
- joined_args = Gem.win_platform? ? args.join(" ") : Shellwords.join(args)
170
-
171
- cmd = "#{binary_path!} #{joined_args}"
170
+ cmd_array = [binary_path!] + args
171
+ cmd =
172
+ if ::Gem.win_platform?
173
+ cmd_array.join " "
174
+ else
175
+ ::Shellwords.join cmd_array
176
+ end
172
177
  puts cmd if echo
173
178
  result = capture ? `#{cmd}` : system(cmd)
174
- code = $?.exitstatus
175
- raise GcloudFailed.new($?.exitstatus) if assert && code != 0
179
+ code = $CHILD_STATUS.exitstatus
180
+ raise GcloudFailed, code if assert && code != 0
176
181
  result
177
182
  end
178
183
 
@@ -187,9 +192,7 @@ module AppEngine
187
192
  def capture args
188
193
  execute args, capture: true
189
194
  end
190
-
191
195
  end
192
196
  end
193
-
194
197
  end
195
198
  end
@@ -1,4 +1,6 @@
1
- # Copyright 2016 Google Inc. All rights reserved.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 Google LLC
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
4
6
  # you may not use this file except in compliance with the License.
@@ -11,11 +13,9 @@
11
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
- ;
15
16
 
16
- module AppEngine
17
17
 
18
+ module AppEngine
18
19
  # The current version of this gem, as a string.
19
- VERSION = '0.4.6'.freeze
20
-
20
+ VERSION = "0.7.0"
21
21
  end
data/lib/appengine.rb CHANGED
@@ -1,4 +1,6 @@
1
- # Copyright 2016 Google Inc. All rights reserved.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 Google LLC
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
4
6
  # you may not use this file except in compliance with the License.
@@ -11,17 +13,22 @@
11
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
- ;
15
16
 
16
- # # Google AppEngine integration
17
+
18
+ ##
19
+ # ## Google AppEngine integration
17
20
  #
18
21
  # The AppEngine module includes optional tools helping Ruby applications to
19
22
  # integrate more closely with the Google App Engine environment.
20
-
23
+ #
21
24
  module AppEngine
25
+ ##
26
+ # Internal utilities
27
+ #
28
+ module Util
29
+ end
22
30
  end
23
31
 
24
-
25
32
  require "appengine/version"
26
33
  require "appengine/env"
27
34
  require "appengine/exec"