diff --git a/core/pkg/fixhandler/fixhandler_test.go b/core/pkg/fixhandler/fixhandler_test.go index 6bdd293e..5236705c 100644 --- a/core/pkg/fixhandler/fixhandler_test.go +++ b/core/pkg/fixhandler/fixhandler_test.go @@ -132,6 +132,12 @@ func getTestCases() []indentationTestCase { select(di==0).spec.securityContext.runAsRoot |= false`, "hybrids/tc-02-01-expected.yaml", }, + { + "hybrids/tc-03-00-input-comments.yaml", + `del(select(di==0).spec.containers[0].securityContext) | + select(di==0).spec.securityContext.runAsRoot |= false`, + "hybrids/tc-03-01-expected.yaml", + }, } return indentationTestCases diff --git a/core/pkg/fixhandler/testdata/hybrids/tc-03-00-input-comments.yaml b/core/pkg/fixhandler/testdata/hybrids/tc-03-00-input-comments.yaml new file mode 100644 index 00000000..ea5c9c51 --- /dev/null +++ b/core/pkg/fixhandler/testdata/hybrids/tc-03-00-input-comments.yaml @@ -0,0 +1,21 @@ +# Fix to Apply: +# REMOVE: +# "del(select(di==0).spec.containers[0].securityContext)" + +# INSERT: +# select(di==0).spec.securityContext.runAsRoot: false + + +apiVersion: v1 +kind: Pod +metadata: + name: insert_to_mapping_node_1 + +spec: + # These are the container comments + containers: + # These are the first containers comments + - name: nginx_container + image: nginx + securityContext: + runAsRoot: true diff --git a/core/pkg/fixhandler/testdata/hybrids/tc-03-01-expected.yaml b/core/pkg/fixhandler/testdata/hybrids/tc-03-01-expected.yaml new file mode 100644 index 00000000..87ef2595 --- /dev/null +++ b/core/pkg/fixhandler/testdata/hybrids/tc-03-01-expected.yaml @@ -0,0 +1,21 @@ +# Fix to Apply: +# REMOVE: +# "del(select(di==0).spec.containers[0].securityContext)" + +# INSERT: +# select(di==0).spec.securityContext.runAsRoot: false + + +apiVersion: v1 +kind: Pod +metadata: + name: insert_to_mapping_node_1 + +spec: + # These are the container comments + containers: + # These are the first containers comments + - name: nginx_container + image: nginx + securityContext: + runAsRoot: false