Repository: alexellis/arkade (Go)

Issue:
Add Red Hat OpenShift on AWS cli as a tool
<!--- Provide a general summary of the issue in the Title above -->

## Expected Behaviour
'arkade get rosa' installs the rosa cli tool without having to log into the portal, providing the correct binary for the target OS and arch

## Current Behaviour
- Register for a Red Hat account
- Sign into the portal
- Select binary from the drop down

## Possible Solution
- expand tools.go to include this tool

## Steps to Reproduce (for bugs)
- NA (Feature request)

- ## Context

Arkade simplifies my workflow and I enjoy promoting this project. This would be useful additional functionality.

## If requesting a CLI for "arkade get"

How many downloads does this tool have? Check at: 

1,150

If approved, are you willing to submit a pull request for this?

- Yes, have already made the changes in a fork :)

## Your Environment

OpenShift / GKE / EKS


```
* Kubernetes version

```
kubectl version --short
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.25.2
Kustomize Version: v4.5.7
Server Version: v1.26.5+7d22122
```


* What arkade version is this?

```
#arkade version


```
            _             _      
  __ _ _ __| | ____ _  __| | ___ 
 / _` | '__| |/ / _` |/ _` |/ _ \
| (_| | |  |   < (_| | (_| |  __/
 \__,_|_|  |_|\_\__,_|\__,_|\___|

Open Source Marketplace For Developer Tools

Version: 0.9.24-1-g225dc58
Git Commit: 225dc58ba12770e31177ae6ed59c5a6d0911121f

 🐳 arkade needs your support: https://github.com/sponsors/alexellis'
```



Discussion:

Patch:
diff --git a/README.md b/README.md
index 0c594040e..c7b0e9633 100644
--- a/README.md
+++ b/README.md
@@ -885,6 +885,7 @@ There are 52 apps that you can install on your cluster.
 | [regctl](https://github.com/regclient/regclient)                             | Utility for accessing docker registries                                                                                                                         |
 | [rekor-cli](https://github.com/sigstore/rekor)                               | Secure Supply Chain - Transparency Log                                                                                                                          |
 | [replicated](https://github.com/replicatedhq/replicated)                     | CLI for interacting with the Replicated Vendor API                                                                                                              |
+| [rosa](https://github.com/openshift/rosa)                                    | Red Hat OpenShift on AWS (ROSA) command line tool                                                                                                               |
 | [rpk](https://github.com/redpanda-data/redpanda)                             | Kafka compatible streaming platform for mission critical workloads.                                                                                             |
 | [run-job](https://github.com/alexellis/run-job)                              | Run a Kubernetes Job and get the logs when it's done.                                                                                                           |
 | [scaleway-cli](https://github.com/scaleway/scaleway-cli)                     | Scaleway CLI is a tool to help you pilot your Scaleway infrastructure directly from your terminal.                                                              |
@@ -917,6 +918,6 @@ There are 52 apps that you can install on your cluster.
 | [yq](https://github.com/mikefarah/yq)                                        | Portable command-line YAML processor.                                                                                                                           |
 | [yt-dlp](https://github.com/yt-dlp/yt-dlp)                                   | Fork of youtube-dl with additional features and fixes                                                                                                           |
 
-There are 158 tools, use `arkade get NAME` to download one.
+There are 159 tools, use `arkade get NAME` to download one.
 
 > Note to contributors, run `go build && ./arkade get --format markdown` to generate this list
\ No newline at end of file
diff --git a/pkg/get/tools.go b/pkg/get/tools.go
index 0cb22a857..ce255c10a 100644
--- a/pkg/get/tools.go
+++ b/pkg/get/tools.go
@@ -4353,5 +4353,34 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Name}}
 					
 					https://releases.crossplane.io/stable/{{.Version}}/bin/{{$os}}_{{$arch}}/crank{{$ext}}`,
 		})
+
+	tools = append(tools,
+		Tool{
+			Owner:           "openshift",
+			Repo:            "rosa",
+			Name:            "rosa",
+			VersionStrategy: GitHubVersionStrategy,
+			Description:     "Red Hat OpenShift on AWS (ROSA) command line tool",
+			BinaryTemplate: `
+							{{$os := .OS}}
+							{{$arch := .Arch}}
+							{{$ext := "tar.gz"}}
+				
+							{{- if eq .OS "darwin" -}}
+								{{$os = "Darwin"}}
+							{{- else if eq .OS "linux" -}}
+								{{$os = "Linux"}}
+							{{- else if HasPrefix .OS "ming" -}}
+								{{$os = "Windows"}}
+								{{$ext = "zip"}}
+							{{- end -}}
+		
+							{{- if (or (eq .Arch "aarch64") (eq .Arch "arm64")) -}}
+								{{$arch = "arm64"}}
+							{{- end -}}
+		
+						rosa_{{$os}}_{{$arch}}.{{$ext}}
+						`,
+		})
 	return tools
 }


Test patch:
diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go
index ddccee391..d86a7bbfe 100644
--- a/pkg/get/get_test.go
+++ b/pkg/get/get_test.go
@@ -8020,3 +8020,59 @@ func Test_Crossplane(t *testing.T) {
 	}
 
 }
+
+func Test_Download_rosa(t *testing.T) {
+	tools := MakeTools()
+	name := "rosa"
+	const toolVersion = "v1.2.46"
+
+	tool := getTool(name, tools)
+
+	tests := []test{
+		{
+			os:      "darwin",
+			arch:    arch64bit,
+			version: toolVersion,
+			url:     "https://github.com/openshift/rosa/releases/download/v1.2.46/rosa_Darwin_x86_64.tar.gz",
+		},
+		{
+			os:      "darwin",
+			arch:    archDarwinARM64,
+			version: toolVersion,
+			url:     "https://github.com/openshift/rosa/releases/download/v1.2.46/rosa_Darwin_arm64.tar.gz",
+		},
+		{
+			os:      "linux",
+			arch:    arch64bit,
+			version: toolVersion,
+			url:     "https://github.com/openshift/rosa/releases/download/v1.2.46/rosa_Linux_x86_64.tar.gz",
+		},
+		{
+			os:      "linux",
+			arch:    archARM64,
+			version: toolVersion,
+			url:     "https://github.com/openshift/rosa/releases/download/v1.2.46/rosa_Linux_arm64.tar.gz",
+		},
+		{
+			os:      "mingw64_nt-10.0-18362",
+			arch:    arch64bit,
+			version: toolVersion,
+			url:     "https://github.com/openshift/rosa/releases/download/v1.2.46/rosa_Windows_x86_64.zip",
+		},
+		{
+			os:      "mingw64_nt-10.0-18362",
+			arch:    archARM64,
+			version: toolVersion,
+			url:     "https://github.com/openshift/rosa/releases/download/v1.2.46/rosa_Windows_arm64.zip",
+		},
+	}
+	for _, tc := range tests {
+		got, err := tool.GetURL(tc.os, tc.arch, tc.version, false)
+		if err != nil {
+			t.Fatal(err)
+		}
+		if got != tc.url {
+			t.Fatalf("\nwant: %s\ngot:  %s", tc.url, got)
+		}
+	}
+}