Skip to content

Commit b439a3a

Browse files
Fix: argo workflow double encoding of secret value in template (#3496)
* fixing cs issue argo executor * cleaning * fix * addressed PRs
1 parent 470dc3c commit b439a3a

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

pkg/pipeline/WorkflowUtils.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ func GetSecretJson(configMapSecretDto ConfigMapSecretDto) (string, error) {
138138

139139
func GetSecretBody(configMapSecretDto ConfigMapSecretDto) v12.Secret {
140140
secretDataMap := make(map[string][]byte)
141-
for key, value := range configMapSecretDto.Data {
142-
secretDataMap[key] = []byte(value)
143-
}
141+
142+
// adding handling to get base64 decoded value in map value
143+
cmsDataMarshaled, _ := json.Marshal(configMapSecretDto.Data)
144+
json.Unmarshal(cmsDataMarshaled, &secretDataMap)
145+
144146
return v12.Secret{
145147
TypeMeta: v1.TypeMeta{
146148
Kind: "Secret",

pkg/pipeline/bean/GlobalCMCSDto.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bean
33
import (
44
"encoding/json"
55
"github.com/devtron-labs/devtron/api/bean"
6+
"github.com/devtron-labs/devtron/internal/sql/repository"
67
)
78

89
type GlobalCMCSDto struct {
@@ -19,11 +20,24 @@ type GlobalCMCSDto struct {
1920
}
2021

2122
func (dto GlobalCMCSDto) ConvertToConfigSecretMap() (bean.ConfigSecretMap, error) {
23+
var jsonRawMsg []byte
24+
var err error
2225
configSecretMap := bean.ConfigSecretMap{}
2326
configSecretMap.Name = dto.Name
2427
configSecretMap.Type = dto.Type
2528
configSecretMap.MountPath = dto.MountPath
26-
jsonRawMsg, err := json.Marshal(dto.Data)
29+
30+
// adding handling to get base64 encoded value in map value in case of secrets
31+
if dto.ConfigType == repository.CS_TYPE_CONFIG {
32+
var csDataMap = make(map[string][]byte)
33+
for key, value := range dto.Data {
34+
csDataMap[key] = []byte(value)
35+
}
36+
jsonRawMsg, err = json.Marshal(csDataMap)
37+
38+
} else {
39+
jsonRawMsg, err = json.Marshal(dto.Data)
40+
}
2741
if err != nil {
2842
return configSecretMap, err
2943
}

0 commit comments

Comments
 (0)