首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >helm模板在使用nindent时添加空行

问helm模板在使用nindent时添加空行
EN

Stack Overflow用户
提问于 2021-05-20 13:01:13
回答 1查看 2.7K关注 0票数 0

我的deployment.yaml

代码语言:javascript
复制
apiVersion: apps/v1
kind: Deployment
metadata:
  name: foo
  labels:
    app: foo
spec:
  selector:
    matchLabels:
      app: foo
  template:
    metadata:
      labels:
        app: foo
    spec:
      {{- include "pod" . | nindent 6 }}

我的_pod.tpl

代码语言:javascript
复制
{{- define "pod" -}}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
  {{- toYaml . | nindent 2 }}
{{- end }}
serviceAccountName: foo
containers:
  - name: foo
    image: nginx:latest
{{- end }}

给我:

代码语言:javascript
复制
# Source: foo/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: foo
  labels:
    app: foo
spec:
  selector:
    matchLabels:
      app: foo
  template:
    metadata:
      labels:
        app: foo
    spec:
      
      imagePullSecrets:
        - name: bar
      serviceAccountName: foo
      containers:
        - name: foo
          image: nginx:latest

为什么在spec:之后有一个空行

编辑的

但是,在部署中使用{{- include "pod" . | indent 6 }}时没有空行,但是在spec:之后有6个空白空间,如:spec:。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-24 11:05:11

-- indent函数与缩进函数相同,但在字符串的开头加上新行。

参考:https://helm.sh/docs/chart_template_guide/function_list/#nindent

您应该使用indent而不是nindent,以避免在spec:之后出现新行

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67620863

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档