Skip to content

Commit

Permalink
fix: Add tflint ignores (#32)
Browse files Browse the repository at this point in the history
- Reduce tflint errors by adding ingores in fogg generated files
- update golden test files
  • Loading branch information
vincenthsh authored Nov 18, 2022
1 parent e632e75 commit 8c9e885
Show file tree
Hide file tree
Showing 70 changed files with 455 additions and 13 deletions.
10 changes: 10 additions & 0 deletions templates/templates/component/terraform/fogg.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,27 @@ terraform {
{{ end}}
}
}
# tflint-ignore: terraform_unused_declarations
variable "env" {
type = string
default = "{{ .Env }}"
}

# tflint-ignore: terraform_unused_declarations
variable "project" {
type = string
default = "{{ .Project }}"
}

# tflint-ignore: terraform_unused_declarations
{{if .ProviderConfiguration.AWS}}
variable "region" {
type = string
default = "{{ .ProviderConfiguration.AWS.Region }}"
}
{{ end }}

# tflint-ignore: terraform_unused_declarations
variable "component" {
type = string
default = "{{ .Name }}"
Expand All @@ -107,11 +111,13 @@ variable "account" {
}
{{ end }}{{ end }}

# tflint-ignore: terraform_unused_declarations
variable "owner" {
type = string
default = "{{ .Owner }}"
}

# tflint-ignore: terraform_unused_declarations
variable "tags" {
type = object({project: string, env: string, service: string, owner: string, managedBy: string})
default = {
Expand All @@ -132,6 +138,7 @@ variable "{{ $key }}" {

{{ if .Global}}
{{ if .Global.Backend.Kind}}
# tflint-ignore: terraform_unused_declarations
data "terraform_remote_state" "global" {
backend = "{{ .Global.Backend.Kind }}"

Expand All @@ -143,6 +150,7 @@ data "terraform_remote_state" "global" {
{{ $outer := . }}
{{ range $component, $backend := .ComponentBackends }}
{{ if ne $component $outer.Name }}
# tflint-ignore: terraform_unused_declarations
data "terraform_remote_state" "{{ $component }}" {
backend = "{{ $backend.Kind }}"

Expand All @@ -154,6 +162,7 @@ data "terraform_remote_state" "{{ $component }}" {
{{ end }}

{{ range $name, $backend := .AccountBackends }}
# tflint-ignore: terraform_unused_declarations
data "terraform_remote_state" "{{ $name }}" {
backend = "{{ $backend.Kind }}"

Expand All @@ -163,6 +172,7 @@ data "terraform_remote_state" "{{ $name }}" {
}
{{ end }}

# tflint-ignore: terraform_unused_declarations
variable "aws_accounts" {
type = map(string)
default = {
Expand Down
3 changes: 3 additions & 0 deletions testdata/auth0_provider_yaml/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testdata/auth0_provider_yaml/scripts/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lint: lint-terraform-fmt lint-tflint ## run all linters for this component
lint-tflint: ## run the tflint linter for this component
@printf "tflint: "
ifeq ($(TFLINT_ENABLED),1)
@tflint || exit $$?;
@tflint -c $(REPO_ROOT)/.tflint.hcl || exit $$?;
else
@echo "disabled"
endif
Expand Down
9 changes: 9 additions & 0 deletions testdata/auth0_provider_yaml/terraform/accounts/foo/fogg.tf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions testdata/auth0_provider_yaml/terraform/envs/bar/bam/fogg.tf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions testdata/auth0_provider_yaml/terraform/global/fogg.tf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions testdata/bless_provider_yaml/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testdata/bless_provider_yaml/scripts/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lint: lint-terraform-fmt lint-tflint ## run all linters for this component
lint-tflint: ## run the tflint linter for this component
@printf "tflint: "
ifeq ($(TFLINT_ENABLED),1)
@tflint || exit $$?;
@tflint -c $(REPO_ROOT)/.tflint.hcl || exit $$?;
else
@echo "disabled"
endif
Expand Down
9 changes: 9 additions & 0 deletions testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8c9e885

Please sign in to comment.