6
6
repository2 "github.com/devtron-labs/devtron/internal/sql/repository"
7
7
appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app"
8
8
"github.com/devtron-labs/devtron/internal/sql/repository/chartConfig"
9
+ "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
9
10
bean3 "github.com/devtron-labs/devtron/pkg/bean"
10
11
chartService "github.com/devtron-labs/devtron/pkg/chart"
11
12
"github.com/devtron-labs/devtron/pkg/cluster/repository"
@@ -47,6 +48,7 @@ type DeploymentConfigurationServiceImpl struct {
47
48
configMapRepository chartConfig.ConfigMapRepository
48
49
deploymentConfigService pipeline.PipelineDeploymentConfigService
49
50
chartRefService chartRef.ChartRefService
51
+ pipelineRepository pipelineConfig.PipelineRepository
50
52
}
51
53
52
54
func NewDeploymentConfigurationServiceImpl (logger * zap.SugaredLogger ,
@@ -62,6 +64,7 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger,
62
64
configMapRepository chartConfig.ConfigMapRepository ,
63
65
deploymentConfigService pipeline.PipelineDeploymentConfigService ,
64
66
chartRefService chartRef.ChartRefService ,
67
+ pipelineRepository pipelineConfig.PipelineRepository ,
65
68
) (* DeploymentConfigurationServiceImpl , error ) {
66
69
deploymentConfigurationService := & DeploymentConfigurationServiceImpl {
67
70
logger : logger ,
@@ -77,6 +80,7 @@ func NewDeploymentConfigurationServiceImpl(logger *zap.SugaredLogger,
77
80
configMapRepository : configMapRepository ,
78
81
deploymentConfigService : deploymentConfigService ,
79
82
chartRefService : chartRefService ,
83
+ pipelineRepository : pipelineRepository ,
80
84
}
81
85
82
86
return deploymentConfigurationService , nil
@@ -631,11 +635,44 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx conte
631
635
impl .logger .Errorw ("getPublishedConfigData, error in getting publishedOnly deployment config " , "configDataQueryParams" , configDataQueryParams , "err" , err )
632
636
return nil , err
633
637
}
634
-
635
638
configData .WithDeploymentTemplateData (deploymentTemplateData )
639
+
640
+ pipelineConfigData , err := impl .getPublishedPipelineStrategyConfig (ctx , appId , envId )
641
+ if err != nil {
642
+ impl .logger .Errorw ("getPublishedConfigData, error in getting publishedOnly pipeline strategy " , "configDataQueryParams" , configDataQueryParams , "err" , err )
643
+ return nil , err
644
+ }
645
+ configData .WithPipelineConfigData (pipelineConfigData )
636
646
return configData , nil
637
647
}
638
648
649
+ func (impl * DeploymentConfigurationServiceImpl ) getPublishedPipelineStrategyConfig (ctx context.Context , appId int , envId int ) (* bean2.DeploymentAndCmCsConfig , error ) {
650
+ pipelineStrategyJson := json.RawMessage {}
651
+ pipelineConfig := bean2 .NewDeploymentAndCmCsConfig ()
652
+ if envId == 0 {
653
+ return pipelineConfig , nil
654
+ }
655
+ pipeline , err := impl .pipelineRepository .FindActiveByAppIdAndEnvId (appId , envId )
656
+ if err != nil {
657
+ impl .logger .Errorw ("error in FindActiveByAppIdAndEnvId" , "appId" , appId , "envId" , envId , "err" , err )
658
+ return nil , err
659
+ }
660
+ pipelineStrategy , err := impl .deploymentConfigService .GetLatestPipelineStrategyConfig (pipeline )
661
+ if err != nil {
662
+ impl .logger .Errorw ("error in GetLatestPipelineStrategyConfig" , "pipelineId" , pipeline .Id , "err" , err )
663
+ return nil , err
664
+ }
665
+ err = pipelineStrategyJson .UnmarshalJSON ([]byte (pipelineStrategy .CodeEditorValue .Value ))
666
+ if err != nil {
667
+ impl .logger .Errorw ("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message" , "err" , err )
668
+ return nil , err
669
+ }
670
+ pipelineConfig .WithConfigData (pipelineStrategyJson ).
671
+ WithResourceType (bean .PipelineStrategy ).
672
+ WithPipelineStrategyMetadata (pipelineStrategy .PipelineTriggerType , string (pipelineStrategy .Strategy ))
673
+ return pipelineConfig , nil
674
+ }
675
+
639
676
func (impl * DeploymentConfigurationServiceImpl ) getBaseDeploymentTemplate (appId int ) (* bean2.DeploymentTemplateMetadata , error ) {
640
677
deploymentTemplateData , err := impl .chartService .FindLatestChartForAppByAppId (appId )
641
678
if err != nil {
0 commit comments