Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: app/bin/tools_common.dart

Issue 2840533002: Add a helper function to ensure we have the correct datastore installed
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « app/bin/server_common.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:io'; 5 import 'dart:io';
6 import 'dart:async'; 6 import 'dart:async';
7 7
8 import 'package:appengine/appengine.dart'; 8 import 'package:appengine/appengine.dart';
9 import 'package:gcloud/db.dart';
9 import 'package:gcloud/service_scope.dart'; 10 import 'package:gcloud/service_scope.dart';
10 import 'package:pub_dartlang_org/upload_signer_service.dart'; 11 import 'package:pub_dartlang_org/upload_signer_service.dart';
11 12
12 import 'server_common.dart'; 13 import 'server_common.dart';
13 import 'configuration.dart'; 14 import 'configuration.dart';
14 15
15 Future withProdServices(Future fun()) { 16 Future withProdServices(Future fun()) {
16 if (Platform.isMacOS) { 17 return withCorrectDatastore((_) {
17 return _withProdServices(() { 18 if (!Platform.environment.containsKey('GCLOUD_PROJECT') ||
18 return fork(() async { 19 !Platform.environment.containsKey('GCLOUD_KEY')) {
19 await initializeApiaryDatastore(); 20 throw 'Missing GCLOUD_* environments for package:appengine';
20 return fun(); 21 }
21 }); 22 return withAppEngineServices(() {
23 registerUploadSigner(
24 new ServiceAccountBasedUploadSigner(activeConfiguration.credentials));
25 initBackend();
26 return fun();
22 }); 27 });
23 } else { 28 }, null);
24 return _withProdServices(fun);
25 }
26 } 29 }
27
28 Future _withProdServices(Future fun()) async {
29 if (!Platform.environment.containsKey('GCLOUD_PROJECT') ||
30 !Platform.environment.containsKey('GCLOUD_KEY')) {
31 throw 'Missing GCLOUD_* environments for package:appengine';
32 }
33 return withAppEngineServices(() {
34 registerUploadSigner(
35 new ServiceAccountBasedUploadSigner(activeConfiguration.credentials));
36 initBackend();
37 return fun();
38 });
39 }
OLDNEW
« no previous file with comments | « app/bin/server_common.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698