Skip to content

Commit 68bef96

Browse files
committed
Use amp to add amp
Thanks to @sqs for sending over some credits to try out amp. With some gentle guidance, it was able to produce a great PR to add amp to arkade very quickly. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent dd08cc5 commit 68bef96

File tree

5 files changed

+148
-3
lines changed

5 files changed

+148
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ With `arkade get`, you'll have `kubectl`, `kind`, `terraform`, and `jq` on your
1212
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
1313
![Downloads](https://img.shields.io/github/downloads/alexellis/arkade/total)
1414

15-
With over 120 CLIs and 55 Kubernetes apps (charts, manifests, installers) available for Kubernetes, gone are the days of contending with dozens of README files just to set up a development stack with the usual suspects like ingress-nginx, Postgres, and cert-manager.
15+
With over 185 CLIs and 55 Kubernetes apps (charts, manifests, installers) available for Kubernetes, gone are the days of contending with dozens of README files just to set up a development stack with the usual suspects like ingress-nginx, Postgres, and cert-manager.
1616

1717
- [arkade - Open Source Marketplace For Developer Tools](#arkade---open-source-marketplace-for-developer-tools)
1818
- [Support arkade 👋](#support-arkade-)
@@ -767,6 +767,7 @@ There are 53 apps that you can install on your cluster.
767767
| [age](https://github.com/FiloSottile/age) | A simple, modern, and secure file encryption tool. |
768768
| [age-keygen](https://github.com/FiloSottile/age) | Key generation tool for age encryption. |
769769
| [alloy](https://github.com/grafana/alloy) | OpenTelemetry Collector distribution with programmable pipelines |
770+
| [amp](https://github.com/sourcegraph/amp) | Amp - the frontier coding agent for your terminal and editor. |
770771
| [argocd](https://github.com/argoproj/argo-cd) | Declarative, GitOps continuous delivery tool for Kubernetes. |
771772
| [argocd-autopilot](https://github.com/argoproj-labs/argocd-autopilot) | An opinionated way of installing Argo-CD and managing GitOps repositories. |
772773
| [arkade](https://github.com/alexellis/arkade) | Portable marketplace for downloading your favourite DevOps CLIs and installing helm charts, with a single command. |
@@ -948,6 +949,6 @@ There are 53 apps that you can install on your cluster.
948949
| [waypoint](https://github.com/hashicorp/waypoint) | Easy application deployment for Kubernetes and Amazon ECS |
949950
| [yq](https://github.com/mikefarah/yq) | Portable command-line YAML processor. |
950951
| [yt-dlp](https://github.com/yt-dlp/yt-dlp) | Fork of youtube-dl with additional features and fixes |
951-
There are 186 tools, use `arkade get NAME` to download one.
952+
There are 187 tools, use `arkade get NAME` to download one.
952953

953954
> Note to contributors, run `go build && ./arkade get --format markdown` to generate this list

pkg/get/download.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,41 @@ func Download(tool *Tool, arch, operatingSystem, version string, movePath string
153153
return "", "", err
154154
}
155155

156+
verifyURL := strings.TrimSpace(buf.String())
157+
log.Printf("Downloading SHA sum from: %s", verifyURL)
158+
shaSum, err := fetchText(verifyURL)
159+
if err != nil {
160+
return "", "", err
161+
}
162+
if err := verifySHA(shaSum, outFilePath); err != nil {
163+
return "", "", err
164+
} else {
165+
log.Printf("SHA sum verified in %s.", time.Since(st).Round(time.Millisecond))
166+
}
167+
} else if tool.VerifyStrategy == AmpShasumStrategy {
168+
st := time.Now()
169+
tmpl := template.New(tool.Name + "sha")
170+
tmpl = tmpl.Funcs(templateFuncs)
171+
t, err := tmpl.Parse(tool.VerifyTemplate)
172+
if err != nil {
173+
return "", "", err
174+
}
175+
176+
var buf bytes.Buffer
177+
inputs := map[string]string{
178+
"Name": tool.Name,
179+
"Owner": tool.Owner,
180+
"Repo": tool.Repo,
181+
"Version": resolvedVersion,
182+
"VersionNumber": strings.TrimPrefix(resolvedVersion, "v"),
183+
"Arch": arch,
184+
"OS": operatingSystem,
185+
}
186+
187+
if err = t.Execute(&buf, inputs); err != nil {
188+
return "", "", err
189+
}
190+
156191
verifyURL := strings.TrimSpace(buf.String())
157192
log.Printf("Downloading SHA sum from: %s", verifyURL)
158193
shaSum, err := fetchText(verifyURL)

pkg/get/get.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ const GitHubVersionStrategy = "github"
2121
const GitLabVersionStrategy = "gitlab"
2222
const k8sVersionStrategy = "k8s"
2323
const ClaudeStrategy = `claude`
24+
const AmpStrategy = `amp`
2425

2526
const HashicorpShasumStrategy = `hashicorp-sha`
2627
const ClaudeShasumStrategy = `claude-sha`
28+
const AmpShasumStrategy = `amp-sha`
2729

2830
var supportedOS = [...]string{"linux", "darwin", "ming"}
2931
var supportedArchitectures = [...]string{"x86_64", "arm", "amd64", "armv6l", "armv7l", "arm64", "aarch64"}
@@ -99,6 +101,11 @@ var releaseLocations = map[string]ReleaseLocation{
99101
Timeout: time.Second * 5,
100102
Method: http.MethodGet,
101103
},
104+
AmpStrategy: {
105+
Url: "https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt",
106+
Timeout: time.Second * 5,
107+
Method: http.MethodGet,
108+
},
102109
}
103110

104111
type ToolLocal struct {
@@ -307,7 +314,7 @@ func FindRelease(location, owner, repo string) (string, error) {
307314
return "", err
308315
}
309316

310-
version := string(bodyBytes)
317+
version := strings.TrimSpace(string(bodyBytes))
311318
return version, nil
312319
}
313320

pkg/get/get_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9292,6 +9292,58 @@ func Test_DownloadClaude(t *testing.T) {
92929292
}
92939293
}
92949294

9295+
func Test_DownloadAmp(t *testing.T) {
9296+
tools := MakeTools()
9297+
name := "amp"
9298+
9299+
tool := getTool(name, tools)
9300+
9301+
const toolVersion = "0.0.1769091939-g843744"
9302+
9303+
tests := []test{
9304+
{
9305+
os: "darwin",
9306+
arch: arch64bit,
9307+
version: toolVersion,
9308+
url: "https://storage.googleapis.com/amp-public-assets-prod-0/cli/0.0.1769091939-g843744/amp-darwin-x64",
9309+
},
9310+
{
9311+
os: "darwin",
9312+
arch: archDarwinARM64,
9313+
version: toolVersion,
9314+
url: "https://storage.googleapis.com/amp-public-assets-prod-0/cli/0.0.1769091939-g843744/amp-darwin-arm64",
9315+
},
9316+
{
9317+
os: "linux",
9318+
arch: arch64bit,
9319+
version: toolVersion,
9320+
url: "https://storage.googleapis.com/amp-public-assets-prod-0/cli/0.0.1769091939-g843744/amp-linux-x64",
9321+
},
9322+
{
9323+
os: "linux",
9324+
arch: archARM64,
9325+
version: toolVersion,
9326+
url: "https://storage.googleapis.com/amp-public-assets-prod-0/cli/0.0.1769091939-g843744/amp-linux-arm64",
9327+
},
9328+
{
9329+
os: "mingw64_nt-10.0-18362",
9330+
arch: arch64bit,
9331+
version: toolVersion,
9332+
url: "https://storage.googleapis.com/amp-public-assets-prod-0/cli/0.0.1769091939-g843744/amp-windows-x64.exe",
9333+
},
9334+
}
9335+
9336+
for _, tc := range tests {
9337+
got, _, err := tool.GetURL(tc.os, tc.arch, tc.version, false)
9338+
if err != nil {
9339+
t.Fatal(err)
9340+
}
9341+
if got != tc.url {
9342+
t.Errorf("\nwant: %s\ngot: %s", tc.url, got)
9343+
}
9344+
}
9345+
}
9346+
92959347
func Test_LogCLI(t *testing.T) {
92969348
tools := MakeTools()
92979349
name := "logcli"

pkg/get/tools.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,56 @@ func MakeTools() Tools {
9898
{{- end -}}
9999
100100
https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/{{.Version}}/{{$os}}-{{$arch}}/claude
101+
`})
102+
103+
// Amp CLI
104+
tools = append(tools,
105+
Tool{
106+
Owner: "sourcegraph",
107+
Repo: "amp",
108+
Name: "amp",
109+
Description: "Amp - the frontier coding agent for your terminal and editor.",
110+
VerifyStrategy: AmpShasumStrategy,
111+
VersionStrategy: AmpStrategy,
112+
VerifyTemplate: `{{$os := .OS}}
113+
{{$arch := .Arch}}
114+
115+
{{ if or (eq .Arch "x86_64") (eq .Arch "amd64") -}}
116+
{{ $arch = "x64" }}
117+
{{- else if or (eq .Arch "arm64") (eq .Arch "aarch64") -}}
118+
{{ $arch = "arm64" }}
119+
{{- end}}
120+
121+
{{ if HasPrefix .OS "ming" -}}
122+
{{ $os = "windows" }}
123+
{{- else if eq .OS "darwin" -}}
124+
{{ $os = "darwin" }}
125+
{{- else -}}
126+
{{ $os = "linux" }}
127+
{{- end -}}
128+
129+
https://storage.googleapis.com/amp-public-assets-prod-0/cli/{{.Version}}/{{$os}}-{{$arch}}-amp.sha256`,
130+
URLTemplate: `
131+
{{$os := .OS}}
132+
{{$arch := .Arch}}
133+
{{$ext := ""}}
134+
135+
{{ if or (eq .Arch "x86_64") (eq .Arch "amd64") -}}
136+
{{ $arch = "x64" }}
137+
{{- else if or (eq .Arch "arm64") (eq .Arch "aarch64") -}}
138+
{{ $arch = "arm64" }}
139+
{{- end}}
140+
141+
{{ if HasPrefix .OS "ming" -}}
142+
{{ $os = "windows" }}
143+
{{ $ext = ".exe" }}
144+
{{- else if eq .OS "darwin" -}}
145+
{{ $os = "darwin" }}
146+
{{- else -}}
147+
{{ $os = "linux" }}
148+
{{- end -}}
149+
150+
https://storage.googleapis.com/amp-public-assets-prod-0/cli/{{.Version}}/amp-{{$os}}-{{$arch}}{{$ext}}
101151
`})
102152

103153
tools = append(tools,

0 commit comments

Comments
 (0)