Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

i've came across 2 types of syntax for creating configmaps from files in kubernetes.

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 |- ?

like image 387
whatmakesyou Avatar asked May 31 '19 13:05

whatmakesyou


1 Answers

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
like image 160
Alassane Ndiaye Avatar answered Oct 07 '22 00:10

Alassane Ndiaye