argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
18.04k stars 5.51k forks source link

jsonnet std.parseYaml wraps result in an array when string values contain --- #17676

Open SamuraiPrinciple opened 8 months ago

SamuraiPrinciple commented 8 months ago

Checklist:

Describe the bug

When using Jsonnet to generate manifests, std.parseYaml function returns incorrect result when string values contain ---

I've also filed an issue here:

https://github.com/google/jsonnet/issues/1147

Jsonnet go implementation (https://github.com/google/go-jsonnet) seems unaffected when I tested it locally (which is strange, because I believe that's the version argocd is using).

To Reproduce

Create an app with test.jsonnet file with the following content:

{
  apiVersion: 'v1',
  kind: 'ConfigMap',
  metadata: { name: 'repro' },
  data: {
    'key': std.parseYaml('a: bad---'),
  },
}

Expected behavior

the key value should be {"a": "bad---"} and not [{"a": "bad---"}]

Screenshots

Screenshot 2024-03-31 at 15 43 54

Version

argocd: v2.10.5+335875d
  BuildDate: 2024-03-28T15:02:45Z
  GitCommit: 335875d13e018bed6e03873f4742582582964745
  GitTreeState: clean
  GoVersion: go1.21.3
  Compiler: gc
  Platform: linux/amd64
FATA[0000] Argo CD server address unspecified           

Logs

Not relevant

SamuraiPrinciple commented 8 months ago

Apologies, after receiving some feedback on issue https://github.com/google/jsonnet/issues/1147 I've realised that I've got it wrong way around - it's the go-jsonnet version that affected (which explains why argocd is affected too). Also, opened the issue in relevant project now - https://github.com/google/go-jsonnet/issues/749

andrii-korotkov-verkada commented 2 weeks ago

ArgoCD versions 2.10 and below have reached EOL. Can you upgrade and tell us if the issue is still present, please?

SamuraiPrinciple commented 4 days ago

Yes, this is still the case with the latest version (2.13.1) - this snippet:

{ apiVersion: 'v1', kind: 'ConfigMap', metadata: { name: 'repro', namespace: 'ingress-nginx-test' }, data: { key: std.manifestYamlDoc(std.parseYaml('a: bad---')), }, }

would emit:

apiVersion: v1 data: key: '- "a": "bad---"' kind: ConfigMap metadata: labels: argocd.argoproj.io/instance: cluster-bootstrap name: repro namespace: ingress-nginx-test

instead of:

apiVersion: v1 data: key: '"a": "bad---"' kind: ConfigMap metadata: labels: argocd.argoproj.io/instance: cluster-bootstrap name: repro namespace: ingress-nginx-test