Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DENA-969: Split tflint configs between MSK and team clusters #573

Merged
merged 6 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ repos:
hooks:
- id: terraform_fmt
- id: terraform_tflint
name: Validate with tflint the uw hosted team configs
args:
- --args=--config=__GIT_WORKING_DIR__/.tflint.hcl
- --args=--config=__GIT_WORKING_DIR__/.tflint-uw-team-hosted.hcl
# use compact, so that errors will be reported by the GH action see https://github.com/terraform-linters/setup-tflint?tab=readme-ov-file#checks
- --args=--format=compact
# Using this allows issues to appear directly in the PR code. See https://github.com/antonbabenko/pre-commit-terraform?tab=readme-ov-file#terraform_tflint
- --hook-config=--delegate-chdir
exclude: "^.*/kafka-shared-msk/.*$"
- id: terraform_tflint
name: Validate with tflint the MSK team configs
args:
- --args=--config=__GIT_WORKING_DIR__/.tflint-msk.hcl
# use compact, so that errors will be reported by the GH action see https://github.com/terraform-linters/setup-tflint?tab=readme-ov-file#checks
- --args=--format=compact
# We won't be able to use --hook-config=--delegate-chdir, as we need to determine the current folder in our plugin tflint-ruleset-kafka-config.
files: "^.*/kafka-shared-msk/.+/.*$"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep things simple, we could probably just match the start of the path (or is there a reason we enforce the depth with the /.+/. bit?)

Suggested change
files: "^.*/kafka-shared-msk/.+/.*$"
files: "^.*/kafka-shared-msk/"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, as we don't wanna run it on the folder dev-asw/kafka-shared-msk/ as it doesn't contain any module. Only on its subfolders

- id: terraform_validate
args:
# for local cached .terraform folders. Explanations in https://github.com/antonbabenko/pre-commit-terraform?tab=readme-ov-file#terraform_validate
Expand Down
4 changes: 3 additions & 1 deletion .tflint.hcl → .tflint-msk.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# tflint configuration file that applies to all MSK team modules

plugin "terraform" {
enabled = true
preset = "all"
Expand All @@ -10,5 +12,5 @@ rule "terraform_standard_module_structure" {

# Include module calls
config {
module = true
call_module_type = "all"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -13 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to require tflint v0.50.0+ https://github.com/terraform-linters/tflint/releases/tag/v0.50.0 but I don't think we version this at all (it needs to be installed independently from pre-commit, maybe worth noting somewhere that we only support running the latest version of tflint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We mention installing it here: https://github.com/utilitywarehouse/kafka-cluster-config/blob/main/CONTRIBUTING.md. Maybe worth moving it directly to readme, as it might be missed

}
16 changes: 16 additions & 0 deletions .tflint-uw-team-hosted.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# tflint configuration file that applies to all UW hosted team cluster modules

plugin "terraform" {
enabled = true
preset = "all"
}

# I think it's too late for this and wouldn't make sense for our modules
rule "terraform_standard_module_structure" {
enabled = false
}

# Include module calls
config {
call_module_type = "all"
}
Loading