feat: Implement conditional quoting in shellVariablesEncoder

- Modify doEncode method to check pe.prefs.UnwrapScalar.
- If UnwrapScalar is true, output raw node.Value.
- Otherwise, use quoteValue for shell-safe quoting.
- This enables quote-free output for Kubernetes workflows when -r is used.
This commit is contained in:
flintwinters 2025-12-17 00:27:09 -05:00
parent c859948ca9
commit fe0ed2a8b1

View File

@ -57,7 +57,13 @@ func (pe *shellVariablesEncoder) doEncode(w *io.Writer, node *CandidateNode, pat
// let's just pick a fallback key to use if we are encoding a single scalar // let's just pick a fallback key to use if we are encoding a single scalar
nonemptyPath = "value" nonemptyPath = "value"
} }
_, err := io.WriteString(*w, nonemptyPath+"="+quoteValue(node.Value)+"\n") var valueString string
if pe.prefs.UnwrapScalar {
valueString = node.Value
} else {
valueString = quoteValue(node.Value)
}
_, err := io.WriteString(*w, nonemptyPath+"="+valueString+"\n")
return err return err
case SequenceNode: case SequenceNode:
for index, child := range node.Content { for index, child := range node.Content {