Skip to content

Commit

Permalink
Add terraform-docs
Browse files Browse the repository at this point in the history
Signed-off-by: Christof Bruyland <[email protected]>
  • Loading branch information
cyberox authored and alexellis committed Mar 5, 2024
1 parent d2168bd commit 7aefb13
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ There are 56 apps that you can install on your cluster.
| [task](https://github.com/go-task/task) | A simple task runner and build tool |
| [tctl](https://github.com/temporalio/tctl) | Temporal CLI. |
| [terraform](https://github.com/hashicorp/terraform) | Infrastructure as Code for major cloud providers. |
| [terraform-docs](https://github.com/terraform-docs/terraform-docs) | Generate documentation from Terraform modules in various output formats. |
| [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. |
Expand Down
59 changes: 59 additions & 0 deletions pkg/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4219,6 +4219,65 @@ func Test_DownloadCilium(t *testing.T) {
}
}

func Test_DownloadTerraformDocs(t *testing.T) {
tools := MakeTools()
name := "terraform-docs"
version := "v0.17.0"

tool := getTool(name, tools)

tests := []test{
{
os: "darwin",
arch: arch64bit,
version: version,
url: `https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-darwin-amd64.tar.gz`,
},
{
os: "darwin",
arch: archDarwinARM64,
version: version,
url: `https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-darwin-arm64.tar.gz`,
},
{
os: "linux",
arch: arch64bit,
version: version,
url: `https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-linux-amd64.tar.gz`,
},
{
os: "linux",
arch: archARM64,
version: version,
url: `https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-linux-arm64.tar.gz`,
},
{
os: "ming",
arch: arch64bit,
version: version,
url: `https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-windows-amd64.zip`,
},
{
os: "ming",
arch: archARM64,
version: version,
url: `https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-windows-arm64.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_DownloadTerragrunt(t *testing.T) {
tools := MakeTools()
name := "terragrunt"
Expand Down
31 changes: 31 additions & 0 deletions pkg/get/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,37 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}}
https://releases.hashicorp.com/{{.Name}}/{{.Version}}/{{.Name}}_{{.Version}}_{{$os}}_{{$arch}}.zip`,
})

tools = append(tools,
Tool{
Owner: "terraform-docs",
Repo: "terraform-docs",
Name: "terraform-docs",
Description: "Generate documentation from Terraform modules in various output formats.",
BinaryTemplate: `
{{$extStr := ".tar.gz"}}
{{ if HasPrefix .OS "ming" -}}
{{$extStr = ".zip"}}
{{- end -}}
{{$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 -}}
{{.Version}}/{{.Name}}-{{.Version}}-{{$osStr}}-{{$archStr}}{{$extStr}}`,
})

tools = append(tools,
Tool{
Owner: "gruntwork-io",
Expand Down

0 comments on commit 7aefb13

Please sign in to comment.