@@ -40,6 +40,9 @@ import {
40
40
import { configstore } from "../../../configstore" ;
41
41
import { trackGA4 } from "../../../track" ;
42
42
43
+ // Default GCP region for Data Connect
44
+ export const FDC_DEFAULT_REGION = "us-east4" ;
45
+
43
46
const DATACONNECT_YAML_TEMPLATE = readTemplateSync ( "init/dataconnect/dataconnect.yaml" ) ;
44
47
const CONNECTOR_YAML_TEMPLATE = readTemplateSync ( "init/dataconnect/connector.yaml" ) ;
45
48
const SCHEMA_TEMPLATE = readTemplateSync ( "init/dataconnect/schema.gql" ) ;
@@ -125,6 +128,8 @@ export async function askQuestions(setup: Setup): Promise<void> {
125
128
}
126
129
if ( hasBilling ) {
127
130
await promptForCloudSQL ( setup , info ) ;
131
+ } else if ( info . appDescription ) {
132
+ await promptForLocation ( setup , info ) ;
128
133
}
129
134
}
130
135
setup . featureInfo = setup . featureInfo || { } ;
@@ -148,7 +153,7 @@ export async function actuate(setup: Setup, config: Config, options: any): Promi
148
153
// Populate the default values of required fields.
149
154
info . serviceId = info . serviceId || defaultServiceId ( ) ;
150
155
info . cloudSqlInstanceId = info . cloudSqlInstanceId || `${ info . serviceId . toLowerCase ( ) } -fdc` ;
151
- info . locationId = info . locationId || `us-central1` ;
156
+ info . locationId = info . locationId || FDC_DEFAULT_REGION ;
152
157
info . cloudSqlDatabase = info . cloudSqlDatabase || `fdcdb` ;
153
158
154
159
try {
@@ -435,10 +440,10 @@ function subDataconnectYamlValues(replacementValues: {
435
440
} ) : string {
436
441
const replacements : Record < string , string > = {
437
442
serviceId : "__serviceId__" ,
443
+ locationId : "__location__" ,
438
444
cloudSqlDatabase : "__cloudSqlDatabase__" ,
439
445
cloudSqlInstanceId : "__cloudSqlInstanceId__" ,
440
446
connectorDirs : "__connectorDirs__" ,
441
- locationId : "__location__" ,
442
447
} ;
443
448
let replaced = DATACONNECT_YAML_TEMPLATE ;
444
449
for ( const [ k , v ] of Object . entries ( replacementValues ) ) {
@@ -614,12 +619,7 @@ async function promptForCloudSQL(setup: Setup, info: RequiredInfo): Promise<void
614
619
}
615
620
616
621
if ( info . locationId === "" ) {
617
- const choices = await locationChoices ( setup ) ;
618
- info . locationId = await select < string > ( {
619
- message : "What location would like to use?" ,
620
- choices,
621
- default : "us-east4" ,
622
- } ) ;
622
+ await promptForLocation ( setup , info ) ;
623
623
info . shouldProvisionCSQL = await confirm ( {
624
624
message : `Would you like to provision your Cloud SQL instance and database now?` ,
625
625
default : true ,
@@ -642,6 +642,17 @@ async function promptForCloudSQL(setup: Setup, info: RequiredInfo): Promise<void
642
642
return ;
643
643
}
644
644
645
+ async function promptForLocation ( setup : Setup , info : RequiredInfo ) : Promise < void > {
646
+ if ( info . locationId === "" ) {
647
+ const choices = await locationChoices ( setup ) ;
648
+ info . locationId = await select < string > ( {
649
+ message : "What location should the new Cloud SQL instance be in?" ,
650
+ choices,
651
+ default : FDC_DEFAULT_REGION ,
652
+ } ) ;
653
+ }
654
+ }
655
+
645
656
async function locationChoices ( setup : Setup ) {
646
657
if ( setup . projectId ) {
647
658
const locations = await listLocations ( setup . projectId ) ;
0 commit comments