Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pkg/pipeline/WorkflowUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,19 @@ func AddTemplatesForGlobalSecretsInWorkflowTemplate(globalCmCsConfigs []*bean.Gl
})
cmIndex++
} else if config.ConfigType == repository.CS_TYPE_CONFIG {
secretJson, err := GetSecretJson(ConfigMapSecretDto{Name: config.Name, Data: config.Data, OwnerRef: ArgoWorkflowOwnerRef})

// special handling for secret data since GetSecretJson expects encoded values in data map
encodedSecretData, err := bean.ConvertToEncodedForm(config.Data)
if err != nil {
return err
}
var encodedSecretDataMap = make(map[string]string)
err = json.Unmarshal(encodedSecretData, &encodedSecretDataMap)
if err != nil {
return err
}

secretJson, err := GetSecretJson(ConfigMapSecretDto{Name: config.Name, Data: encodedSecretDataMap, OwnerRef: ArgoWorkflowOwnerRef})
if err != nil {
return err
}
Expand Down
22 changes: 15 additions & 7 deletions pkg/pipeline/bean/GlobalCMCSDto.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,35 @@ type GlobalCMCSDto struct {
}

func (dto GlobalCMCSDto) ConvertToConfigSecretMap() (bean.ConfigSecretMap, error) {
var jsonRawMsg []byte
var err error

configSecretMap := bean.ConfigSecretMap{}
configSecretMap.Name = dto.Name
configSecretMap.Type = dto.Type
configSecretMap.MountPath = dto.MountPath

var jsonRawMsg []byte
var err error
// adding handling to get base64 encoded value in map value in case of secrets
if dto.ConfigType == repository.CS_TYPE_CONFIG {
var csDataMap = make(map[string][]byte)
for key, value := range dto.Data {
csDataMap[key] = []byte(value)
}
jsonRawMsg, err = json.Marshal(csDataMap)
jsonRawMsg, err = ConvertToEncodedForm(dto.Data)

} else {
jsonRawMsg, err = json.Marshal(dto.Data)
}

if err != nil {
return configSecretMap, err
}
configSecretMap.Data = jsonRawMsg
return configSecretMap, nil
}

// ConvertToEncodedForm Function to encode the values in the input map values
func ConvertToEncodedForm(data map[string]string) ([]byte, error) {
var csDataMap = make(map[string][]byte)
for key, value := range data {
csDataMap[key] = []byte(value)
}
jsonRawMsg, err := json.Marshal(csDataMap)
return jsonRawMsg, err
}