Comments (4)
+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.
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.
'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.
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)
- Docker support
- Unexpected ':' HOT 1
- why is this suggested to be used with yamllint, it can be aligned with its rules? HOT 1
- pre-commit hook installation fails on linux HOT 2
- Question: What could be the args to get same output as `yq' ? HOT 2
- File path issue when running locally on Windows HOT 9
- Installation with tag 0.1.0 is failing HOT 1
- Implement dictionary key sorting
- yamllint
- Setting different offset breaks hte pre-commit-hook config HOT 1
- mapping values are not allowed here HOT 1
- Is it possible to ignore a line ? HOT 1
- Add argument for accepting path to config file
- Pin ruamel.yaml dependency version HOT 5
- Recommended autoformatter introduces lint errors HOT 3
- yamlfmt conflicts with yamllint if there is a long URL HOT 4
- Docs request: `pip install` instructions to the README
- Request: ability to use double quotes
- ruamel.yaml.clib 0.2.8 breaks the hook HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pre-commit-hook-yamlfmt.