Skip to content

Commit

Permalink
install script and readme.md update
Browse files Browse the repository at this point in the history
  • Loading branch information
gaganyaan2 committed Oct 28, 2022
1 parent 2eb760f commit a412bcc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# kx-kn in rust (WIP)
Simple kubernetes context and namespace switch using rust
# kx-kn in rust
Simple kubernetes context and namespace switch in rust

### Install kn and kx:
- **kx** - Switch between kubernetes context
- **kn** - Switch between kubernetes namespace

### Install kx and kn in linux:

```bash
WIP
curl -s https://raw.githubusercontent.com/koolwithk/kx-kn-rust/main/install.sh | bash
```

### Run:
Expand All @@ -20,10 +23,6 @@ kx <context> #switch to other context
- small binary size
- fast

### Limitation:

- WIP

### Refrences:
- https://github.com/ahmetb/kubectx (Inspired By)
- https://doc.rust-lang.org/rust-by-example/index.html
Expand Down
29 changes: 29 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

if [[ $1 == '--uninstall' ]]; then
rm -rf $HOME/.local/bin/kx $HOME/.local/bin/kn
echo "Uninstall kn and kx from $HOME/.local/bin/kn $HOME/.local/bin/kx"
exit
fi

if [[ $(uname) == "Linux" ]]; then
cd /tmp
tag_name=$(curl -s "https://api.github.com/repos/koolwithk/kx-kn-rust/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
curl -s https://github.com/koolwithk/kx-kn-rust/releases/download/$tag_name/kn-$tag_name-x86_64-linux-musl.tar.gz -L --output kn-$tag_name-x86_64-linux-musl.tar.gz
tar -xzf kn-$tag_name-x86_64-linux-musl.tar.gz
rm -rf kn-$tag_name-x86_64-linux-musl.tar.gz
mkdir -p $HOME/.local/bin
/usr/bin/mv kn $HOME/.local/bin

curl -s https://github.com/koolwithk/kx-kn-rust/releases/download/$tag_name/kx-$tag_name-x86_64-linux-musl.tar.gz -L --output kx-$tag_name-x86_64-linux-musl.tar.gz
tar -xzf kx-$tag_name-x86_64-linux-musl.tar.gz
rm -rf kx-$tag_name-x86_64-linux-musl.tar.gz
/usr/bin/mv kx $HOME/.local/bin
echo "Installed kn and kx $tag_name at $HOME/.local/bin/kx $HOME/.local/bin/kn"

if [[ "$(echo "$PATH" | grep -o "$HOME/.local/bin")" != "$HOME/.local/bin" ]]; then
echo 'Please add /usr/local/bin to your $PATH'
fi
else
echo "$(uname) OS not supported by this script :("
fi

0 comments on commit a412bcc

Please sign in to comment.