Skip to content

Commit e5c410a

Browse files
fix: Global secret data bug in CI workflow (#3504)
* Updated latest image of hyperion in installer * Updated latest image of devtron in installer * fix Global secret data bug in CI workflow * Revert "Updated latest image of devtron in installer" This reverts commit c5f54cc. * Revert "Updated latest image of hyperion in installer" This reverts commit fb145a1. --------- Co-authored-by: ReleaseBot <[email protected]>
1 parent be23d69 commit e5c410a

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

pkg/pipeline/WorkflowUtils.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,19 @@ func AddTemplatesForGlobalSecretsInWorkflowTemplate(globalCmCsConfigs []*bean.Gl
215215
})
216216
cmIndex++
217217
} else if config.ConfigType == repository.CS_TYPE_CONFIG {
218-
secretJson, err := GetSecretJson(ConfigMapSecretDto{Name: config.Name, Data: config.Data, OwnerRef: ArgoWorkflowOwnerRef})
218+
219+
// special handling for secret data since GetSecretJson expects encoded values in data map
220+
encodedSecretData, err := bean.ConvertToEncodedForm(config.Data)
221+
if err != nil {
222+
return err
223+
}
224+
var encodedSecretDataMap = make(map[string]string)
225+
err = json.Unmarshal(encodedSecretData, &encodedSecretDataMap)
226+
if err != nil {
227+
return err
228+
}
229+
230+
secretJson, err := GetSecretJson(ConfigMapSecretDto{Name: config.Name, Data: encodedSecretDataMap, OwnerRef: ArgoWorkflowOwnerRef})
219231
if err != nil {
220232
return err
221233
}

pkg/pipeline/bean/GlobalCMCSDto.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,35 @@ type GlobalCMCSDto struct {
2020
}
2121

2222
func (dto GlobalCMCSDto) ConvertToConfigSecretMap() (bean.ConfigSecretMap, error) {
23-
var jsonRawMsg []byte
24-
var err error
23+
2524
configSecretMap := bean.ConfigSecretMap{}
2625
configSecretMap.Name = dto.Name
2726
configSecretMap.Type = dto.Type
2827
configSecretMap.MountPath = dto.MountPath
2928

29+
var jsonRawMsg []byte
30+
var err error
3031
// adding handling to get base64 encoded value in map value in case of secrets
3132
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)
33+
jsonRawMsg, err = ConvertToEncodedForm(dto.Data)
3734

3835
} else {
3936
jsonRawMsg, err = json.Marshal(dto.Data)
4037
}
38+
4139
if err != nil {
4240
return configSecretMap, err
4341
}
4442
configSecretMap.Data = jsonRawMsg
4543
return configSecretMap, nil
4644
}
45+
46+
// ConvertToEncodedForm Function to encode the values in the input map values
47+
func ConvertToEncodedForm(data map[string]string) ([]byte, error) {
48+
var csDataMap = make(map[string][]byte)
49+
for key, value := range data {
50+
csDataMap[key] = []byte(value)
51+
}
52+
jsonRawMsg, err := json.Marshal(csDataMap)
53+
return jsonRawMsg, err
54+
}

0 commit comments

Comments
 (0)