diff --git a/README.md b/README.md index c8216c20e..a185e86bd 100644 --- a/README.md +++ b/README.md @@ -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. | +| [opentofu](https://github.com/opentofu/opentofu) | OpenTofu lets you declaratively manage your cloud infrastructure. | | [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. | diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go index 0ef25b569..bd69e8dab 100644 --- a/pkg/get/get_test.go +++ b/pkg/get/get_test.go @@ -4278,6 +4278,60 @@ func Test_DownloadTerraformDocs(t *testing.T) { } } +func Test_DownloadOpentofu(t *testing.T) { + tools := MakeTools() + name := "tofu" + version := "v1.6.2" + + tool := getTool(name, tools) + + tests := []test{ + { + os: "darwin", + arch: arch64bit, + version: version, + url: `https://github.com/opentofu/opentofu/releases/download/v1.6.2/tofu_1.6.2_darwin_amd64.zip`, + }, + { + os: "darwin", + arch: archDarwinARM64, + version: version, + url: `https://github.com/opentofu/opentofu/releases/download/v1.6.2/tofu_1.6.2_darwin_arm64.zip`, + }, + { + os: "linux", + arch: arch64bit, + version: version, + url: `https://github.com/opentofu/opentofu/releases/download/v1.6.2/tofu_1.6.2_linux_amd64.zip`, + }, + { + os: "linux", + arch: archARM64, + version: version, + url: `https://github.com/opentofu/opentofu/releases/download/v1.6.2/tofu_1.6.2_linux_arm64.zip`, + }, + { + os: "ming", + arch: arch64bit, + version: version, + url: `https://github.com/opentofu/opentofu/releases/download/v1.6.2/tofu_1.6.2_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_DownloadTerragrunt(t *testing.T) { tools := MakeTools() name := "terragrunt" diff --git a/pkg/get/tools.go b/pkg/get/tools.go index 941666e3b..4dcd37caf 100644 --- a/pkg/get/tools.go +++ b/pkg/get/tools.go @@ -906,6 +906,35 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}} {{.Version}}/{{.Name}}_{{$osStr}}_{{$archStr}}{{$extStr}}`, }) + tools = append(tools, + Tool{ + Owner: "opentofu", + Repo: "opentofu", + Name: "tofu", + Version: "v1.6.2", + Description: "OpenTofu lets you declaratively manage your cloud infrastructure", + BinaryTemplate: ` + {{$extStr := ".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 -}} + + {{.Version}}/{{.Name}}_{{.VersionNumber}}_{{$osStr}}_{{$archStr}}{{$extStr}}`, + }) + tools = append(tools, Tool{ Owner: "hashicorp",