From 3965bae3c73e4371752ca209fd9071ea6fe43838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cz=C3=A9kus=20M=C3=A1t=C3=A9?= Date: Fri, 2 Sep 2022 21:30:04 +0200 Subject: [PATCH] Add butane tool to arkade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Czékus Máté --- README.md | 3 ++- pkg/get/get_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++++ pkg/get/table.go | 2 +- pkg/get/tools.go | 26 +++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4f86f4e10..6d2b7df94 100644 --- a/README.md +++ b/README.md @@ -583,6 +583,7 @@ There are 56 apps that you can install on your cluster. | autok3s | Run Rancher Lab's lightweight Kubernetes distribution k3s everywhere. | | buildx | Docker CLI plugin for extended build capabilities with BuildKit. | | bun | Bun is an incredibly fast JavaScript runtime, bundler, transpiler and package manager – all in one. | +| butane | Translates human readable Butane Configs into machine readable Ignition Configs | | caddy | Caddy is an extensible server platform that uses TLS by default | | cilium | CLI to install, manage & troubleshoot Kubernetes clusters running Cilium. | | civo | CLI for interacting with your Civo resources. | @@ -680,6 +681,6 @@ There are 56 apps that you can install on your cluster. | waypoint | Easy application deployment for Kubernetes and Amazon ECS | | yq | Portable command-line YAML processor. | -There are 102 tools, use `arkade get NAME` to download one. +There are 103 tools, use `arkade get NAME` to download one. > Note to contributors, run `arkade get --output markdown` to generate this list diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go index e4a4eb83a..340572de7 100644 --- a/pkg/get/get_test.go +++ b/pkg/get/get_test.go @@ -4784,3 +4784,50 @@ func Test_DownloadHadolint(t *testing.T) { }) } } + +func Test_DownloadButane(t *testing.T) { + tools := MakeTools() + name := "butane" + version := "v0.15.0" + + tool := getTool(name, tools) + + tests := []test{ + { + os: "darwin", + arch: arch64bit, + version: version, + url: "https://github.com/coreos/butane/releases/download/v0.15.0/butane-x86_64-apple-darwin", + }, + { + os: "linux", + arch: arch64bit, + version: version, + url: "https://github.com/coreos/butane/releases/download/v0.15.0/butane-x86_64-unknown-linux-gnu", + }, + { + os: "linux", + arch: archARM64, + version: version, + url: "https://github.com/coreos/butane/releases/download/v0.15.0/butane-aarch64-unknown-linux-gnu", + }, + { + os: "ming", + arch: arch64bit, + version: version, + url: "https://github.com/coreos/butane/releases/download/v0.15.0/butane-x86_64-pc-windows-gnu.exe", + }, + } + + 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) + } + }) + } +} diff --git a/pkg/get/table.go b/pkg/get/table.go index 09e9cca79..c27ed16c2 100644 --- a/pkg/get/table.go +++ b/pkg/get/table.go @@ -20,7 +20,7 @@ func CreateToolsTable(tools Tools, format TableFormat) { table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Tool", "Description"}) table.SetCaption(true, - fmt.Sprintf("There are %d tools, use 'arkade get NAME' to download one.", len(tools))) + fmt.Sprintf("There are %d tools, use `arkade get NAME` to download one.", len(tools))) if format == MarkdownStyle { table.SetCaption(true) table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) diff --git a/pkg/get/tools.go b/pkg/get/tools.go index afa51948c..fda331d6f 100644 --- a/pkg/get/tools.go +++ b/pkg/get/tools.go @@ -2752,5 +2752,31 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Name}} `, }) + tools = append(tools, + Tool{ + Owner: "coreos", + Repo: "butane", + Name: "butane", + Description: "Translates human readable Butane Configs into machine readable Ignition Configs", + BinaryTemplate: ` + {{$os := ""}} + {{$ext := ""}} + {{$arch := .Arch}} + {{- if eq .OS "linux" -}} + {{$os = "unknown-linux-gnu"}} + {{- else if eq .OS "darwin" -}} + {{$os = "apple-darwin"}} + {{- else if HasPrefix .OS "ming" -}} + {{$os = "pc-windows-gnu"}} + {{$ext = ".exe"}} + {{- end -}} + + {{- if eq .Arch "arm64" -}} + {{$arch = "aarch64"}} + {{- end -}} + {{.Name}}-{{$arch}}-{{$os}}{{$ext}} + `, + }) + return tools }