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

Unexpected behaviour of YAML decoder #91

Closed
glyn opened this issue Apr 2, 2020 · 2 comments
Closed

Unexpected behaviour of YAML decoder #91

glyn opened this issue Apr 2, 2020 · 2 comments

Comments

@glyn
Copy link

glyn commented Apr 2, 2020

I tried using the API machinery YAML utility to split a stream of YAML documents into individual documents. It doesn’t seem to cope with certain cases and I am wondering if that was intentional, a restriction, or what.

In particular, directives don't appear to be grouped with the document they apply to. For example:

%YAML 1.2
---
a: b
...
%YAML 1.2
---
c: d

splits into three documents instead of two:

%YAML 1.2
a: b
...
%YAML 1.2
c: d

See the code here which reproduces the above: https://play.golang.org/p/fgqRm_16LJV.

There are also small issues around when newlines are preserved.

Ideally, NewDocumentDecoder should satisfy these properties:

  • each document produced should be a valid YAML document consisting of a substring of the input string
  • when the documents produced are concatenated together, the resultant string should be equal to the input string

Here is some code and a test which pins down the unexpected behaviour a bit better: split.go.txt,split_test.go.txt. (I added the .txt to the filenames since I couldn't attach .go files.)

@dims
Copy link
Member

dims commented Apr 2, 2020

fyi kubernetes/kubernetes#34146

also this repo is not really watched as this is bot generated/updated repo. please use kubernetes/kubernetes

@glyn
Copy link
Author

glyn commented Apr 2, 2020

fyi kubernetes/kubernetes#34146

That's pretty revealing. Thanks.

also this repo is not really watched as this is bot generated/updated repo. please use kubernetes/kubernetes

Moved to kubernetes/kubernetes#89764

@glyn glyn closed this as completed Apr 2, 2020
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