Skip to content

Commit

Permalink
Add 'kubectx'
Browse files Browse the repository at this point in the history
  • Loading branch information
myhro committed Dec 28, 2023
1 parent d443f2f commit 0baeeb0
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $ staticd <tool>
- `cloudflared`: [cloudflare/cloudflared][cloudflared], Argo Tunnel client.
- `flyctl`: [superfly/flyctl][flyctl], command line tools for fly.io services
- `k9s`: [derailed/k9s][k9s], Kubernetes CLI to manage your clusters in style.
- `kubectx`: [ahmetb/kubectx][kubectx], faster way to switch between clusters in kubectl
- `upx`: [upx/upx][upx], the Ultimate Packer for eXecutables.
- `xh`: [ducaale/xh][xh], friendly and fast tool for sending HTTP requests.
- `yj`: [sclevine/yj][yj], convert between YAML, TOML, JSON, and HCL.
Expand All @@ -25,6 +26,7 @@ $ staticd <tool>
[cloudflared]: https://github.com/cloudflare/cloudflared
[flyctl]: https://github.com/superfly/flyctl
[k9s]: https://github.com/derailed/k9s
[kubectx]: https://github.com/ahmetb/kubectx
[upx]: https://github.com/upx/upx
[xh]: https://github.com/ducaale/xh
[yj]: https://github.com/sclevine/yj
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ func main() {
},
}

kubectxCmd := &cobra.Command{
Use: tools.Kubectx,
Short: "Faster way to switch between clusters in kubectl",
Run: func(cmd *cobra.Command, args []string) {
run(tools.Kubectx)
},
}

upxCmd := &cobra.Command{
Use: tools.UPX,
Short: "The Ultimate Packer for eXecutables",
Expand Down Expand Up @@ -155,6 +163,7 @@ func main() {
rootCmd.AddCommand(cloudflaredCmd)
rootCmd.AddCommand(flyctlCmd)
rootCmd.AddCommand(k9sCmd)
rootCmd.AddCommand(kubectxCmd)
rootCmd.AddCommand(upxCmd)
rootCmd.AddCommand(xhCmd)
rootCmd.AddCommand(yjCmd)
Expand Down
10 changes: 10 additions & 0 deletions tables/arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ var Arch = map[string]map[string]map[string]string{
"arm64": "arm64",
},
},
Kubectx: {
"darwin": {
"amd64": "x86_64",
"arm64": "arm64",
},
"linux": {
"amd64": "x86_64",
"arm64": "arm64",
},
},
UPX: {
"linux": {
"amd64": "amd64",
Expand Down
10 changes: 10 additions & 0 deletions tables/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ var OS = map[string]map[string]map[string]string{
"arm64": "Linux",
},
},
Kubectx: {
"darwin": {
"amd64": "darwin",
"arm64": "darwin",
},
"linux": {
"amd64": "linux",
"arm64": "linux",
},
},
UPX: {
"linux": {
"amd64": "linux",
Expand Down
4 changes: 4 additions & 0 deletions tables/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (s *TablesTestSuite) TestToolsNames() {
local: tables.K9s,
remote: tools.K9s,
},
{
local: tables.Kubectx,
remote: tools.Kubectx,
},
{
local: tables.UPX,
remote: tools.UPX,
Expand Down
1 change: 1 addition & 0 deletions tables/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const (
Cloudflared = "cloudflared"
Flyctl = "flyctl"
K9s = "k9s"
Kubectx = "kubectx"
UPX = "upx"
Xh = "xh"
Yj = "yj"
Expand Down
1 change: 1 addition & 0 deletions tables/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var URL = map[string]string{
Cloudflared: "https://github.com/cloudflare/cloudflared/releases",
Flyctl: "https://github.com/superfly/flyctl/releases",
K9s: "https://github.com/derailed/k9s/releases",
Kubectx: "https://github.com/ahmetb/kubectx/releases",
UPX: "https://github.com/upx/upx/releases",
Xh: "https://github.com/ducaale/xh/releases",
Yj: "https://github.com/sclevine/yj/releases",
Expand Down
4 changes: 4 additions & 0 deletions tools/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func (t *Tool) AssetK9s() {
t.Asset.Name = fmt.Sprintf("k9s_%v_%v.tar.gz", t.OS, t.Arch)
}

func (t *Tool) AssetKubectx() {
t.Asset.Name = fmt.Sprintf("kubectx_%v_%v_%v.tar.gz", t.Version, t.OS, t.Arch)
}

func (t *Tool) AssetUPX() {
baseName := fmt.Sprintf("upx-%v-%v_%v", t.TrimVersion(), t.Arch, t.OS)
t.Asset.Name = baseName + ".tar.xz"
Expand Down
7 changes: 7 additions & 0 deletions tools/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ func (s *AssetTestSuite) TestName() {
version: "v0.30.4",
filename: "k9s_Linux_amd64.tar.gz",
},
{
name: Kubectx,
arch: "arm64",
os: "darwin",
version: "v0.9.5",
filename: "kubectx_v0.9.5_darwin_arm64.tar.gz",
},
{
name: UPX,
arch: "amd64",
Expand Down
4 changes: 4 additions & 0 deletions tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
Cloudflared = "cloudflared"
Flyctl = "flyctl"
K9s = "k9s"
Kubectx = "kubectx"
UPX = "upx"
Xh = "xh"
Yj = "yj"
Expand Down Expand Up @@ -140,6 +141,7 @@ func (t *Tool) GetVersion() error {
return nil
}

//nolint:cyclop
func (t *Tool) SetAsset() error {
t.Asset.Destination = path.Join(t.BaseDir(), t.Name)
t.Asset.WithinArchive = t.Name
Expand All @@ -155,6 +157,8 @@ func (t *Tool) SetAsset() error {
t.AssetFlyctl()
case K9s:
t.AssetK9s()
case Kubectx:
t.AssetKubectx()
case UPX:
t.AssetUPX()
case Xh:
Expand Down

0 comments on commit 0baeeb0

Please sign in to comment.