Giter VIP home page Giter VIP logo

Comments (4)

dmitry-mightydevops avatar dmitry-mightydevops commented on June 30, 2024

+1, I have run into the same issue. I have some templates with HELM blocks inside files with yaml extension

➜ git commit -m "feat: prepare prod solution"
check for added large files..............................................Passed
check for merge conflicts................................................Passed
forbid new submodules................................(no files to check)Skipped
don't commit to branch...................................................Passed
check for broken symlinks............................(no files to check)Skipped
mixed line ending........................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
check for case conflicts.................................................Passed
Format YAML files........................................................Failed
- hook id: yamlfmt
- exit code: 1

staging/ppc/high-priority.yaml  Done
staging/argocd/apps/templates/velero.yamlTraceback (most recent call last):
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/bin/yamlfmt", line 181, in <module>
    FORMATTER.format(file_name)
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/bin/yamlfmt", line 137, in format
    FORMATTER.parse_file(path)
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/bin/yamlfmt", line 147, in parse_file
    self.content = list(self.yaml.load_all(stream))
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/main.py", line 461, in load_all
    yield constructor.get_data()
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 114, in get_data
    return self.construct_document(self.composer.get_node())
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/composer.py", line 66, in get_node
    return self.compose_document()
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/composer.py", line 99, in compose_document
    node = self.compose_node(None, None)
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/composer.py", line 143, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/composer.py", line 218, in compose_mapping_node
    item_key = self.compose_node(node, None)
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/composer.py", line 143, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/composer.py", line 216, in compose_mapping_node
    while not self.parser.check_event(MappingEndEvent):
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/parser.py", line 146, in check_event
    self.current_event = self.state()
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/parser.py", line 743, in parse_flow_mapping_first_key
    return self.parse_flow_mapping_key(first=True)
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/parser.py", line 776, in parse_flow_mapping_key
    return self.parse_flow_node()
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/parser.py", line 348, in parse_flow_node
    return self.parse_node()
  File "/home/dmitry/.cache/pre-commit/repotn97rwh1/py_env-python3.9/lib/python3.9/site-packages/ruamel/yaml/parser.py", line 509, in parse_node
    raise ParserError(
ruamel.yaml.parser.ParserError: while parsing a flow node
expected the node content, but found '-'
  in "staging/argocd/apps/templates/velero.yaml", line 1, column 3
.pre-commit-config.yaml  Done
staging/coredns/coredns-hpa.yaml  Done

from pre-commit-hook-yamlfmt.

shellshock1953 avatar shellshock1953 commented on June 30, 2024

Seems it should be done using pre-commit level:

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
  rev: 0.2.1
  hooks:
  - id: yamlfmt
    args: [--mapping, '2', --sequence, '2', --offset, '0']
    exclude: ^charts/

from pre-commit-hook-yamlfmt.

vvarga007 avatar vvarga007 commented on June 30, 2024

'exclude' is a regex, so if you want to exclude multiple files, it should be something like this:

  - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
    rev: 0.2.1
    hooks:
      - id: yamlfmt
        args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '160']
        exclude: (.yamllint|modules/gatus/configs/.*)

from pre-commit-hook-yamlfmt.

rafaribe avatar rafaribe commented on June 30, 2024

Is it possible to include a configuration file?
I've tried this way but the config file is not respected:

    - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
      rev: 0.2.1 # or other specific tag
      hooks:
          - args:
                - -c
                - .github/linters/.yamlfmt
            id: yamlfmt

from pre-commit-hook-yamlfmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.