From 75b1a8897f4d5bff4ac48afc89d66566da87a3c2 Mon Sep 17 00:00:00 2001 From: Christof Bruyland Date: Sun, 14 Jan 2024 09:18:51 +0100 Subject: [PATCH] Add tflint Signed-off-by: Christof Bruyland --- README.md | 1 + pkg/get/get_test.go | 53 +++++++++++++++++++++++++++++++++++++++++++++ pkg/get/tools.go | 29 +++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/README.md b/README.md index e8299bcc0..aefb47e08 100644 --- a/README.md +++ b/README.md @@ -894,6 +894,7 @@ There are 56 apps that you can install on your cluster. | [terraform](https://github.com/hashicorp/terraform) | Infrastructure as Code for major cloud providers. | | [terragrunt](https://github.com/gruntwork-io/terragrunt) | Terragrunt is a thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules | | [terrascan](https://github.com/tenable/terrascan) | Detect compliance and security violations across Infrastructure as Code. | +| [tflint](https://github.com/terraform-linters/tflint) | A Pluggable Terraform Linter. | | [tfsec](https://github.com/aquasecurity/tfsec) | Security scanner for your Terraform code | | [tilt](https://github.com/tilt-dev/tilt) | A multi-service dev environment for teams on Kubernetes. | | [timoni](https://github.com/stefanprodan/timoni) | A package manager for Kubernetes powered by CUE. | diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go index 37dd67916..3d69abcdc 100644 --- a/pkg/get/get_test.go +++ b/pkg/get/get_test.go @@ -3175,6 +3175,59 @@ func Test_DownloadRekorCli(t *testing.T) { } +func Test_DownloadTflint(t *testing.T) { + tools := MakeTools() + name := "tflint" + version := "v0.50.1" + + tool := getTool(name, tools) + + tests := []test{ + { + os: "darwin", + arch: arch64bit, + version: version, + url: `https://github.com/terraform-linters/tflint/releases/download/v0.50.1/tflint_darwin_amd64.zip`, + }, + { + os: "darwin", + arch: archDarwinARM64, + version: version, + url: `https://github.com/terraform-linters/tflint/releases/download/v0.50.1/tflint_darwin_arm64.zip`, + }, + { + os: "linux", + arch: arch64bit, + version: version, + url: `https://github.com/terraform-linters/tflint/releases/download/v0.50.1/tflint_linux_amd64.zip`, + }, + { + os: "linux", + arch: archARM64, + version: version, + url: `https://github.com/terraform-linters/tflint/releases/download/v0.50.1/tflint_linux_arm64.zip`, + }, + { + os: "ming", + arch: arch64bit, + version: version, + url: `https://github.com/terraform-linters/tflint/releases/download/v0.50.1/tflint_windows_amd64.zip`, + }, + } + + for _, tc := range tests { + t.Run(tc.os+" "+tc.arch+" "+tc.version, func(r *testing.T) { + got, err := tool.GetURL(tc.os, tc.arch, tc.version, false) + if err != nil { + t.Fatal(err) + } + if got != tc.url { + t.Errorf("want: %s, got: %s", tc.url, got) + } + }) + } +} + func Test_DownloadTFSecCli(t *testing.T) { tools := MakeTools() name := "tfsec" diff --git a/pkg/get/tools.go b/pkg/get/tools.go index c28aacb59..7cda094e7 100644 --- a/pkg/get/tools.go +++ b/pkg/get/tools.go @@ -2054,6 +2054,35 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Repo}} }, ) + tools = append(tools, + Tool{ + Owner: "terraform-linters", + Repo: "tflint", + Name: "tflint", + Description: "A Pluggable Terraform Linter.", + BinaryTemplate: ` + {{ $ext := ".zip" }} + + {{$osStr := ""}} + {{ if HasPrefix .OS "ming" -}} + {{$osStr = "windows"}} + {{- else if eq .OS "linux" -}} + {{$osStr = "linux"}} + {{- else if eq .OS "darwin" -}} + {{$osStr = "darwin"}} + {{- end -}} + + {{$archStr := .Arch}} + {{- if eq .Arch "x86_64" -}} + {{$archStr = "amd64"}} + {{- else if eq .Arch "aarch64" -}} + {{$archStr = "arm64"}} + {{- end -}} + + {{.Name}}_{{$osStr}}_{{$archStr}}{{$ext}}`, + }, + ) + tools = append(tools, Tool{ Owner: "aquasecurity",