How to check YML grammar is correct (gitlab.yml)

你离开我真会死。 提交于 2019-12-06 06:04:33

问题


GitLab server can't start. The reason is likely because gitlab.yml configuration file is not correct.

What tool to use to check yml grammar is correct?

I have tried Notepad++ and SublimeText, but they show small sign in different places:

Notepad doesn't like indent for 1 line.

SublimeText

Can really indents and spaces be problem in GitLab config parser?


回答1:


What I use, and this works with any editor, is a comparison between:

  • gitlab.yml
  • gitlab.yml.example

I developed a little bash diff script which will look for differences in keys (not values, since you are supposed to put your own values there)

## LDAP setting
ldap:               (<--- it is a key)
  enabled: true
    ^^^     ^^^
    key      value

I just do a:

cd gitlab/config
check_all_diff .

That way, if there are any change in term of keys, key order, new keys or deleted keys, I can spot those when I upgrade gitlab.

To summarize, you need to copy in a directory part of your $PATH:

  • check_all_diff
  • check_diff (called by check_all_diff)

Don't forget to:

  • chmod 755 check_all_diff check_diff
  • don't introduce improper eol (end of line) character. If you did, a dos2unix will take care of those.


来源:https://stackoverflow.com/questions/17825404/how-to-check-yml-grammar-is-correct-gitlab-yml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!