chore(lint): add pre-commit hook

This commit is contained in:
Bertrand Lanson 2024-02-25 12:46:45 +01:00
parent 0e258537f2
commit 5f62dde30d
6 changed files with 66 additions and 7 deletions

5
.gitignore vendored
View File

@ -11,8 +11,8 @@ crash.log
crash.*.log
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json
@ -33,4 +33,3 @@ override.tf.json
# Ignore CLI configuration files
.terraformrc
terraform.rc

20
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,20 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.86.0
hooks:
- id: terraform_fmt
- id: terraform_docs
args:
- "--hook-config=--path-to-file=README.md"
- "--hook-config=--add-to-existing-file=true"
- "--hook-config=--create-file-if-not-exist=true"
- "--args=--escape=false"
- "--args=--lockfile=false"
- "--args=--indent 3"
- "--args=--show all"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

View File

@ -17,4 +17,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -41,4 +41,44 @@ No modules.
## Outputs
No outputs.
<!-- END_TF_DOCS -->
<!-- END_TF_DOCS --><!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
### Requirements
No requirements.
### Providers
| Name | Version |
|------|---------|
| <a name="provider_consul"></a> [consul](#provider_consul) | n/a |
| <a name="provider_nomad"></a> [nomad](#provider_nomad) | n/a |
### Modules
No modules.
### Resources
| Name | Type |
|------|------|
| [consul_intention.this](https://registry.terraform.io/providers/hashicorp/consul/latest/docs/resources/intention) | resource |
| [consul_key_prefix.this](https://registry.terraform.io/providers/hashicorp/consul/latest/docs/resources/key_prefix) | resource |
| [nomad_csi_volume.this](https://registry.terraform.io/providers/hashicorp/nomad/latest/docs/resources/csi_volume) | resource |
| [nomad_csi_volume_registration.this](https://registry.terraform.io/providers/hashicorp/nomad/latest/docs/resources/csi_volume_registration) | resource |
| [nomad_job.this](https://registry.terraform.io/providers/hashicorp/nomad/latest/docs/resources/job) | resource |
### Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_consul_intentions"></a> [consul_intentions](#input_consul_intentions) | List of intentions associated with the job(s) | <pre>map(object({<br> source_name = string<br> destination_name = string<br> action = string<br> }))</pre> | `{}` | no |
| <a name="input_consul_kv"></a> [consul_kv](#input_consul_kv) | List key/value pairs to put at a specific prefix (mainly for traefik) | `map(any)` | `{}` | no |
| <a name="input_jobs"></a> [jobs](#input_jobs) | The list of jobs to deploy | `map(string)` | `{}` | no |
| <a name="input_jobs_variables"></a> [jobs_variables](#input_jobs_variables) | Map of object to pass variables to the nomad job(s). Key is the job's name, value is a map of variables and their values | `map(map(string))` | `{}` | no |
| <a name="input_nfs_volumes"></a> [nfs_volumes](#input_nfs_volumes) | List of nfs volumes associated to the job(s) | <pre>map(object({<br> plugin_id = string<br> namespace = string<br> capability = map(string)<br> context = map(string)<br> mount_options = object({<br> fs_type = string<br> mount_flags = list(string)<br> })<br> }))</pre> | `{}` | no |
| <a name="input_volumes"></a> [volumes](#input_volumes) | List of volumes associated to the job(s) | <pre>map(object({<br> plugin_id = string<br> namespace = string<br> capacity_min = string<br> capacity_max = string<br> capability = map(string)<br> parameters = map(string)<br> secrets = map(string)<br> }))</pre> | `{}` | no |
### Outputs
No outputs.
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

View File

@ -65,4 +65,4 @@ resource "consul_intention" "this" {
source_name = each.value.source_name
destination_name = each.value.destination_name
action = each.value.action
}
}

View File

@ -54,4 +54,4 @@ variable "consul_intentions" {
}))
description = "List of intentions associated with the job(s)"
default = {}
}
}