@@ -20,7 +20,7 @@ import (
2020 "context"
2121 "encoding/json"
2222 "errors"
23- "strings "
23+ globalUtil "github.com/devtron-labs/devtron/util "
2424 "time"
2525
2626 "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig"
@@ -490,7 +490,7 @@ func (impl ConfigMapHistoryServiceImpl) GetHistoryForDeployedCMCSById(ctx contex
490490 SubPath : & config .SubPath ,
491491 FilePermission : config .FilePermission ,
492492 CodeEditorValue : & HistoryDetailConfig {
493- DisplayName : "Data" ,
493+ DisplayName : DataDisplayName ,
494494 Value : string (config .Data ),
495495 VariableSnapshot : variableSnapshotMap ,
496496 ResolvedValue : resolvedTemplate ,
@@ -521,13 +521,27 @@ func (impl ConfigMapHistoryServiceImpl) GetHistoryForDeployedCMCSById(ctx contex
521521 }
522522 historyDto .ExternalSecretType = config .ExternalSecretType
523523 historyDto .RoleARN = config .RoleARN
524+ historyDto .ESOSubPath = config .ESOSubPath
524525 if config .External {
525- externalSecretData , err := json .Marshal (config .ExternalSecret )
526- if err != nil {
527- impl .logger .Errorw ("error in marshaling external secret data" , "err" , err )
528- }
529- if len (externalSecretData ) > 0 {
530- historyDto .CodeEditorValue .Value = string (externalSecretData )
526+ if config .ExternalSecretType == globalUtil .KubernetesSecret {
527+ externalSecretData , err := json .Marshal (config .ExternalSecret )
528+ if err != nil {
529+ impl .logger .Errorw ("error in marshaling external secret data" , "err" , err )
530+ }
531+ if len (externalSecretData ) > 0 {
532+ historyDto .CodeEditorValue .DisplayName = ExternalSecretDisplayName
533+ historyDto .CodeEditorValue .Value = string (externalSecretData )
534+ }
535+ } else if config .IsESOExternalSecretType () {
536+ externalSecretDataBytes , jErr := json .Marshal (config .ESOSecretData )
537+ if jErr != nil {
538+ impl .logger .Errorw ("error in marshaling eso secret data" , "esoSecretData" , config .ESOSecretData , "err" , jErr )
539+ return nil , jErr
540+ }
541+ if len (externalSecretDataBytes ) > 0 {
542+ historyDto .CodeEditorValue .DisplayName = ESOSecretDataDisplayName
543+ historyDto .CodeEditorValue .Value = string (externalSecretDataBytes )
544+ }
531545 }
532546 }
533547 }
@@ -593,7 +607,7 @@ func (impl ConfigMapHistoryServiceImpl) ConvertConfigDataToComponentLevelDto(con
593607 SubPath : & config .SubPath ,
594608 FilePermission : config .FilePermission ,
595609 CodeEditorValue : & HistoryDetailConfig {
596- DisplayName : "Data" ,
610+ DisplayName : DataDisplayName ,
597611 Value : string (config .Data ),
598612 },
599613 }
@@ -623,22 +637,27 @@ func (impl ConfigMapHistoryServiceImpl) ConvertConfigDataToComponentLevelDto(con
623637 }
624638 historyDto .ExternalSecretType = config .ExternalSecretType
625639 historyDto .RoleARN = config .RoleARN
640+ historyDto .ESOSubPath = config .ESOSubPath
626641 if config .External {
627642 var externalSecretData []byte
628- if strings .HasPrefix (config .ExternalSecretType , "ESO" ) {
643+ displayName := historyDto .CodeEditorValue .DisplayName
644+ if config .IsESOExternalSecretType () {
645+ displayName = ESOSecretDataDisplayName
629646 externalSecretData , err = json .Marshal (config .ESOSecretData )
630647 if err != nil {
631648 impl .logger .Errorw ("error in marshaling external secret data" , "err" , err )
632649 return nil , err
633650 }
634651 } else {
652+ displayName = ExternalSecretDisplayName
635653 externalSecretData , err = json .Marshal (config .ExternalSecret )
636654 if err != nil {
637655 impl .logger .Errorw ("error in marshaling external secret data" , "err" , err )
638656 return nil , err
639657 }
640658 }
641659 if len (externalSecretData ) > 0 {
660+ historyDto .CodeEditorValue .DisplayName = displayName
642661 historyDto .CodeEditorValue .Value = string (externalSecretData )
643662 }
644663 }
0 commit comments