@@ -278,24 +278,21 @@ func DeployNetworksStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outpu
278278
279279 step := GetNetworkStep (c .EnableHubAndSpoke )
280280
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- }
281+ var localStep string
290282
283+ if c .EnableHubAndSpoke {
284+ localStep = "shared"
291285 } 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- }
286+ localStep = "production"
287+ }
288+
289+ // shared
290+ sharedTfvars := NetSharedTfvars {
291+ TargetNameServerAddresses : tfvars .TargetNameServerAddresses ,
292+ }
293+ err := utils .WriteTfvars (filepath .Join (c .FoundationPath , step , "shared.auto.tfvars" ), sharedTfvars )
294+ if err != nil {
295+ return err
299296 }
300297 // common
301298 commonTfvars := NetCommonTfvars {
@@ -306,7 +303,7 @@ func DeployNetworksStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outpu
306303 if tfvars .EnableHubAndSpoke {
307304 commonTfvars .EnableHubAndSpokeTransitivity = & tfvars .EnableHubAndSpokeTransitivity
308305 }
309- err : = utils .WriteTfvars (filepath .Join (c .FoundationPath , step , "common.auto.tfvars" ), commonTfvars )
306+ err = utils .WriteTfvars (filepath .Join (c .FoundationPath , step , "common.auto.tfvars" ), commonTfvars )
310307 if err != nil {
311308 return err
312309 }
@@ -319,67 +316,38 @@ func DeployNetworksStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outpu
319316 return err
320317 }
321318
322- if c .EnableHubAndSpoke {
323-
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 )
319+ conf := utils .CloneCSR (t , NetworksRepo , filepath .Join (c .CheckoutPath , NetworksRepo ), outputs .CICDProject , c .Logger )
320+ stageConf := StageConf {
321+ Stage : NetworksRepo ,
322+ StageSA : outputs .NetworkSA ,
323+ CICDProject : outputs .CICDProject ,
324+ DefaultRegion : outputs .DefaultRegion ,
325+ Step : step ,
326+ Repo : NetworksRepo ,
327+ GitConf : conf ,
328+ HasLocalStep : true ,
329+ LocalSteps : []string {localStep },
330+ GroupingUnits : []string {"envs" },
331+ Envs : []string {"production" , "nonproduction" , "development" },
355332 }
333+ return deployStage (t , stageConf , s , c )
356334}
357335
358336func DeployProjectsStage (t testing.TB , s steps.Steps , tfvars GlobalTFVars , outputs BootstrapOutputs , c CommonConf ) error {
359337
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- }
338+ // shared
339+ sharedTfvars := ProjSharedTfvars {
340+ DefaultRegion : tfvars .DefaultRegion ,
341+ }
342+ err := utils .WriteTfvars (filepath .Join (c .FoundationPath , ProjectsStep , "shared.auto.tfvars" ), sharedTfvars )
343+ if err != nil {
344+ return err
377345 }
378346 // common
379347 commonTfvars := ProjCommonTfvars {
380348 RemoteStateBucket : outputs .RemoteStateBucket ,
381349 }
382- err : = utils .WriteTfvars (filepath .Join (c .FoundationPath , ProjectsStep , "common.auto.tfvars" ), commonTfvars )
350+ err = utils .WriteTfvars (filepath .Join (c .FoundationPath , ProjectsStep , "common.auto.tfvars" ), commonTfvars )
383351 if err != nil {
384352 return err
385353 }
@@ -400,40 +368,23 @@ func DeployProjectsStage(t testing.TB, s steps.Steps, tfvars GlobalTFVars, outpu
400368 }
401369 }
402370
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 )
371+ conf := utils .CloneCSR (t , ProjectsRepo , filepath .Join (c .CheckoutPath , ProjectsRepo ), outputs .CICDProject , c .Logger )
372+ stageConf := StageConf {
373+ Stage : ProjectsRepo ,
374+ StageSA : outputs .ProjectsSA ,
375+ CICDProject : outputs .CICDProject ,
376+ DefaultRegion : outputs .DefaultRegion ,
377+ Step : ProjectsStep ,
378+ Repo : ProjectsRepo ,
379+ GitConf : conf ,
380+ HasLocalStep : true ,
381+ LocalSteps : []string {"shared" , "production" },
382+ GroupingUnits : []string {"business_unit_1" },
383+ Envs : []string {"production" , "nonproduction" , "development" },
436384 }
385+
386+ return deployStage (t , stageConf , s , c )
387+
437388}
438389
439390func DeployExampleAppStage (t testing.TB , s steps.Steps , tfvars GlobalTFVars , outputs InfraPipelineOutputs , c CommonConf ) error {
@@ -505,7 +456,7 @@ func deployStage(t testing.TB, sc StageConf, s steps.Steps, c CommonConf) error
505456 NoColor : true ,
506457 }
507458
508- err := s .RunStep (fmt .Sprintf ("%s.%s.apply-shared " , sc .Stage , bu ), func () error {
459+ err := s .RunStep (fmt .Sprintf ("%s.%s.apply-%s " , sc .Stage , bu , localStep ), func () error {
509460 return applyLocal (t , buOptions , sc .StageSA , c .PolicyPath , c .ValidatorProject )
510461 })
511462 if err != nil {
0 commit comments