Skip to content

Commit

Permalink
Prevent duplicate calls to templates.HasTemplate
Browse files Browse the repository at this point in the history
Signed-off-by: mprahl <mprahl@users.noreply.github.com>
  • Loading branch information
mprahl committed Jul 19, 2024
1 parent 6579e5c commit 586c37d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions controllers/configurationpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1137,13 +1137,14 @@ func (r *ConfigurationPolicyReconciler) handleTemplatization(

// process object templates for go template usage
for i, rawData := range rawDataList {
if !templates.HasTemplate(rawData, "", true) && !isRawObjTemplate {
hasTemplate := templates.HasTemplate(rawData, "", true)

if !hasTemplate && !isRawObjTemplate {
continue
}

if !templates.HasTemplate(rawData, "", true) {
// Unmarshal raw template YAML into object if that has not already been done by the template
// resolution function
if !hasTemplate {
// Unmarshal raw template YAML into object as it doesn't need template resolution
err := yaml.Unmarshal(rawData, &objTemps)
if err != nil {
addTemplateErrorViolation("Error parsing the YAML in the object-templates-raw field", err.Error())
Expand Down

0 comments on commit 586c37d

Please sign in to comment.