gpt4 book ai didi

kubernetes - 从 kubernetes yaml 定义中的文件创建配置映射时 |+ 和 |- 之间有什么区别?

转载 作者:行者123 更新时间:2023-12-03 16:41:06 37 4
gpt4 key购买 nike

我遇到过 2 种从 kubernetes 中的文件创建配置映射的语法。

第一个 ;

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

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

|+ 和 |- 有什么区别?

最佳答案

这是block chomping indicator .

直接引用链接:

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.



这意味着对于:
apiVersion: v1
data:
file1.yaml: |-
parameter1=value1


kind: ConfigMap
metadata:
name: my-configmap

file1.yaml 将具有以下值:
parameter1=value1

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


kind: ConfigMap
metadata:
name: my-configmap

file1.yaml 将具有以下值:
parameter1=value1 # line break
# line break
# line break

关于kubernetes - 从 kubernetes yaml 定义中的文件创建配置映射时 |+ 和 |- 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56395758/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com