Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support template parameters in configmap/secret customData #366

Merged
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
8 changes: 7 additions & 1 deletion modules/common/configmap/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ func createOrPatchConfigMap(
// Note: this can overwrite data rendered from GetTemplateData() if key is same
if len(cm.CustomData) > 0 {
for k, v := range cm.CustomData {
configMap.Data[k] = v
vExpanded, err := util.ExecuteTemplateData(v, cm.ConfigOptions)
if err == nil {
configMap.Data[k] = vExpanded
} else {
h.GetLogger().Info(fmt.Sprintf("Skipped customData expansion due to: %s", err))
configMap.Data[k] = v
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion modules/common/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ func createOrUpdateSecret(
// Note: this can overwrite data rendered from GetTemplateData() if key is same
if len(st.CustomData) > 0 {
for k, v := range st.CustomData {
dataString[k] = v
vExpanded, err := util.ExecuteTemplateData(v, st.ConfigOptions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to consolidate this code and the code for the config map into a single function, but I don't think that's a big deal.

if err == nil {
dataString[k] = vExpanded
} else {
h.GetLogger().Info(fmt.Sprintf("Skipped customData expansion due to: %s", err))
dataString[k] = v
}
}
}

Expand Down
Loading