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

Feature Request: Identify poorly indented states (e.g. only using one space instead of two) #246

Open
myii opened this issue Feb 21, 2021 · 2 comments
Labels
Type: Enhancement New feature or request

Comments

@myii
Copy link
Contributor

myii commented Feb 21, 2021

Is your feature request related to a problem? Please describe.

salt-lint should catch poorly indented states.

https://github.com/saltstack-formulas/haproxy-formula/blob/958c2d9249b276d1844605091608e02dc3601512/haproxy/config.sls#L4-L19

haproxy.config:
 file.managed:
   - name: {{ config_file }}
   - source: {{ haproxy.config_file_source }}
   - template: jinja
   - user: {{ haproxy.user }}
   - group: {{ haproxy.group }}
   - mode: 644
   - require_in:
     - service: haproxy.service
   - watch_in:
     - service: haproxy.service
   {% if salt['pillar.get']('haproxy:overwrite', default=True) == False %}
   - unless:
     - test -e {{ config_file }}
   {% endif %}
  • Initial indent is only one space instead of two and consequently, the rest of the lines are using an odd number of spaces.

Describe the solution you'd like

Run salt-lint on the above file and it will pass. salt-lint has been enabled for this repository for a long time now, here's the last run:

https://gitlab.com/saltstack-formulas/haproxy-formula/-/jobs/914490845#L171

Check Salt files using salt-lint.........................................Passed
- hook id: salt-lint
- duration: 0.13s
Examining test/salt/salt/hosts/init.sls of type state
Examining haproxy/service.sls of type state
Examining haproxy/init.sls of type state
Examining /tmp/tmpvfw2xbmk.sls of type state
Examining haproxy/install.sls of type state
Examining haproxy/templates/haproxy.jinja of type state
Examining test/salt/pillar/hosts.sls of type state
Examining haproxy/config.sls of type state
Examining haproxy/map.jinja of type state

Examining haproxy/config.sls of type state should show a failure.

@myii myii added the Type: Enhancement New feature or request label Feb 21, 2021
@roaldnefs
Copy link
Member

Thanks @myii for your feature request!

This might automatically be detected by allowing yamllint to run on the states stripped of any Jinja (#240).

@myii
Copy link
Contributor Author

myii commented Feb 21, 2021

Thanks @myii for your feature request!

This might automatically be detected by allowing yamllint to run on the states stripped of any Jinja (#240).

@roaldnefs Yes, that definitely will work. #240 would be a fantastic addition to salt-lint.

Thanks for the prompt reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants