json - Helm 为 nginx 模板转换数据
问题描述
我通过 helm 使用以下文件
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-cfg
data:
default.conf: |-
{{ .Files.Get "config/nginx.conf" | nindent 4 }}
我收到以下错误:
错误:ops/templates/config/nginx.conf 上的 YAML 解析错误:将 YAML 转换为 JSON 时出错:yaml:第 4 行:此上下文中不允许映射值
nginx 文件如下所示
nginx.conf
server {
listen 80;
listen [::]:80;
server_name: {{ print "kiftb." .Values.global.host | quote }} // this is the error line
...
带有sever_name
创建错误的行。
知道如何解决吗?
更新
正如@Evan 所建议的,我试图删除冒号,
server_name {{ print "kiftb." .Values.global.host | quote }}
我得到一个错误:
error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type releaseutil.SimpleHead
helm.go:81: [debug] error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type releaseutil.SimpleHead
任何想法如何克服这个?有什么解决方法吗?
解决方案
尝试删除之后的冒号server_name
。
server_name {{ print "kiftb." .Values.global.host | quote }}
...
推荐阅读
- python - Odoo 8 - 无法使用 self.env 获取对象的内容
- java - 我怎样才能修改我的代码,使其免受死锁的影响?
- java - 如何在 Android pie 中记录通话?
- c++ - 如何在 lambda 中写入文件?
- r - 在移动包中运行 align_move 时,dimnames (slot(x, "coords") 出错
- mysql - 迭代日期 Mysql 循环
- sockets - 对监听多个端口的 telnet 服务器进行同步泛洪攻击
- java - 我不知道我的 Android Studio 发生了什么,我没有 Google Material 的任何组件
- bash - 与 $() 具有不同输出的反引号
- javascript - 如何将 Google Visualization API 的日期列转换为 JSON 格式