From f289250a4d34842aa7c4c6f5c3a5338e9ad4a21a Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 28 Jul 2023 11:39:17 -0400 Subject: [PATCH] [fish] Update functions from sure --- fish/.config/fish/functions/al.fish | 3 ++ fish/.config/fish/functions/dnsupdate.fish | 5 ++++ fish/.config/fish/functions/k.fish | 3 ++ fish/.config/fish/functions/kc.fish | 4 +++ fish/.config/fish/functions/kush.fish | 28 +++++++++++++++++++ fish/.config/fish/functions/pt.fish | 3 ++ fish/.config/fish/functions/sure-npm-token | 4 ++- .../fish/functions/sure-npm-token.fish | 4 ++- .../fish/functions/sure-set-token.fish | 4 ++- fish/.config/fish/functions/v.fish | 3 ++ 10 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 fish/.config/fish/functions/al.fish create mode 100644 fish/.config/fish/functions/dnsupdate.fish create mode 100644 fish/.config/fish/functions/k.fish create mode 100644 fish/.config/fish/functions/kc.fish create mode 100644 fish/.config/fish/functions/kush.fish create mode 100644 fish/.config/fish/functions/pt.fish create mode 100644 fish/.config/fish/functions/v.fish diff --git a/fish/.config/fish/functions/al.fish b/fish/.config/fish/functions/al.fish new file mode 100644 index 0000000..66f1ef6 --- /dev/null +++ b/fish/.config/fish/functions/al.fish @@ -0,0 +1,3 @@ +function al + aws sso login --profile $argv +end diff --git a/fish/.config/fish/functions/dnsupdate.fish b/fish/.config/fish/functions/dnsupdate.fish new file mode 100644 index 0000000..19dd665 --- /dev/null +++ b/fish/.config/fish/functions/dnsupdate.fish @@ -0,0 +1,5 @@ +function dnsupdate + for arg in $argv +  curl -X PUT "https://box.unbl.ink/admin/dns/custom/$arg.unbl.ink" --user colin@unbl.ink:$(pass personal/colin@unbl.ink) + end +end diff --git a/fish/.config/fish/functions/k.fish b/fish/.config/fish/functions/k.fish new file mode 100644 index 0000000..8270dd9 --- /dev/null +++ b/fish/.config/fish/functions/k.fish @@ -0,0 +1,3 @@ +function k + kubectl exec -it $(kubectl get pods | fzf | awk '{print $1}'|head -n 1) -- bash -c "python manage.py shell" +end diff --git a/fish/.config/fish/functions/kc.fish b/fish/.config/fish/functions/kc.fish new file mode 100644 index 0000000..01520b7 --- /dev/null +++ b/fish/.config/fish/functions/kc.fish @@ -0,0 +1,4 @@ +function kc + echo "from platform_core.apps.core_protections.models import *" | pbcopy + kubectl exec -it $(kubectl get pods | fzf | awk '{print $1}'|head -n 1) -- bash -c "python manage.py shell" +end diff --git a/fish/.config/fish/functions/kush.fish b/fish/.config/fish/functions/kush.fish new file mode 100644 index 0000000..cfb9b50 --- /dev/null +++ b/fish/.config/fish/functions/kush.fish @@ -0,0 +1,28 @@ +function kush + + switch $argv[1] + case "sbx" + aws eks update-kubeconfig --name surepreme-sandbox-main-cluster --profile sure-inc + case "qa" + aws eks update-kubeconfig --name farmers-qa-main-cluster --profile np-farmers + case "prod" + echo "from platform_core.apps.core_protections.models import *" | pbcopy + aws eks update-kubeconfig --name surepreme-production-main-cluster --profile sure-inc + kubectl exec -it -n bastion $(kubectl get po -n bastion | grep "surepreme.*bastion" | head -n 1 | awk '{print $1}') -- python manage.py shell + end + + if test (count $argv) -gt 1 + if [ $argv[2] = "-p" ] + echo "Import command is on your clipboard" + echo "from platform_core.apps.core_protections.models import *" | pbcopy + kubectl exec -it $(kubectl get pods | fzf | awk '{print $1}'|head -n 1) -- bash -c "python manage.py shell" + else + kubectl exec -it $(kubectl get pods | fzf | awk '{print $1}'|head -n 1) -- bash + end + else + kubectl exec -it $(kubectl get pods | fzf | awk '{print $1}'|head -n 1) -- bash + end + + + +end diff --git a/fish/.config/fish/functions/pt.fish b/fish/.config/fish/functions/pt.fish new file mode 100644 index 0000000..b67e1d0 --- /dev/null +++ b/fish/.config/fish/functions/pt.fish @@ -0,0 +1,3 @@ +function pt +poetry run pytest $argv +end diff --git a/fish/.config/fish/functions/sure-npm-token b/fish/.config/fish/functions/sure-npm-token index c1627c5..355ff59 100644 --- a/fish/.config/fish/functions/sure-npm-token +++ b/fish/.config/fish/functions/sure-npm-token @@ -1 +1,3 @@ -aws codeartifact login --namespace sureapp --tool npm --repository npm --domain sure --domain-owner 348777858795 --profile $AWS_PROFILE +function sure-npm-token + aws codeartifact login --namespace sureapp --tool npm --repository npm --domain sure --domain-owner 348777858795 --profile $argv +end diff --git a/fish/.config/fish/functions/sure-npm-token.fish b/fish/.config/fish/functions/sure-npm-token.fish index c1627c5..355ff59 100644 --- a/fish/.config/fish/functions/sure-npm-token.fish +++ b/fish/.config/fish/functions/sure-npm-token.fish @@ -1 +1,3 @@ -aws codeartifact login --namespace sureapp --tool npm --repository npm --domain sure --domain-owner 348777858795 --profile $AWS_PROFILE +function sure-npm-token + aws codeartifact login --namespace sureapp --tool npm --repository npm --domain sure --domain-owner 348777858795 --profile $argv +end diff --git a/fish/.config/fish/functions/sure-set-token.fish b/fish/.config/fish/functions/sure-set-token.fish index e36c263..8a5596a 100644 --- a/fish/.config/fish/functions/sure-set-token.fish +++ b/fish/.config/fish/functions/sure-set-token.fish @@ -1,4 +1,6 @@ function sure-set-token - set -x PRIVATE_REPO_TOKEN "$(aws codeartifact get-authorization-token --domain sure --query authorizationToken --output text --profile registries-read)" + set -Ux PRIVATE_REPO_TOKEN "$(aws codeartifact get-authorization-token --domain sure --query authorizationToken --output text --profile registries-read)" + set -Ux CODEARTIFACT_AUTH_TOKEN "$PRIVATE_REPO_TOKEN" poetry config http-basic.codeartifact aws $PRIVATE_REPO_TOKEN + aws codeartifact login --namespace sureapp --tool npm --repository npm --domain sure --domain-owner 348777858795 --profile registries-read end diff --git a/fish/.config/fish/functions/v.fish b/fish/.config/fish/functions/v.fish new file mode 100644 index 0000000..16ba253 --- /dev/null +++ b/fish/.config/fish/functions/v.fish @@ -0,0 +1,3 @@ +function v + fzf --bind 'enter:become(vim {})' +end