File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ func ValidateContent(content []byte) error {
38
38
39
39
// EvaluateExpression evaluates the yq expression, and returns the modified yaml.
40
40
func EvaluateExpression (expression string , content []byte ) ([]byte , error ) {
41
+ if expression == "" {
42
+ return content , nil
43
+ }
41
44
logrus .Debugf ("Evaluating yq expression: %q" , expression )
42
45
formatter , err := yamlfmtBasicFormatter ()
43
46
if err != nil {
Original file line number Diff line number Diff line change @@ -25,6 +25,17 @@ func TestValidateContentError(t *testing.T) {
25
25
assert .ErrorContains (t , err , "could not find expected" )
26
26
}
27
27
28
+ func TestEvaluateExpressionEmpty (t * testing.T ) {
29
+ expression := ""
30
+ content := `
31
+ foo: bar
32
+ `
33
+ expected := content
34
+ out , err := EvaluateExpression (expression , []byte (content ))
35
+ assert .NilError (t , err )
36
+ assert .Equal (t , expected , string (out ))
37
+ }
38
+
28
39
func TestEvaluateExpressionSimple (t * testing.T ) {
29
40
expression := `.cpus = 2 | .memory = "2GiB"`
30
41
content := `
You can’t perform that action at this time.
0 commit comments