From edfbcee6093f42bc92b18722fc30c9b7a59e0d13 Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Thu, 14 Oct 2021 10:11:17 +0100 Subject: [PATCH] Lots of changes --- .config/starship.toml | 3 ++- .dotfiles/1-zsh | 2 +- .dotfiles/aliases | 12 +++++++++--- .dotfiles/environment | 1 + .dotfiles/kubernetes | 14 +------------- .gitconfig | 9 ++++++--- .kube/switch-config.yaml | 8 ++++++++ .zshrc | 4 ++++ Makefile | 8 ++++++++ 9 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 .kube/switch-config.yaml diff --git a/.config/starship.toml b/.config/starship.toml index 8e6ef4b..06ae4e7 100644 --- a/.config/starship.toml +++ b/.config/starship.toml @@ -7,7 +7,6 @@ format = """\ $git_commit\ $git_state\ $git_status\ - $aws\ $kubernetes\ $helm\ $golang\ @@ -44,6 +43,8 @@ format = '[$symbol$context \($namespace\)]($style) ' symbol = "ﴱ " style = "bold blue" disabled = false +[kubernetes.context_aliases] +"gs-(?P.+)" = "$cluster [MC]" [terraform] format = "[$symbol$version]($style) " diff --git a/.dotfiles/1-zsh b/.dotfiles/1-zsh index fc51b79..e56a025 100644 --- a/.dotfiles/1-zsh +++ b/.dotfiles/1-zsh @@ -7,12 +7,12 @@ plugins=( zsh-autosuggestions ) autoload -U compinit && compinit -fpath=($fpath ~/.zsh/completion) DISABLE_UNTRACKED_FILES_DIRTY="true" SHOW_AWS_PROMPT=false source $ZSH/oh-my-zsh.sh +source `brew --prefix switch`/switch.sh # History HISTFILE="$HOME/.zsh_history" diff --git a/.dotfiles/aliases b/.dotfiles/aliases index c625b19..dbb3bdb 100644 --- a/.dotfiles/aliases +++ b/.dotfiles/aliases @@ -24,6 +24,8 @@ alias bandwhich='sudo bandwhich' alias top='btm' alias ps='procs' alias dig='dog' +alias kubectx='switch' +alias kctx='switch' alias machine-info='macchina -t Boron --bar' alias watch='watch ' @@ -39,7 +41,11 @@ lt() { } alias aws='docker run --rm -ti -v ~/.aws:/root/.aws -v $(pwd):/aws -e AWS_PROFILE -e AWS_DEFAULT_REGION -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY amazon/aws-cli' -git-clone() { - git clone $1 - cd "$(basename "$1" .git)" +git() { + if [ "$1" = "take" ]; then + /usr/local/bin/git clone $2 + cd $(basename $2 | sed 's/\.git$//') + else + /usr/local/bin/git $@ + fi } diff --git a/.dotfiles/environment b/.dotfiles/environment index 437f655..3709792 100644 --- a/.dotfiles/environment +++ b/.dotfiles/environment @@ -1,6 +1,7 @@ export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/goworkspace/bin:$HOME/.cargo/bin:/usr/local/kubebuilder/bin:$HOME/.asdf/shims" export EDITOR='vim' export VISUAL='code' +export GPG_TTY=$(tty) # AWS if [ -f ~/.aws/profile ]; then diff --git a/.dotfiles/kubernetes b/.dotfiles/kubernetes index 401262e..1b17de6 100644 --- a/.dotfiles/kubernetes +++ b/.dotfiles/kubernetes @@ -1,4 +1,5 @@ alias k='kubectl ' +alias kgs='kubectl-gs ' alias kshell='kubectl run -it shell --image bash --restart Never --rm -- sh' kiam () { @@ -70,12 +71,6 @@ kube-forward() { source <(kubectl completion zsh) -## Merge multiple kubeconfigs -function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } -KUBECONFIG="$HOME/.kube/config" -OTHER_CLUSTERS="$(join_by :$HOME/.kube/clusters/ $(echo $HOME/.kube/clusters/$(/bin/ls $HOME/.kube/clusters)))" -export KUBECONFIG=$KUBECONFIG:$OTHER_CLUSTERS - ## Kubectl exec kx () { local pod=($(kubectl get pods --all-namespaces -owide | fzf | awk '{print $1, $2}')) @@ -99,13 +94,6 @@ kall () { kubectl get all --all-namespaces } -kctx () { - KUBECONFIG="$HOME/.kube/config" - OTHER_CLUSTERS="$(join_by :$HOME/.kube/clusters/ $(echo $HOME/.kube/clusters/$(ls $HOME/.kube/clusters)))" - export KUBECONFIG=$KUBECONFIG:$OTHER_CLUSTERS - kubectx $@ -} - k-version-test() { VERSION="" FILES="" diff --git a/.gitconfig b/.gitconfig index 43d262b..1925ac9 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,5 +1,9 @@ [user] name = Marcus Noble + signingkey = B8F2DB8A7AEBAF78 + +[commit] + gpgsign = true [core] editor = /usr/bin/vim @@ -26,8 +30,9 @@ org-name = "!git remote -v | grep -m 1 -o ':.*/' | sed 's:^.\\(.*\\).$:\\1:'" branch-name = "!git rev-parse --abbrev-ref HEAD" changelog-changed = "!test $(git diff --name-only HEAD origin/$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') | grep CHANGELOG.md | wc -l | xargs) = 1" + main-branch = "!git remote show origin|grep HEAD|sed 's/.* //'" - main = "!git remote set-head origin --auto && git checkout $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') && git pull" + main = "!git remote set-head origin --auto && git checkout $(git main-branch) && git pull" publish = "!func(){ if [[ $(git branch-name) != \"$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')\" ]]; then git push -u origin $(git branch-name) && (git changelog-changed || echo '\n\n⚠️ Dont forget to update changelog ⚠️ ') ; else echo "Wat?!"; fi; }; func" cleanup = "!git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done" dont-change-file = "!git update-index --assume-unchanged" @@ -45,5 +50,3 @@ [url "ssh://git@github.com"] insteadOf = https://github.com -[url "ssh://git@gitlab.et-scm.com/"] - insteadOf = https://gitlab.et-scm.com diff --git a/.kube/switch-config.yaml b/.kube/switch-config.yaml new file mode 100644 index 0000000..0ca2b76 --- /dev/null +++ b/.kube/switch-config.yaml @@ -0,0 +1,8 @@ +kind: SwitchConfig +version: v1alpha1 +kubeconfigName: "*.yaml" +kubeconfigStores: +- kind: filesystem + kubeconfigName: "*.yaml" + paths: + - ~/.kube/clusters/ diff --git a/.zshrc b/.zshrc index 863f96e..ec8caf2 100644 --- a/.zshrc +++ b/.zshrc @@ -1,3 +1,7 @@ +if [ ! -z ~/.additional_dotfiles/credentials ]; then + source ~/.additional_dotfiles/credentials +fi + for filename in ~/.dotfiles/*; do source $filename done diff --git a/Makefile b/Makefile index 361b151..c415492 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ pre-reqs: ## Install all required binaries. which procs > /dev/null || brew install procs; \ which dog > /dev/null || brew install dog; \ which asdf > /dev/null || brew install asdf; \ + which switcher > /dev/null || brew install danielfoehrkn/switch/switch; \ brew install gpg gawk coreutils; \ git clone https://github.com/zsh-users/zsh-autosuggestions $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions; \ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting; \ @@ -79,6 +80,7 @@ upgrade: ## Upgrade all required binaries. which procs > /dev/null && brew upgrade procs; \ which dog > /dev/null && brew upgrade dog; \ which asdf > /dev/null && brew upgrade asdf; \ + which switcher > /dev/null && brew upgrade switch; \ cd $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions && git pull && cd -; \ cd $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && git pull && cd -; \ asdf plugin update --all; \ @@ -104,6 +106,12 @@ dotfiles: ## Installs the dotfiles. f=$$(basename $$file); \ ln -sfn $$file $(HOME)/.k9s/$$f; \ done; \ + mkdir -p $(HOME)/.kube; \ + for file in $(shell find $(CURDIR)/.kube -type f); do \ + f=$$(basename $$file); \ + ln -sfn $$file $(HOME)/.kube/$$f; \ + done; \ + .PHONY: help help: