在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:gruntwork-io/pre-commit开源软件地址:https://github.com/gruntwork-io/pre-commit开源编程语言:Shell 75.9%开源软件介绍:Pre-commit hooksThis repo defines Git pre-commit hooks intended for use with pre-commit. The currently supported hooks are:
General UsageIn each of your repos, add a file called repos:
- repo: https://github.com/gruntwork-io/pre-commit
rev: <VERSION> # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
hooks:
- id: terraform-fmt
- id: terraform-validate
- id: tflint
- id: shellcheck
- id: gofmt
- id: golint Next, have every developer:
That’s it! Now every time you commit a code change ( Running Against All Files At OnceExample: Formatting all filesIf you'd like to format all of your code at once (rather than one file at a time), you can run: pre-commit run terraform-fmt --all-files Example: Enforcing in CIIf you'd like to enforce all your hooks, you can configure your CI build to fail if the code doesn't pass checks by adding the following to your build scripts: pip install pre-commit
pre-commit install
pre-commit run --all-files If all the hooks pass, the last command will exit with an exit code of 0. If any of the hooks make changes (e.g., because files are not formatted), the last command will exit with a code of 1, causing the build to fail. Helm Lint CaveatsDetecting chartsThe Note that charts are detected by walking up the directory tree of the changed file and looking for a linter_values.yaml
Therefore, to support this, this pre-commit hook looks for a special For example, suppose you had a helm chart that defined two input values: # values.yaml
# containerImage is required and defines which image to use
# containerTag specifies the image tag to use. Defaults to latest.
containerTag: latest If you run # linter_values.yaml
containerImage: nginx Now when the pre-commit hook runs, it will call
Shellcheck ArgumentsTo enable optional shellcheck features you can use the repos:
- repo: https://github.com/gruntwork-io/pre-commit
rev: <VERSION>
hooks:
- id: shellcheck
args: ["--enable require-variable-braces,deprecate-which"] LicenseThis code is released under the Apache 2.0 License. Please see LICENSE and NOTICE for more details. Copyright © 2019 Gruntwork, Inc. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论