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

yamllint does not respect the ignore field of .yamllint.yaml #214

Open
adam-rummer-hpe opened this issue Nov 27, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@adam-rummer-hpe
Copy link

adam-rummer-hpe commented Nov 27, 2023

1️⃣ Description

yamlfix does not respect the following config file, while yamllint does. Executing both like '<yamllint|yamlfix> -c .yamllint.yaml .'

# .yamllint.yaml
---
yaml-files:
  - '*.yaml'
  - '*.yml'
# .gitignore style
# chart dirs contain pre-rendered yaml
ignore: |
  **/charts/**

📑 Steps to Reproduce

Steps to reproduce the behavior:

  1. Place .yamllint.yaml file at root of repo
  2. execute like '<yamllint|yamlfix> -c .yamllint.yaml .' (both freshly pip installed)
  3. yamllint passes, yamlfix fails at a helm template file
  4. yamlfix output doesn't seem to indicate what file actually failed
``` [+] YamlFix: Fixing files Traceback (most recent call last): File "/opt/homebrew/bin/yamlfix", line 8, in sys.exit(cli()) ^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1157, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/yamlfix/entrypoints/cli.py", line 119, in cli fixed_code, changed = services.fix_files(files_to_fix, check, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/yamlfix/services.py", line 83, in fix_files fixed_source = fix_code(source, config) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/yamlfix/services.py", line 162, in fix_code source_code = fixer.fix(source_code=source_code) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/yamlfix/adapters.py", line 363, in fix source_code = fixer(source_code) ^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/yamlfix/adapters.py", line 381, in _ruamel_yaml_fixer for source_dict in source_dicts: File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/main.py", line 477, in load_all yield constructor.get_data() ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/constructor.py", line 134, in get_data return self.construct_document(self.composer.get_node()) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/composer.py", line 63, in get_node return self.compose_document() ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/composer.py", line 96, in compose_document node = self.compose_node(None, None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/composer.py", line 142, in compose_node node = self.compose_mapping_node(anchor) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/composer.py", line 222, in compose_mapping_node item_value = self.compose_node(node, item_key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/composer.py", line 142, in compose_node node = self.compose_mapping_node(anchor) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/composer.py", line 215, in compose_mapping_node while not self.parser.check_event(MappingEndEvent): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/parser.py", line 150, in check_event self.current_event = self.state() ^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/parser.py", line 636, in parse_block_mapping_key if self.scanner.check_token(KeyToken): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/scanner.py", line 1826, in check_token self.fetch_more_tokens() File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/scanner.py", line 229, in fetch_more_tokens self.stale_possible_simple_keys() File "/opt/homebrew/lib/python3.11/site-packages/ruyaml/scanner.py", line 362, in stale_possible_simple_keys raise ScannerError( ruyaml.scanner.ScannerError: while scanning a simple key in "", line 7, column 3: {{-★with★.Values.serviceMonitor. ... ^ (line: 7) could not find expected ':' in "", line 8, column 3: annotations: ^ (line: 8) ```

2️⃣ Expected behavior

Yamlfix respects the same config file yamllint does, and doesn't fail on these helm template files. In places where it would panic, I'd expect the output to tell me what file failed validation

3️⃣ Scripts

ℹ️ Environment details

  • OS: macos
  • Python runtime
    python3 --version
    Python 3.11.6
  • The output of yamlfixer --version
    yamlfix --version

 yamlfix: 1.16.0
 Python: 3.11.6
 Platform: macOS-13.0-arm64-arm-64bit

  • Used shell: zsh

Additional context

This also fails when explicitly passing an exclude flag like yamlfix -c .yamllint.yaml --exclude='**/charts/**' .

@adam-rummer-hpe adam-rummer-hpe added the bug Something isn't working label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant