kubeyaml icon indicating copy to clipboard operation
kubeyaml copied to clipboard

Kubeyaml returns questionable output on multidoc input including empty docs

Open 2opremio opened this issue 5 years ago • 3 comments

This comes from https://github.com/weaveworks/flux/issues/1925

Input:

---
# Source: webapp/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: name
  namespace: namespace
spec:
  selector:
    matchLabels:
      name: name
  template:
    metadata:
      labels:
        name: name
    spec:
      containers:
      - name: container
        image: stefanprodan/podinfo:1.4.4
---
# Source: webapp/templates/configmap.yaml
---
---
# Foo
---
---
---
---

The command:

kubeyaml.py image --namespace namespace --container container --kind deployment --name name --image bar

Results in:

---
# Source: webapp/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: name
  namespace: namespace
spec:
  selector:
    matchLabels:
      name: name
  template:
    metadata:
      labels:
        name: name
    spec:
      containers:
      - name: container
        image: stefanprodan/podinfo:latest
---
...
---
...
---
...
---
...
---
...
---
...
---
...

The output is questionable for a few reasons:

  1. The end-of-document markers (...) were not present in the original document (which makes both flux and kubectl choke). Here is the error from kubectl when trying to apply the output document:
    $ pbpaste | kubectl apply -f -
    deployment.apps/name configured
    error: error parsing STDIN: error converting YAML to JSON: yaml: did not find expected node content
    
  2. The output is missing comments.

The output seems to be correct YAML according to the standard though:

The stream format is intentionally “sloppy” to better support common use cases, such as stream concatenation.

2opremio avatar Apr 12 '19 23:04 2opremio

This makes me think that Flux never managed to successfully make releases in multi-doc manifest files.

2opremio avatar Apr 13 '19 03:04 2opremio

The example includes empty documents. Do you have evidence that it produces problematic output when there are no empty documents? If not, that might be why it doesn't seem to have shown up before.

squaremo avatar Apr 23 '19 13:04 squaremo

you are right, it only generates ... with empty documents.

2opremio avatar Apr 23 '19 13:04 2opremio