OLD | NEW |
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 } | |
OLD | NEW |