@@ -278,13 +278,24 @@ func DeployNetworksStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outpu
278
278
279
279
step := GetNetworkStep (c .EnableHubAndSpoke )
280
280
281
- // shared
282
- sharedTfvars := NetSharedTfvars {
283
- TargetNameServerAddresses : tfvars .TargetNameServerAddresses ,
284
- }
285
- err := utils .WriteTfvars (filepath .Join (c .FoundationPath , step , "shared.auto.tfvars" ), sharedTfvars )
286
- if err != nil {
287
- return err
281
+ if c .EnableHubAndSpoke {
282
+ // shared
283
+ sharedTfvars := NetSharedTfvars {
284
+ TargetNameServerAddresses : tfvars .TargetNameServerAddresses ,
285
+ }
286
+ err := utils .WriteTfvars (filepath .Join (c .FoundationPath , step , "shared.auto.tfvars" ), sharedTfvars )
287
+ if err != nil {
288
+ return err
289
+ }
290
+
291
+ } else {
292
+ productionTfvars := NetSharedTfvars {
293
+ TargetNameServerAddresses : tfvars .TargetNameServerAddresses ,
294
+ }
295
+ err := utils .WriteTfvars (filepath .Join (c .FoundationPath , step , "production.auto.tfvars" ), productionTfvars )
296
+ if err != nil {
297
+ return err
298
+ }
288
299
}
289
300
// common
290
301
commonTfvars := NetCommonTfvars {
@@ -295,7 +306,7 @@ func DeployNetworksStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outpu
295
306
if tfvars .EnableHubAndSpoke {
296
307
commonTfvars .EnableHubAndSpokeTransitivity = & tfvars .EnableHubAndSpokeTransitivity
297
308
}
298
- err = utils .WriteTfvars (filepath .Join (c .FoundationPath , step , "common.auto.tfvars" ), commonTfvars )
309
+ err : = utils .WriteTfvars (filepath .Join (c .FoundationPath , step , "common.auto.tfvars" ), commonTfvars )
299
310
if err != nil {
300
311
return err
301
312
}
@@ -308,37 +319,67 @@ func DeployNetworksStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outpu
308
319
return err
309
320
}
310
321
311
- conf := utils .CloneCSR (t , NetworksRepo , filepath .Join (c .CheckoutPath , NetworksRepo ), outputs .CICDProject , c .Logger )
312
- stageConf := StageConf {
313
- Stage : NetworksRepo ,
314
- StageSA : outputs .NetworkSA ,
315
- CICDProject : outputs .CICDProject ,
316
- DefaultRegion : outputs .DefaultRegion ,
317
- Step : step ,
318
- Repo : NetworksRepo ,
319
- GitConf : conf ,
320
- HasManualStep : true ,
321
- GroupingUnits : []string {"envs" },
322
- Envs : []string {"production" , "nonproduction" , "development" },
323
- }
322
+ if c .EnableHubAndSpoke {
324
323
325
- return deployStage (t , stageConf , s , c )
324
+ conf := utils .CloneCSR (t , NetworksRepo , filepath .Join (c .CheckoutPath , NetworksRepo ), outputs .CICDProject , c .Logger )
325
+ stageConf := StageConf {
326
+ Stage : NetworksRepo ,
327
+ StageSA : outputs .NetworkSA ,
328
+ CICDProject : outputs .CICDProject ,
329
+ DefaultRegion : outputs .DefaultRegion ,
330
+ Step : step ,
331
+ Repo : NetworksRepo ,
332
+ GitConf : conf ,
333
+ HasLocalStep : true ,
334
+ LocalSteps : []string {"shared" },
335
+ GroupingUnits : []string {"envs" },
336
+ Envs : []string {"production" , "nonproduction" , "development" },
337
+ }
338
+ return deployStage (t , stageConf , s , c )
339
+ } else {
340
+ conf := utils .CloneCSR (t , NetworksRepo , filepath .Join (c .CheckoutPath , NetworksRepo ), outputs .CICDProject , c .Logger )
341
+ stageConf := StageConf {
342
+ Stage : NetworksRepo ,
343
+ StageSA : outputs .NetworkSA ,
344
+ CICDProject : outputs .CICDProject ,
345
+ DefaultRegion : outputs .DefaultRegion ,
346
+ Step : step ,
347
+ Repo : NetworksRepo ,
348
+ GitConf : conf ,
349
+ HasLocalStep : true ,
350
+ LocalSteps : []string {"production" , "shared" },
351
+ GroupingUnits : []string {"envs" },
352
+ Envs : []string {"nonproduction" , "development" },
353
+ }
354
+ return deployStage (t , stageConf , s , c )
355
+ }
326
356
}
327
357
328
358
func DeployProjectsStage (t testing.TB , s steps.Steps , tfvars GlobalTFVars , outputs BootstrapOutputs , c CommonConf ) error {
329
- // shared
330
- sharedTfvars := ProjSharedTfvars {
331
- DefaultRegion : tfvars .DefaultRegion ,
332
- }
333
- err := utils .WriteTfvars (filepath .Join (c .FoundationPath , ProjectsStep , "shared.auto.tfvars" ), sharedTfvars )
334
- if err != nil {
335
- return err
359
+
360
+ if c .EnableHubAndSpoke {
361
+ // shared
362
+ sharedTfvars := ProjSharedTfvars {
363
+ DefaultRegion : tfvars .DefaultRegion ,
364
+ }
365
+ err := utils .WriteTfvars (filepath .Join (c .FoundationPath , ProjectsStep , "shared.auto.tfvars" ), sharedTfvars )
366
+ if err != nil {
367
+ return err
368
+ }
369
+ } else {
370
+ productionTfvars := ProjSharedTfvars {
371
+ DefaultRegion : tfvars .DefaultRegion ,
372
+ }
373
+ err := utils .WriteTfvars (filepath .Join (c .FoundationPath , ProjectsStep , "production.auto.tfvars" ), productionTfvars )
374
+ if err != nil {
375
+ return err
376
+ }
336
377
}
337
378
// common
338
379
commonTfvars := ProjCommonTfvars {
339
380
RemoteStateBucket : outputs .RemoteStateBucket ,
340
381
}
341
- err = utils .WriteTfvars (filepath .Join (c .FoundationPath , ProjectsStep , "common.auto.tfvars" ), commonTfvars )
382
+ err : = utils .WriteTfvars (filepath .Join (c .FoundationPath , ProjectsStep , "common.auto.tfvars" ), commonTfvars )
342
383
if err != nil {
343
384
return err
344
385
}
@@ -359,22 +400,40 @@ func DeployProjectsStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outpu
359
400
}
360
401
}
361
402
362
- conf := utils .CloneCSR (t , ProjectsRepo , filepath .Join (c .CheckoutPath , ProjectsRepo ), outputs .CICDProject , c .Logger )
363
- stageConf := StageConf {
364
- Stage : ProjectsRepo ,
365
- StageSA : outputs .ProjectsSA ,
366
- CICDProject : outputs .CICDProject ,
367
- DefaultRegion : outputs .DefaultRegion ,
368
- Step : ProjectsStep ,
369
- Repo : ProjectsRepo ,
370
- GitConf : conf ,
371
- HasManualStep : true ,
372
- GroupingUnits : []string {"business_unit_1" },
373
- Envs : []string {"production" , "nonproduction" , "development" },
403
+ if c .EnableHubAndSpoke {
404
+
405
+ conf := utils .CloneCSR (t , ProjectsRepo , filepath .Join (c .CheckoutPath , ProjectsRepo ), outputs .CICDProject , c .Logger )
406
+ stageConf := StageConf {
407
+ Stage : ProjectsRepo ,
408
+ StageSA : outputs .ProjectsSA ,
409
+ CICDProject : outputs .CICDProject ,
410
+ DefaultRegion : outputs .DefaultRegion ,
411
+ Step : ProjectsStep ,
412
+ Repo : ProjectsRepo ,
413
+ GitConf : conf ,
414
+ HasLocalStep : true ,
415
+ LocalSteps : []string {"shared" },
416
+ GroupingUnits : []string {"business_unit_1" },
417
+ Envs : []string {"production" , "nonproduction" , "development" },
418
+ }
419
+ return deployStage (t , stageConf , s , c )
420
+ } else {
421
+ conf := utils .CloneCSR (t , ProjectsRepo , filepath .Join (c .CheckoutPath , ProjectsRepo ), outputs .CICDProject , c .Logger )
422
+ stageConf := StageConf {
423
+ Stage : ProjectsRepo ,
424
+ StageSA : outputs .ProjectsSA ,
425
+ CICDProject : outputs .CICDProject ,
426
+ DefaultRegion : outputs .DefaultRegion ,
427
+ Step : ProjectsStep ,
428
+ Repo : ProjectsRepo ,
429
+ GitConf : conf ,
430
+ HasLocalStep : true ,
431
+ LocalSteps : []string {"production" , "shared" },
432
+ GroupingUnits : []string {"business_unit_1" },
433
+ Envs : []string {"nonproduction" , "development" },
434
+ }
435
+ return deployStage (t , stageConf , s , c )
374
436
}
375
-
376
- return deployStage (t , stageConf , s , c )
377
-
378
437
}
379
438
380
439
func DeployExampleAppStage (t testing.TB , s steps.Steps , tfvars GlobalTFVars , outputs InfraPipelineOutputs , c CommonConf ) error {
@@ -433,22 +492,25 @@ func deployStage(t testing.TB, sc StageConf, s steps.Steps, c CommonConf) error
433
492
return err
434
493
}
435
494
436
- shared := []string {}
437
- if sc .HasManualStep {
438
- shared = sc .GroupingUnits
495
+ groupunit := []string {}
496
+ if sc .HasLocalStep {
497
+ groupunit = sc .GroupingUnits
439
498
}
440
- for _ , bu := range shared {
441
- buOptions := & terraform.Options {
442
- TerraformDir : filepath .Join (filepath .Join (c .CheckoutPath , sc .Repo ), bu , "shared" ),
443
- Logger : c .Logger ,
444
- NoColor : true ,
445
- }
446
499
447
- err := s .RunStep (fmt .Sprintf ("%s.%s.apply-shared" , sc .Stage , bu ), func () error {
448
- return applyLocal (t , buOptions , sc .StageSA , c .PolicyPath , c .ValidatorProject )
449
- })
450
- if err != nil {
451
- return err
500
+ for _ , bu := range groupunit {
501
+ for _ , localStep := range sc .LocalSteps {
502
+ buOptions := & terraform.Options {
503
+ TerraformDir : filepath .Join (filepath .Join (c .CheckoutPath , sc .Repo ), bu , localStep ),
504
+ Logger : c .Logger ,
505
+ NoColor : true ,
506
+ }
507
+
508
+ err := s .RunStep (fmt .Sprintf ("%s.%s.apply-shared" , sc .Stage , bu ), func () error {
509
+ return applyLocal (t , buOptions , sc .StageSA , c .PolicyPath , c .ValidatorProject )
510
+ })
511
+ if err != nil {
512
+ return err
513
+ }
452
514
}
453
515
}
454
516
@@ -514,6 +576,7 @@ func copyStepCode(t testing.TB, conf utils.GitRepo, foundationPath, checkoutPath
514
576
}
515
577
516
578
func planStage (t testing.TB , conf utils.GitRepo , project , region , repo string ) error {
579
+
517
580
err := conf .CommitFiles (fmt .Sprintf ("Initialize %s repo" , repo ))
518
581
if err != nil {
519
582
return err
0 commit comments