YAML中的整数类型转换

3
以下是我的流量转移的istio yaml。如果我在Spinnaker中传递参数,我会遇到以下错误。我只发送像10、20等整数值。
"json: cannot unmarshal string into Go value of type int32"
我能否在yaml中将字符串更改为整数?
- apiVersion: networking.istio.io/v1alpha3
  kind: VirtualService
  metadata:
    name: webvs
    namespace: default
  spec:
    gateways:
      - xyz.default.svc.cluster.local
      - mesh
    hosts:
      - web.xyz.com
    http:
      - route:
          - destination:
              host: web.default.svc.cluster.local
              port:
                number: 8080
              subset: v1
            weight: '${ parameters.Prodweightb }'
          - destination:
              host: web.default.svc.cluster.local
              port:
                number: 8080
              subset: v2
            weight: '${ parameters.Blineweightb }'
          - destination:
              host: web.default.svc.cluster.local
              port:
                number: 8080
              subset: v3
            weight: '${ parameters.Canaryweightb }'
1个回答

2
您的yaml文件存在问题,即整数参数值周围有单引号。请尝试将其删除,例如:
weight: ${ parameters.Canaryweightb }

1
Spinnaker会自动分配这些单引号。 - undefined
有没有办法告诉Spinnaker这个值是整数(而不是字符串),这样它就不会添加引号了? - undefined
2
我可以使用Spinnaker中的以下表示法来解决它。'${ #toInt( parameters.Prodweightb ) }' '${ #toInt( parameters.Blineweightb ) }' '${ #toInt( parameters.Canaryweightb ) }' - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接