What is the difference between |+ and |- when creating a configmap from a file in kubernetes yaml definitions? (block chomping indicator)

first one

apiVersion: v1
data:
  file1.yaml: |+
    parameter1=value1
kind: ConfigMap
metadata:
  name: my-configmap

second one

apiVersion: v1
data:
  file1.yaml: |-
    parameter1=value1
kind: ConfigMap
metadata:
  name: my-configmap

what is the difference between |+ and |- ?

This is the block chomping indicator.

Directly quoting from the link:

The chomping indicator controls what should happen with newlines at the end of the string. The default, clip, puts a single newline at the end of the string. To remove all newlines, strip them by putting a minus sign (-) after the style indicator. Both clip and strip ignore how many newlines are actually at the end of the block; to keep them all put a plus sign (+) after the style indicator.

This means that for:

apiVersion: v1
data:
  file1.yaml: |-
    parameter1=value1


kind: ConfigMap
metadata:
  name: my-configmap

file1.yaml will have the value:

parameter1=value1

For:

apiVersion: v1
data:
  file1.yaml: |+
    parameter1=value1


kind: ConfigMap
metadata:
  name: my-configmap

file1.yaml will have the value:

parameter1=value1 # line break
# line break
# line break

source: https://stackoverflow.com/questions/56395758/what-is-the-difference-between-and-when-creating-a-configmap-from-a-file-i

Tags:
#kubernetes #yaml #yml