@@ -9,6 +9,15 @@ import * as functionsEnv from "../../functions/env";
99import * as runtimes from "./runtimes" ;
1010import * as validate from "./validate" ;
1111import * as ensure from "./ensure" ;
12+ import {
13+ functionsOrigin ,
14+ artifactRegistryDomain ,
15+ runtimeconfigOrigin ,
16+ cloudRunApiOrigin ,
17+ eventarcOrigin ,
18+ pubsubOrigin ,
19+ storageOrigin ,
20+ } from "../../api" ;
1221import { Options } from "../../options" ;
1322import {
1423 EndpointFilter ,
@@ -62,15 +71,10 @@ export async function prepare(
6271
6372 // ===Phase 0. Check that minimum APIs required for function deploys are enabled.
6473 const checkAPIsEnabled = await Promise . all ( [
65- ensureApiEnabled . ensure ( projectId , "cloudfunctions.googleapis.com" , "functions" ) ,
66- ensureApiEnabled . check (
67- projectId ,
68- "runtimeconfig.googleapis.com" ,
69- "runtimeconfig" ,
70- /* silent=*/ true ,
71- ) ,
74+ ensureApiEnabled . ensure ( projectId , functionsOrigin , "functions" ) ,
75+ ensureApiEnabled . check ( projectId , runtimeconfigOrigin , "runtimeconfig" , /* silent=*/ true ) ,
7276 ensure . cloudBuildEnabled ( projectId ) ,
73- ensureApiEnabled . ensure ( projectId , "artifactregistry.googleapis.com" , "artifactregistry" ) ,
77+ ensureApiEnabled . ensure ( projectId , artifactRegistryDomain , "artifactregistry" ) ,
7478 ] ) ;
7579
7680 // Get the Firebase Config, and set it on each function in the deployment.
@@ -234,12 +238,7 @@ export async function prepare(
234238 // Note: Some of these are premium APIs that require billing to be enabled.
235239 // We'd eventually have to add special error handling for billing APIs, but
236240 // enableCloudBuild is called above and has this special casing already.
237- const V2_APIS = [
238- "run.googleapis.com" ,
239- "eventarc.googleapis.com" ,
240- "pubsub.googleapis.com" ,
241- "storage.googleapis.com" ,
242- ] ;
241+ const V2_APIS = [ cloudRunApiOrigin , eventarcOrigin , pubsubOrigin , storageOrigin ] ;
243242 const enablements = V2_APIS . map ( ( api ) => {
244243 return ensureApiEnabled . ensure ( context . projectId , api , "functions" ) ;
245244 } ) ;
0 commit comments