Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Fix YTT processing to avoid errors parsing passwords
Browse files Browse the repository at this point in the history
Fixes our ytt processor so that password values are not passed to the yaml
parser as yaml. This prevents the password from being interpreted as
yaml, which could lead to template errors and other failures.
  • Loading branch information
tenczar committed Apr 6, 2023
1 parent 4b16cc4 commit f32efce
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tkg/yamlprocessor/ytt.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"
"sort"
"strconv"
"strings"

"github.com/pkg/errors"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -166,6 +167,7 @@ func (p *YTTProcessor) Process(rawArtifact []byte, variablesClient func(string)

// build out the data values for ytt
dataValues := make([]string, 0, len(variables))
stringValues := make([]string, 0, len(variables))
for _, vName := range variables {
vValue, err := variablesClient(vName)
if err != nil {
Expand All @@ -189,14 +191,17 @@ func (p *YTTProcessor) Process(rawArtifact []byte, variablesClient func(string)
}
}

if convertable {
if strings.Contains(strings.ToUpper(vName), "PASSWORD") {
stringValues = append(stringValues, fmt.Sprintf("%s=%s", vName, vValue))
} else if convertable {
dataValues = append(dataValues, fmt.Sprintf("%s=%s", vName, vValue))
} else {
dataValues = append(dataValues, fmt.Sprintf("%s=%q", vName, vValue))
}
}
dvf := template.DataValuesFlags{
KVsFromYAML: dataValues,
KVsFromStrings: stringValues,
KVsFromYAML: dataValues,
}

// add the data values as overlays to the ytt templates
Expand Down

0 comments on commit f32efce

Please sign in to comment.