Repository: alexellis/arkade (Go)

Issue:
Add Grafana Alloy to arkade get
<!--- Provide a general summary of the issue in the Title above -->
Grafana Alloy is an open source OpenTelemetry collector with built-in Prometheus pipelines and support for metrics, logs, traces, and profiles.
https://github.com/grafana/alloy


## Expected Behaviour
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->

`arkade get alloy` installs Grafana Alloy.

## Current Behaviour
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->

Not implemented.

## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->

Add Grafana Alloy as an installable cli tool.

## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context

<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- What would happen if this issue was not resolved for you in some way? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

Grafana Alloy is the successor of Grafana Agent.

## If requesting a CLI for "arkade get"

How many downloads does this tool have? Check at:

72,867
https://somsubhra.github.io/github-release-stats/?username=grafana&repository=alloy&page=1&per_page=5

If approved, are you willing to submit a pull request for this?

## Your Environment

* What Kubernetes distribution are you using?

```
kubectl version
```

* Operating System and version (e.g. Linux, Windows, MacOS):

```
uname -a

cat /etc/os-release
```

* What arkade version is this?

```
arkade version
```



Discussion:
I _think_ this would fall under `arkade system install` rather than `arkade get`
I think we could eventually do both like with caddy. We can use `arkade get` if you just need to get the binary and the system install if you also want a systemd unit file to run it.


Oh, OK. I looked at https://grafana.com/docs/alloy/latest/set-up/install/ and only saw `systemd` as the way of running it.  I guess you're referencing https://grafana.com/docs/alloy/latest/reference/cli/ for the `arkade get` mode?
Thanks for the PR @rgee0 



Patch:
diff --git a/.gitignore b/.gitignore
index 32f64cf69..ae8fc4ac0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,4 @@ mc
 /arkade-*
 /faas-cli*
 test.out
-docker-compose.yaml
\ No newline at end of file
+docker-compose.yaml*
\ No newline at end of file
diff --git a/README.md b/README.md
index 72d3c851f..bbd741015 100644
--- a/README.md
+++ b/README.md
@@ -760,6 +760,7 @@ There are 52 apps that you can install on your cluster.
 |------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
 | [actions-usage](https://github.com/self-actuated/actions-usage)              | Get usage insights from GitHub Actions.                                                                                                                           |
 | [actuated-cli](https://github.com/self-actuated/actuated-cli)                | Official CLI for actuated.dev                                                                                                                                     |
+| [alloy](https://github.com/grafana/alloy)                                    | OpenTelemetry Collector distribution with programmable pipelines                                                                                                  |
 | [argocd](https://github.com/argoproj/argo-cd)                                | Declarative, GitOps continuous delivery tool for Kubernetes.                                                                                                      |
 | [argocd-autopilot](https://github.com/argoproj-labs/argocd-autopilot)        | An opinionated way of installing Argo-CD and managing GitOps repositories.                                                                                        |
 | [arkade](https://github.com/alexellis/arkade)                                | Portable marketplace for downloading your favourite DevOps CLIs and installing helm charts, with a single command.                                                |
@@ -920,6 +921,6 @@ There are 52 apps that you can install on your cluster.
 | [waypoint](https://github.com/hashicorp/waypoint)                            | Easy application deployment for Kubernetes and Amazon ECS                                                                                                         |
 | [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 162 tools, use `arkade get NAME` to download one.
+There are 163 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 b18490ec3..fc238a14e 100644
--- a/pkg/get/tools.go
+++ b/pkg/get/tools.go
@@ -4467,5 +4467,51 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Name}}
 							rclone-{{.Version}}-{{$os}}-{{$arch}}.{{$ext}}
 							`,
 		})
+
+	tools = append(tools,
+		Tool{
+			Owner:           "grafana",
+			Repo:            "alloy",
+			Name:            "alloy",
+			VersionStrategy: GitHubVersionStrategy,
+			Description:     "OpenTelemetry Collector distribution with programmable pipelines",
+			URLTemplate: `
+{{$fileName := ""}}
+{{- if eq .OS "linux" -}}
+	{{- if (or (eq .Arch "aarch64") (eq .Arch "arm64")) -}}
+	    {{$fileName = "alloy-linux-arm64.zip"}}
+	{{ else if eq .Arch "x86_64" -}}
+        {{$fileName = "alloy-linux-amd64.zip"}}
+    {{- end -}}
+{{- else if eq .OS "darwin" -}}
+	{{- if (or (eq .Arch "aarch64") (eq .Arch "arm64")) -}}
+	{{$fileName = "alloy-darwin-arm64.zip"}}
+	{{ else if eq .Arch "x86_64" -}}
+	{{$fileName = "alloy-darwin-amd64.zip"}}
+	{{- end -}}
+{{- else if HasPrefix .OS "ming" -}}
+    {{$fileName = "alloy-windows-amd64.exe.zip"}}
+{{- end -}}
+
+https://github.com/grafana/alloy/releases/download/{{.Version}}/{{$fileName}}`,
+
+			BinaryTemplate: `
+{{- if eq .OS "linux" -}}
+	{{- if eq .Arch "x86_64" -}}
+		{{.Name}}-linux-amd64
+	{{- else if (or (eq .Arch "aarch64") (eq .Arch "arm64")) -}}
+		{{.Name}}-linux-arm64
+		{{- end -}}
+{{- else if eq .OS "darwin" -}}
+	{{- if eq .Arch "x86_64" -}}
+		{{.Name}}-darwin-amd64
+	{{- else if (or (eq .Arch "aarch64") (eq .Arch "arm64")) -}}
+		{{.Name}}-darwin-arm64
+		{{- end -}}
+{{- else if HasPrefix .OS "ming" -}}
+	                                  {{.Name}}-windows-amd64
+									{{- end -}}
+								`,
+		})
 	return tools
 }


Test patch:
diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go
index c8ad7729c..4a6e87916 100644
--- a/pkg/get/get_test.go
+++ b/pkg/get/get_test.go
@@ -8237,3 +8237,53 @@ func Test_Download_rclone(t *testing.T) {
 		}
 	}
 }
+
+func Test_Download_alloy(t *testing.T) {
+	tools := MakeTools()
+	name := "alloy"
+	const toolVersion = "v1.4.3"
+
+	tool := getTool(name, tools)
+
+	tests := []test{
+		{
+			os:      "darwin",
+			arch:    arch64bit,
+			version: toolVersion,
+			url:     "https://github.com/grafana/alloy/releases/download/v1.4.3/alloy-darwin-amd64.zip",
+		},
+		{
+			os:      "darwin",
+			arch:    archDarwinARM64,
+			version: toolVersion,
+			url:     "https://github.com/grafana/alloy/releases/download/v1.4.3/alloy-darwin-arm64.zip",
+		},
+		{
+			os:      "linux",
+			arch:    arch64bit,
+			version: toolVersion,
+			url:     "https://github.com/grafana/alloy/releases/download/v1.4.3/alloy-linux-amd64.zip",
+		},
+		{
+			os:      "linux",
+			arch:    archARM64,
+			version: toolVersion,
+			url:     "https://github.com/grafana/alloy/releases/download/v1.4.3/alloy-linux-arm64.zip",
+		},
+		{
+			os:      "mingw64_nt-10.0-18362",
+			arch:    arch64bit,
+			version: toolVersion,
+			url:     "https://github.com/grafana/alloy/releases/download/v1.4.3/alloy-windows-amd64.exe.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)
+		}
+	}
+}