@@ -378,25 +378,20 @@ func (impl *DeploymentConfigurationServiceImpl) encodeSecretDataFromNonAdminUser
378
378
}
379
379
}
380
380
381
- func (impl * DeploymentConfigurationServiceImpl ) getCmCsDataForPreviousDeployments (ctx context.Context , deploymentTemplateHistoryId , pipelineId int , userHasAdminAccess bool ) (* bean2.DeploymentAndCmCsConfigDto , error ) {
381
+ func (impl * DeploymentConfigurationServiceImpl ) getCmCsDataForPreviousDeployments (ctx context.Context , wfrId , pipelineId int , userHasAdminAccess bool ) (* bean2.DeploymentAndCmCsConfigDto , error ) {
382
382
383
383
configDataDto := & bean2.DeploymentAndCmCsConfigDto {}
384
384
385
- deplTemplateHistory , err := impl .deploymentTemplateHistoryReadService . GetTemplateHistoryModelForDeployedTemplateById ( deploymentTemplateHistoryId , pipelineId )
385
+ cmConfigData , err := impl .configMapHistoryReadService . GetCmCsHistoryByWfrIdAndPipelineId ( ctx , pipelineId , wfrId , repository3 . CONFIGMAP_TYPE , userHasAdminAccess )
386
386
if err != nil {
387
- impl .logger .Errorw ("error in getting deployment template history" , "err" , err , "deploymentTemplateHistoryId" , deploymentTemplateHistoryId , "pipelineId" , pipelineId )
388
- return nil , err
389
- }
390
- cmConfigData , err := impl .configMapHistoryReadService .GetCmCsHistoryByDeployedOnAndPipelineId (ctx , pipelineId , deplTemplateHistory .DeployedOn , repository3 .CONFIGMAP_TYPE , userHasAdminAccess )
391
- if err != nil {
392
- impl .logger .Errorw ("error in getting secretData and cmData" , "err" , err , "deploymentTemplateHistoryId" , deploymentTemplateHistoryId , "pipelineId" , pipelineId )
387
+ impl .logger .Errorw ("error in getting secretData and cmData" , "err" , err , "wfrId" , wfrId , "pipelineId" , pipelineId )
393
388
return nil , err
394
389
}
395
390
configDataDto .WithConfigMapData (cmConfigData )
396
391
if userHasAdminAccess {
397
- secretConfigData , err := impl .configMapHistoryReadService .GetCmCsHistoryByDeployedOnAndPipelineId (ctx , pipelineId , deplTemplateHistory . DeployedOn , repository3 .SECRET_TYPE , userHasAdminAccess )
392
+ secretConfigData , err := impl .configMapHistoryReadService .GetCmCsHistoryByWfrIdAndPipelineId (ctx , pipelineId , wfrId , repository3 .SECRET_TYPE , userHasAdminAccess )
398
393
if err != nil {
399
- impl .logger .Errorw ("error in getting secretData and cmData" , "err" , err , "deploymentTemplateHistoryId " , deploymentTemplateHistoryId , "pipelineId" , pipelineId )
394
+ impl .logger .Errorw ("error in getting secretData and cmData" , "err" , err , "wfrId " , wfrId , "pipelineId" , pipelineId )
400
395
return nil , err
401
396
}
402
397
configDataDto .WithSecretData (secretConfigData )
@@ -405,77 +400,74 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsDataForPreviousDeployment
405
400
return configDataDto , nil
406
401
407
402
}
408
- func (impl * DeploymentConfigurationServiceImpl ) getPipelineStrategyForPreviousDeployments (ctx context.Context , deploymentTemplateHistoryId , pipelineId int ) (* bean2.DeploymentAndCmCsConfig , error ) {
403
+ func (impl * DeploymentConfigurationServiceImpl ) getPipelineStrategyForPreviousDeployments (ctx context.Context , wfrId , pipelineId int ) (* bean2.DeploymentAndCmCsConfig , error ) {
409
404
pipelineStrategyJson := json.RawMessage {}
410
405
pipelineConfig := bean2 .NewDeploymentAndCmCsConfig ()
411
- deplTemplateHistory , err := impl .deploymentTemplateHistoryReadService .GetTemplateHistoryModelForDeployedTemplateById (deploymentTemplateHistoryId , pipelineId )
412
- if err != nil {
413
- impl .logger .Errorw ("error in getting deployment template history" , "deploymentTemplateHistoryId" , deploymentTemplateHistoryId , "pipelineId" , pipelineId , "err" , err )
414
- return nil , err
415
- }
416
- pipelineStrategyHistory , err := impl .pipelineStrategyHistoryRepository .FindPipelineStrategyForDeployedOnAndPipelineId (pipelineId , deplTemplateHistory .DeployedOn )
406
+ pipelineStrategyHistory , err := impl .pipelineStrategyHistoryRepository .GetHistoryByPipelineIdAndWfrId (ctx , pipelineId , wfrId )
417
407
if err != nil && ! util .IsErrNoRows (err ) {
418
- impl .logger .Errorw ("error in FindPipelineStrategyForDeployedOnAndPipelineId" , "deploymentTemplateHistoryId " , deploymentTemplateHistoryId , "deployedOn" , deplTemplateHistory . DeployedOn , "pipelineId" , pipelineId , "err" , err )
408
+ impl .logger .Errorw ("error in FindPipelineStrategyForDeployedOnAndPipelineId" , "wfrId " , wfrId , "pipelineId" , pipelineId , "err" , err )
419
409
return nil , err
420
410
} else if util .IsErrNoRows (err ) {
421
411
return pipelineConfig , nil
422
412
}
423
- err = pipelineStrategyJson .UnmarshalJSON ([]byte (pipelineStrategyHistory .Config ))
424
- if err != nil {
425
- impl .logger .Errorw ("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message" , "err" , err )
426
- return nil , err
413
+ if pipelineStrategyHistory != nil {
414
+ err = pipelineStrategyJson .UnmarshalJSON ([]byte (pipelineStrategyHistory .Config ))
415
+ if err != nil {
416
+ impl .logger .Errorw ("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message" , "err" , err )
417
+ return nil , err
418
+ }
419
+ pipelineConfig .WithConfigData (pipelineStrategyJson ).
420
+ WithResourceType (bean .PipelineStrategy ).
421
+ WithPipelineStrategyMetadata (pipelineStrategyHistory .PipelineTriggerType , string (pipelineStrategyHistory .Strategy ))
427
422
}
428
- pipelineConfig .WithConfigData (pipelineStrategyJson ).
429
- WithResourceType (bean .PipelineStrategy ).
430
- WithPipelineStrategyMetadata (pipelineStrategyHistory .PipelineTriggerType , string (pipelineStrategyHistory .Strategy ))
431
423
return pipelineConfig , nil
432
424
}
433
425
434
- func (impl * DeploymentConfigurationServiceImpl ) getDeploymentsConfigForPreviousDeployments (ctx context.Context , configDataQueryParams * bean2.ConfigDataQueryParams ,
435
- appId , envId int ) (generateManifest.DeploymentTemplateResponse , error ) {
436
- deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest {
437
- PipelineId : configDataQueryParams .PipelineId ,
438
- DeploymentTemplateHistoryId : configDataQueryParams .IdentifierId ,
439
- RequestDataMode : generateManifest .Values ,
440
- Type : repository2 .DeployedOnSelfEnvironment ,
441
- }
426
+ func (impl * DeploymentConfigurationServiceImpl ) getDeploymentsConfigForPreviousDeployments (ctx context.Context , configDataQueryParams * bean2.ConfigDataQueryParams ) (generateManifest.DeploymentTemplateResponse , error ) {
427
+
442
428
var deploymentTemplateResponse generateManifest.DeploymentTemplateResponse
443
- deploymentTemplateResponse , err := impl .deploymentTemplateService . GetDeploymentTemplate (ctx , deploymentTemplateRequest )
429
+ deplTemplate , err := impl .deploymentTemplateHistoryReadService . GetDeployedHistoryByPipelineIdAndWfrId (ctx , configDataQueryParams . PipelineId , configDataQueryParams . WfrId )
444
430
if err != nil {
445
- impl .logger .Errorw ("getDeploymentTemplateForEnvLevel , error in getting deployment template for " , "deploymentTemplateRequest " , deploymentTemplateRequest , "err" , err )
431
+ impl .logger .Errorw ("getDeploymentsConfigForPreviousDeployments , error in getting deployment template by pipelineId and wfrId " , "pipelineId " , configDataQueryParams . PipelineId , "wfrId" , configDataQueryParams . WfrId , "err" , err )
446
432
return deploymentTemplateResponse , err
447
433
}
448
-
434
+ deploymentTemplateResponse = generateManifest.DeploymentTemplateResponse {
435
+ Data : deplTemplate .CodeEditorValue .Value ,
436
+ ResolvedData : deplTemplate .CodeEditorValue .ResolvedValue ,
437
+ VariableSnapshot : deplTemplate .CodeEditorValue .VariableSnapshot ,
438
+ TemplateVersion : deplTemplate .TemplateVersion ,
439
+ IsAppMetricsEnabled : * deplTemplate .IsAppMetricsEnabled ,
440
+ }
449
441
return deploymentTemplateResponse , nil
450
442
}
451
443
452
444
func (impl * DeploymentConfigurationServiceImpl ) getDeploymentAndCmCsConfigDataForPreviousDeployments (ctx context.Context , configDataQueryParams * bean2.ConfigDataQueryParams ,
453
445
appId , envId int , userHasAdminAccess bool ) (* bean2.DeploymentAndCmCsConfigDto , error ) {
454
446
455
447
// getting DeploymentAndCmCsConfigDto obj with cm and cs data populated
456
- configDataDto , err := impl .getCmCsDataForPreviousDeployments (ctx , configDataQueryParams .IdentifierId , configDataQueryParams .PipelineId , userHasAdminAccess )
448
+ configDataDto , err := impl .getCmCsDataForPreviousDeployments (ctx , configDataQueryParams .WfrId , configDataQueryParams .PipelineId , userHasAdminAccess )
457
449
if err != nil {
458
- impl .logger .Errorw ("error in getting cm cs for PreviousDeployments state" , "deploymentTemplateHistoryId" , configDataQueryParams . IdentifierId , "pipelineId" , configDataQueryParams . PipelineId , "err" , err )
450
+ impl .logger .Errorw ("error in getting cm cs for PreviousDeployments state" , "configDataQueryParams" , configDataQueryParams , "err" , err )
459
451
return nil , err
460
452
}
461
- pipelineStrategy , err := impl .getPipelineStrategyForPreviousDeployments (ctx , configDataQueryParams .IdentifierId , configDataQueryParams .PipelineId )
453
+ pipelineStrategy , err := impl .getPipelineStrategyForPreviousDeployments (ctx , configDataQueryParams .WfrId , configDataQueryParams .PipelineId )
462
454
if err != nil {
463
- impl .logger .Errorw (" error in getting cm cs for PreviousDeployments state" , "deploymentTemplateHistoryId" , configDataQueryParams . IdentifierId , "pipelineId" , configDataQueryParams . PipelineId , "err" , err )
455
+ impl .logger .Errorw (" error in getting cm cs for PreviousDeployments state" , "configDataQueryParams" , configDataQueryParams , "err" , err )
464
456
return nil , err
465
457
}
466
458
if len (pipelineStrategy .Data ) > 0 {
467
459
configDataDto .WithPipelineConfigData (pipelineStrategy )
468
460
}
469
461
470
- deploymentTemplateData , err := impl .getDeploymentsConfigForPreviousDeployments (ctx , configDataQueryParams , appId , envId )
462
+ deploymentTemplateData , err := impl .getDeploymentsConfigForPreviousDeployments (ctx , configDataQueryParams )
471
463
if err != nil {
472
- impl .logger .Errorw ("error in getting deployment config" , "appName" , configDataQueryParams . AppName , "envName" , configDataQueryParams . EnvName , "err" , err )
464
+ impl .logger .Errorw ("error in getting deployment config" , "configDataQueryParams" , configDataQueryParams , "err" , err )
473
465
return nil , err
474
466
}
475
467
deploymentJson := json.RawMessage {}
476
468
err = deploymentJson .UnmarshalJSON ([]byte (deploymentTemplateData .Data ))
477
469
if err != nil {
478
- impl .logger .Errorw ("error in unmarshalling string deploymentTemplateResponse data into json Raw message" , "appName" , configDataQueryParams . AppName , "envName" , configDataQueryParams . EnvName , "err" , err )
470
+ impl .logger .Errorw ("error in unmarshalling string deploymentTemplateResponse data into json Raw message" , "configDataQueryParams" , configDataQueryParams , "err" , err )
479
471
return nil , err
480
472
}
481
473
variableSnapShotMap := map [string ]map [string ]string {bean .DeploymentTemplate .ToString (): deploymentTemplateData .VariableSnapshot }
0 commit comments