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 {
3838
3939// EvaluateExpression evaluates the yq expression, and returns the modified yaml.
4040func EvaluateExpression (expression string , content []byte ) ([]byte , error ) {
41+ if expression == "" {
42+ return content , nil
43+ }
4144 logrus .Debugf ("Evaluating yq expression: %q" , expression )
4245 formatter , err := yamlfmtBasicFormatter ()
4346 if err != nil {
Original file line number Diff line number Diff line change @@ -25,6 +25,17 @@ func TestValidateContentError(t *testing.T) {
2525 assert .ErrorContains (t , err , "could not find expected" )
2626}
2727
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+
2839func TestEvaluateExpressionSimple (t * testing.T ) {
2940 expression := `.cpus = 2 | .memory = "2GiB"`
3041 content := `
You can’t perform that action at this time.
0 commit comments