Closed Sammers21 closed 4 years ago
@amihaiemil, Is there any option to remove the validation
part or make it less strict?
@Sammers21 No, unfortunately validation cannot be disabled or removed. The YAML format has some strict rules which have to be followed and indentation is one of them -- that's why we try to validate that.
There is a known bug in the eo-yaml, and that is sequences or mappings within a sequence have to start at the next line with reference to the -
.
The following are both valid YAML Sequences:
- scalar1
- key: value
key1: value1
- scalar2
- scalar1
-
key: value
key1: value1
- scalar2
But eo-yaml can only parse the second version correctly.
I see in your examples there are mappings as sequence elements which start on the same line as the -
. E.g.:
- name: yahavb
email: ybiran@ananware.systems
Should be:
-
name: yahavb
email: ybiran@ananware.systems
Can you make this change and try again? There are also other issues in your YAML, which are real indentation problems. For instance:
keywords:
- mysql
- database
- sql
is not correctly indented. It should be:
keywords:
- mysql
- database
- sql
@Sammers21 Here is your first YAML, which should work now (I fixed it):
apiVersion: v1
appVersion: 5.7.30
description: Fast, reliable, scalable, and easy to use open-source relational database system.
home: https://www.mysql.com/
icon: https://www.mysql.com/common/logos/logo-mysql-170x115.png
keywords:
- mysql
- database
- sql
maintainers:
-
email: o.with@sportradar.com
name: olemarkus
-
email: viglesias@google.com
name: viglesiasce
name: mysql
sources:
- https://github.com/kubernetes/charts
- https://github.com/docker-library/mysql
version: 1.6.4
and the second one:
apiVersion: v1
name: tomcat
description: Deploy a basic tomcat application server with sidecar as web archive container
icon: http://tomcat.apache.org/res/images/tomcat.png
version: 0.4.1
appVersion: "7.0"
home: https://github.com/yahavb
maintainers:
-
name: yahavb
email: ybiran@ananware.systems
@amihaiemil, I'm not writing those YAML files and that is why I could not correct them. Some of the example you can find here: https://github.com/helm/charts/tree/master/stable
@Sammers21 well, even if the bug in eo-yaml was not there, they are still not correct because of the keywords
and sources
elements indentation...
I cannot make any changes about that because YAML indentation is really relevant and it has to be correct.
@Sammers21 And particularly, in eo-yaml, indentation is used in the reading logic. So even if I take out the validation, it will not work because eo-yaml will not read the elements correctly.
@amihaiemil, why all the Yaml validators are saying the opposite then? And can you refer to a specific spec paragraph?
@amihaiemil, also, is there any way to fix
the formatting without any manual manipulations?
@Sammers21 See here. The Specification defines that structure is determined by indentation in Block YAML.
why all the Yaml validators are saying the opposite then?
I don't know, but you should know that people generally avoid YAML particularly because the Specification is too complex and there are very few YAML parsers that do not have any problems.
is there any way to fix the formatting without any manual manipulations?
No, eo-yaml just Reads the YAML. If inconsistencies are found in indentation/structure, it cannot really know what the correct path is so it throws an exception.
@amihaiemil, as a note: snakeyaml works perfectly fine with those files.
@Sammers21 snakeyaml is much older and robust than eo-yaml :)
@Sammers21 I'm closing this since there's nothing I can do about it.
a little note, its called MapList
in yaml/json. in json it looks like that;
{
"test": "test",
"test-map-list": [
{
"email": "o.with@sportradar.com",
"name": "olemarkus"
},
{
"email": "viglesias@google.com",
"name": "viglesiasce"
},
],
"test-2": "test-2"
}
@amihaiemil, why this issue is open again?
@Sammers21 Because I'm working on it. First step is to fix the problem with mappings within a sequence, that start at the same line with the dash (-
). This is almost done.
Then, I'll have a look and see if I can do something about the indentation issues... maybe I can add some formatting rules.
@amihaiemil, what do you thing about wrapping snake-yaml, while keeping the design without any changes?
@Sammers21 That's not an option, sorry. A library should fix its own problems and requirements, not wrap another library in yet another set of abstractions.
@Sammers21 but if you like eo-yaml's interfaces, you can implement them yourself, based on snake-yaml. It shouldn't be hard :)
@Sammers21 The bug about reading mappings within sequences, which start at the dash line, has just been fixed and released with version 5.0.3
. See here.
I'll continue with #361 and see if I can implement some default formatting rules.
@Sammers21 @g4s8 I just released version 5.1.0
which allows you to bypass the validation of indentation.
However, this might result in a different YAML than what you expect, so I only recommend you do it if you have proper tests for your code. More details here.
I'm closing this Issue now as I think all the related bugs have been fixed. Please feel free to open another one if you still have problems.
Some of the YAML files, which this project is not able to parse.
Stack trace:
Note: some of the YAML validators claims that those 2 files are actually valid ones