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

Changed way of linting YAML files. #90

Merged
merged 3 commits into from
Dec 5, 2016
Merged

Conversation

krzyzakp
Copy link
Collaborator

@krzyzakp krzyzakp commented Oct 5, 2016

This should fix issue #88

Copy link

@aranc23 aranc23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried yaml-lint on a variety of yaml files, even a file consisting only of

adjf
"passes" the yaml-lint saying Syntax OK

the python yamllint tool says this of the same file:
test.yaml
1:1 warning missing document start "---" (document-start)
3:1 error too many blank lines (2 > 0) (empty-lines)

@aranc23
Copy link

aranc23 commented Oct 7, 2016

I also tried using rbenv to install ruby 2.3.0 and then using bundle install to get the yaml-lint binary. Same results...

@krzyzakp
Copy link
Collaborator Author

@aranc23 Problem with file, which you raised seems not to be valid - for Ruby YAML library such file looks ok:

krzyzakp@rocket:/tmp  $ cat test2.yaml                                                                                                                             dasdsa
krzyzakp@rocket:/tmp  $ yaml-lint test2.yaml                                                                                                                       Checking the content of ["test2.yaml"]
File : test2.yaml, Syntax OK
Done.
krzyzakp@rocket:/tmp  $ ruby -e "require 'yaml'; YAML.parse(File.open('test2.yaml'))"   
krzyzakp@rocket:/tmp  $          

However if I have really corrupted yaml file, it acts same way as ruby itself:

krzyzakp@rocket:/tmp  $ cat test.yaml                                                                                                                              dsdsa: 'dsas' dsadas:
dsad:
 - dasda
 - asdas
krzyzakp@rocket:/tmp  $ yaml-lint test.yaml                                                                                                                        Checking the content of ["test.yaml"]
File : test.yaml, error: (test.yaml): did not find expected key while parsing a block mapping at line 1 column 1
Done.
krzyzakp@rocket:/tmp  $ ruby -e "require 'yaml'; YAML.parse(File.open('test.yaml'))"                                                                               /usr/lib/ruby/2.1.0/psych.rb:370:in `parse': (<unknown>): did not find expected key while parsing a block mapping at line 1 column 1 (Psych::SyntaxError)
    from /usr/lib/ruby/2.1.0/psych.rb:370:in `parse_stream'
    from /usr/lib/ruby/2.1.0/psych.rb:318:in `parse'
    from -e:1:in `<main>'
krzyzakp@rocket:/tmp  $ 

Things which you mentioned in python yaml lint are more about following specification - first is warning, so just advice, as file without it is still being able to parse. Second one is error for linting, but same as before - yaml interpreter will be able to load and parse this file.
I agree, that Python tool is more precise and could be a good choice, however whole library is written in Bash+Ruby, so adding Python there as third language is bad idea. What more Puppet is better supported in Ruby, as it's written in this language.

Personally I would prefer also Python, but for tight integration with Puppet, Ruby works better.

@krzyzakp krzyzakp merged commit d315776 into drwahl:master Dec 5, 2016
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

Successfully merging this pull request may close these issues.

2 participants