Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

values 传yaml文本 invalid character 'x' after object key:value pair" #64

Open
lic0914 opened this issue Jun 22, 2022 · 2 comments
Open

Comments

@lic0914
Copy link

lic0914 commented Jun 22, 2022

版本最新的
传值的 values 如下
获取方式

values="`curl -s -X GET $url --header 'Content-Type: application/json' | jq ".data"`"
env:\n  ASPNETCORE_ENVIRONMENT: Staging\n  PayOrderAppSetting__RunEnvironment: Test\nglobal:\n  cattle:\n    clusterId: c-9lmh5\n    clusterName: k8s-online\n    rkePathPrefix: \"\"\n    rkeWindowsPathPrefix: \"\"\n    systemDefaultRegistry: \"\"\n    url: https://rancher.xxxx.com\n  systemDefaultRegistry: \"\"\nimage:\n  pullPolicy: Always\n  tag: final-0.0.2\ningress:\n  hosts:\n  - host: www.xxx.cn\n    paths:\n    - path: /gateway/xxx\n      pathType: ImplementationSpecific\nreplicaCount: 1\n

更新

res=`curl -s  -X PUT $url     --header 'Content-Type: application/json'     -d "{ \"set\": [\"image.tag=$version\"],  \"repo\": \"$Chart_Repo\",  \"values\": \"$values\"  }"`
echo "response : $res"
code=`echo $res | jq ".code"`
exit $code

在更新时会出现

{"code":1,"error":"invalid character 'e' after object key:value pair"}

在 Postman 中执行 正常

@lic0914 lic0914 changed the title values 传值 偶尔出现 invalid character 'x' after object key:value pair" values 传yaml文本 invalid character 'x' after object key:value pair" Jun 23, 2022
@lic0914
Copy link
Author

lic0914 commented Jun 23, 2022

查看源码了解到 是 Gin 在 c.ShouldBindJSON抛出异常
最终原因确定是 values值 在 curl 中转义造成的
当前需要满足以下条件

  • values 是变量
  • 使用curl做请求

是否考虑使用 values 做base64编码在进行发送呢
谢谢!!!

@opskumu
Copy link
Owner

opskumu commented Jun 23, 2022

@lic0914 base64 确实是个好办法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants