@@ -42,6 +42,7 @@ import (
42
42
commonmodels "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/models"
43
43
templatemodels "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/models/template"
44
44
commonrepo "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/mongodb"
45
+ "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/mongodb/template"
45
46
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/notify"
46
47
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/repository"
47
48
commonutil "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/util"
@@ -366,12 +367,31 @@ func UpgradeHelmRelease(product *commonmodels.Product, productSvc *commonmodels.
366
367
}
367
368
}
368
369
369
- newProductInfo .Services = [][]* commonmodels.ProductService {{}}
370
- for _ , service := range productSvcMap {
371
- newProductInfo .Services [0 ] = append (newProductInfo .Services [0 ], service )
370
+ templateProduct , err := template .NewProductCollWithSess (session ).Find (product .ProductName )
371
+ if err != nil {
372
+ mongo .AbortTransaction (session )
373
+ return errors .Wrapf (err , "failed to find template product %s" , product .ProductName )
374
+ }
375
+
376
+ newProductInfo .Services = [][]* commonmodels.ProductService {}
377
+ serviceOrchestration := templateProduct .Services
378
+ if product .Production {
379
+ serviceOrchestration = templateProduct .ProductionServices
380
+ }
381
+
382
+ for i , svcGroup := range serviceOrchestration {
383
+ if len (newProductInfo .Services ) >= i {
384
+ newProductInfo .Services = append (newProductInfo .Services , []* commonmodels.ProductService {})
385
+ }
386
+
387
+ for _ , svc := range svcGroup {
388
+ if productSvcMap [svc ] != nil {
389
+ newProductInfo .Services [i ] = append (newProductInfo .Services [i ], productSvcMap [svc ])
390
+ }
391
+ }
372
392
}
373
393
for _ , service := range productChartSvcMap {
374
- newProductInfo .Services [0 ] = append (newProductInfo .Services [0 ], service )
394
+ newProductInfo .Services [len ( newProductInfo . Services ) - 1 ] = append (newProductInfo .Services [len ( newProductInfo . Services ) - 1 ], service )
375
395
}
376
396
377
397
if productSvc .DeployStrategy == setting .ServiceDeployStrategyDeploy {
0 commit comments