Skip to content

Commit

Permalink
style(lint): added linting support
Browse files Browse the repository at this point in the history
  • Loading branch information
dharsanb committed Jan 10, 2024
1 parent db556fd commit 7f4f3e5
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ jobs:

- name: Terraform Validate
run: make validate

- uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.49.0

- name: Lint
run: make lint
4 changes: 4 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugin "terraform" {
enabled = true
preset = "recommended"
}
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
TF_DIRS = $(patsubst %/main.tf, %, $(shell find . -type d -name .terraform -prune -o -name 'main.tf' -print))
VALIDATE_TF_DIRS = $(addprefix validate-,$(TF_DIRS))
LINT_TF_DIRS = $(addprefix lint-,$(TF_DIRS))
DOCS_TF_DIRS = $(addprefix docs-,$(TF_DIRS))

# Generate docs for a terraform directories
Expand Down Expand Up @@ -30,3 +31,16 @@ $(VALIDATE_TF_DIRS): validate-%:
# Validate all terraform directories
validate: $(VALIDATE_TF_DIRS)
@echo "All validated"

# Lint a terraform directories
$(LINT_TF_DIRS): lint-%:
@echo "Lint $*"
tflint --config "$(PWD)/.tflint.hcl" --chdir="$*"

# Initialize tflint
lint-init:
tflint --init

# Lint all terraform directories
lint: lint-init $(LINT_TF_DIRS)
@echo "All linted"
7 changes: 6 additions & 1 deletion examples/postgres/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Modules

Expand Down
4 changes: 3 additions & 1 deletion examples/postgres/providers.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}
required_version = ">= 1.3.0"
}


Expand Down
7 changes: 6 additions & 1 deletion examples/redis/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Modules

Expand Down
4 changes: 3 additions & 1 deletion examples/redis/providers.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}
required_version = ">= 1.3.0"
}


Expand Down
9 changes: 7 additions & 2 deletions humanitec-resource-defs/mysql/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Resources

Expand All @@ -17,7 +22,7 @@

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| prefix | n/a | `string` | `""` | no |
| prefix | Prefix for all resources | `string` | n/a | yes |

## Outputs

Expand Down
4 changes: 3 additions & 1 deletion humanitec-resource-defs/mysql/basic/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}
required_version = ">= 1.3.0"
}
2 changes: 2 additions & 0 deletions humanitec-resource-defs/mysql/basic/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

# Prefix for all resources
prefix = ""
3 changes: 2 additions & 1 deletion humanitec-resource-defs/mysql/basic/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
variable "prefix" {
default = ""
description = "Prefix for all resources"
type = string
}
9 changes: 7 additions & 2 deletions humanitec-resource-defs/postgres/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Resources

Expand All @@ -17,7 +22,7 @@

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| prefix | n/a | `string` | `""` | no |
| prefix | Prefix for all resources | `string` | n/a | yes |

## Outputs

Expand Down
4 changes: 3 additions & 1 deletion humanitec-resource-defs/postgres/basic/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}
required_version = ">= 1.3.0"
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

# Prefix for all resources
prefix = ""
3 changes: 2 additions & 1 deletion humanitec-resource-defs/postgres/basic/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
variable "prefix" {
default = ""
description = "Prefix for all resources"
type = string
}
9 changes: 7 additions & 2 deletions humanitec-resource-defs/redis/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Resources

Expand All @@ -17,7 +22,7 @@

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| prefix | n/a | `string` | `""` | no |
| prefix | Prefix for all resources | `string` | n/a | yes |

## Outputs

Expand Down
4 changes: 3 additions & 1 deletion humanitec-resource-defs/redis/basic/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}
required_version = ">= 1.3.0"
}
2 changes: 2 additions & 0 deletions humanitec-resource-defs/redis/basic/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

# Prefix for all resources
prefix = ""
3 changes: 2 additions & 1 deletion humanitec-resource-defs/redis/basic/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
variable "prefix" {
default = ""
description = "Prefix for all resources"
type = string
}

0 comments on commit 7f4f3e5

Please sign in to comment.