Skip to content

Commit 7b88dd7

Browse files
committed
Initial commit
Signed-off-by: Dalwar Hossain <5631766+dalwar23@users.noreply.github.com>
0 parents  commit 7b88dd7

19 files changed

Lines changed: 637 additions & 0 deletions

.codespellrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[codespell]
2+
skip = *.po
3+
ignore-words = .spellignore

.editorconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 4
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
charset = utf-8
11+
end_of_line = lf
12+
13+
[*.bat]
14+
indent_style = tab
15+
end_of_line = crlf
16+
17+
[*.{yaml,yml,toml}]
18+
indent_size = 2
19+
20+
[LICENSE]
21+
insert_final_newline = false
22+
23+
[Makefile]
24+
indent_style = tab

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
ignore = D203,F541,E722,C901,E501
3+
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,.venv
4+
max-complexity = 15

.gitignore

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
58+
# Flask stuff:
59+
instance/
60+
.webassets-cache
61+
62+
# Scrapy stuff:
63+
.scrapy
64+
65+
# Sphinx documentation
66+
docs/_build/
67+
68+
# PyBuilder
69+
target/
70+
71+
# Jupyter Notebook
72+
.ipynb_checkpoints
73+
74+
# pyenv
75+
.python-version
76+
77+
# celery beat schedule file
78+
celerybeat-schedule
79+
80+
# SageMath parsed files
81+
*.sage.py
82+
83+
# dotenv
84+
.env
85+
86+
# virtualenv
87+
.venv
88+
venv/
89+
ENV/
90+
91+
# Spyder project settings
92+
.spyderproject
93+
.spyproject
94+
95+
# Rope project settings
96+
.ropeproject
97+
98+
# mkdocs documentation
99+
/site
100+
101+
# mypy
102+
.mypy_cache/
103+
104+
# IDE settings
105+
.vscode/
106+
.idea/
107+
108+
# Discard test_results
109+
*.xml
110+
111+
# MacOS
112+
.DS_Store

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-added-large-files
8+
- id: check-executables-have-shebangs
9+
- id: check-json
10+
- id: requirements-txt-fixer
11+
- id: check-toml
12+
- id: detect-private-key
13+
- id: check-case-conflict
14+
- id: fix-encoding-pragma
15+
args:
16+
- --remove
17+
- repo: https://github.com/psf/black
18+
rev: 25.1.0
19+
hooks:
20+
- id: black
21+
args: [--line-length=120]
22+
- repo: https://github.com/codespell-project/codespell
23+
rev: v2.4.1
24+
hooks:
25+
- id: codespell
26+
args:
27+
- --config=.codespellrc
28+
- repo: https://github.com/pre-commit/pygrep-hooks
29+
rev: v1.10.0
30+
hooks:
31+
- id: rst-backticks
32+
- id: rst-directive-colons
33+
- id: rst-inline-touching-normal
34+
35+
- repo: https://github.com/astral-sh/ruff-pre-commit
36+
rev: v0.11.4
37+
hooks:
38+
- id: ruff

.pre-commit-hooks.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- id: terraform-fmt
2+
name: Lint terraform files
3+
description: Prevent malformed terraform script being commited
4+
entry: fmt
5+
language: python
6+
require_serial: true
7+
stages: [pre-commit]
8+
types: [terraform]

.spellignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
codespell

AUTHORS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Credits
2+
3+
4+
## Development Lead
5+
6+
* Dalwar Hossain <dalwar23@pm.me>
7+
8+
## Contributors
9+
10+
None yet. Why not be the first?

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2024-Present, the respective contributors, as shown by the AUTHORS file.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
7+
following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
10+
disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
16+
products derived from this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
19+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# tf-pre-commit
2+
3+
Python base simple terraform pre-commit hook.
4+
5+
## Python Version
6+
7+
Requires `python` version `3.9` or above.
8+
9+
## Table of Contents
10+
11+
- [Using tf-pre-commit with pre-commit](#using-tf-pre-commit-with-pre-commit)
12+
- [Development](#development)
13+
- [License](#license)
14+
15+
## Using `tf-pre-commit` with `pre-commit`
16+
17+
Add the following `repo` to your `.pre-commit-config.yaml`
18+
19+
```yaml
20+
...
21+
- repo: https://github.com/devopsforhuman/tf-pre-commit
22+
rev: v1.0.0
23+
hooks:
24+
id: terraform-fmt
25+
...
26+
```
27+
if you want to provide `options` or `global options` (try `terraform fmt --help`) then use `args`
28+
29+
```yaml
30+
...
31+
- repo: https://github.com/devopsforhuman/tf-pre-commit
32+
rev: v1.0.0
33+
hooks:
34+
id: terraform-fmt
35+
args:
36+
- --option="-no-color -diff -check"
37+
...
38+
```
39+
40+
> **Note**
41+
> If `-recursive` is provided in the `--options` argument, terraform formatting will recursively format the parent
42+
> directory of the file in context.
43+
44+
## Development
45+
46+
- Create virtual environment
47+
48+
```shell
49+
python3 -m venv .venv
50+
```
51+
52+
- Activate virtual environment
53+
54+
```shell
55+
source .venv/bin/activate
56+
```
57+
58+
or for windows
59+
60+
```shell
61+
.\.venv\Scripts\activate.ps1
62+
```
63+
64+
- Install dependencies
65+
66+
To install dependencies with `pipenv` use the following command
67+
68+
```shell
69+
python3 -m pip install -r requirements.txt
70+
```
71+
72+
To install `dev` dependencies use `--dev` flag
73+
74+
```shell
75+
python3 -m pip install -r requirements_dev.txt
76+
```
77+
78+
## License
79+
80+
`tf-pre-commit` is distributed under the terms of the [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html) license.

0 commit comments

Comments
 (0)