Skip to content

Commit 2fa6ebf

Browse files
committed
feat: Add kubecolor for colorized kubectl output. Update completions
1 parent 581cb2e commit 2fa6ebf

File tree

6 files changed

+89
-3
lines changed

6 files changed

+89
-3
lines changed

ansible/roles/config/templates/zshrc.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ plugins=(
107107
pyenv-lazy
108108
jq
109109
kubectl
110+
aws
111+
azure
112+
terraform
110113
{% if actual_node_version.stdout | regex_search('^v[0-9]*\.[0-9]*\.[0-9]*') %}
111114
zsh-snv
112115
{% endif %}
@@ -143,6 +146,11 @@ echo 'source <(switcher init zsh)' >> ~/.zshrc
143146
echo 'source <(alias s=switch)' >> ~/.zshrc
144147
echo 'source <(switch completion zsh)' >> ~/.zshrc
145148

149+
### kubecolor
150+
alias kubectl=kubecolor
151+
source <(kubectl completion zsh)
152+
compdef kubecolor=kubectl
153+
146154
### Fuzzy Finder
147155

148156
# Setup fzf
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# kubecolor (colorize kubectl output)
2+
# Source: https://github.com/kubecolor/kubecolor
3+
---
4+
- name: "[kubecolor] Check installed kubecolor version"
5+
ansible.builtin.command: dpkg-query -W kubecolor
6+
register: kubecolor_check_deb
7+
ignore_errors: true
8+
changed_when: kubecolor_check_deb.rc > 1
9+
failed_when: kubecolor_check_deb.rc > 1
10+
tags:
11+
- versions
12+
13+
- name: "[kubecolor] Get Github URL for proper version"
14+
vars:
15+
app: kubecolor
16+
repo: kubecolor/kubecolor
17+
version_query: curl -s https://api.github.com/repos/kubecolor/kubecolor/releases/latest | jq .name -r | cut -f2 -d'v'
18+
github_uri: "v{{ kubecolor_version }}/kubecolor_{{ kubecolor_version }}_linux_amd64.deb"
19+
ansible.builtin.include_role:
20+
name: common
21+
tasks_from: github_version.yml
22+
apply:
23+
tags:
24+
- versions
25+
tags:
26+
- versions
27+
28+
- name: "Installation"
29+
when: kubecolor_check_deb.stdout | regex_search('[0-9]+\.[0-9]+\.[0-9]+') | default(0) != kubecolor_version
30+
block:
31+
- name: "[kubecolor] Create directory in {{ ansible_env.HOME }}/.local/opt"
32+
ansible.builtin.file:
33+
path: "{{ ansible_env.HOME }}/.local/opt/kubecolor-{{ kubecolor_version }}"
34+
state: directory
35+
mode: '0755'
36+
37+
- name: "[kubecolor] Download kubecolor {{ kubecolor_version }}"
38+
ansible.builtin.get_url:
39+
url: "{{ kubecolor_url }}"
40+
dest: "{{ ansible_env.HOME }}/.local/opt/kubecolor-{{ kubecolor_version }}"
41+
mode: '0755'
42+
43+
- name: "[kubecolor] Install {{ kubecolor_version }} .deb package"
44+
ansible.builtin.apt:
45+
deb: "{{ ansible_env.HOME }}/.local/opt/kubecolor-{{ kubecolor_version }}/kubecolor_{{ kubecolor_version }}_linux_amd64.deb"
46+
become: true
47+
48+
- name: "[kubecolor] Save used version"
49+
vars:
50+
app: kubecolor
51+
target_version:
52+
github_packages:
53+
kubecolor: "{{ kubecolor_version }}"
54+
query: ".github_packages.kubecolor = \"{{ kubecolor_version }}\""
55+
ansible.builtin.include_role:
56+
name: common
57+
tasks_from: save_version.yml
58+
apply:
59+
tags:
60+
- versions
61+
tags:
62+
- versions

ansible/roles/software/tasks/main.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@
197197
- versions
198198
- kubectl
199199

200+
- name: "[Software] kubecolor"
201+
ansible.builtin.include_tasks:
202+
file: kubecolor.yml
203+
apply:
204+
tags:
205+
- software
206+
- kubecolor
207+
when: "'kubecolor' not in software_tasks_exclude"
208+
tags:
209+
- software
210+
- versions
211+
- kubecolor
212+
200213
- name: "[Software] KinD"
201214
ansible.builtin.include_tasks:
202215
file: kind.yml

ansible/roles/software/vars/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ github_packages:
5757
fd: latest
5858
kind: latest
5959
k9s: latest
60+
kubecolor: latest
6061
yq: latest
6162
win32yank: latest
6263
terraform: latest

docs-web/docs/main/roles/10-software.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Various tools:
1010
4. [Diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) - alternate GIT DIFF presentation
1111
5. [Git fuzzy](https://github.com/bigH/git-fuzzy.git) - managing GIT commands using FZF
1212
6. [Gita](https://github.com/nosarthur/gita) - managing multiple GIT repositories at once (add groups, execute git or shell commands for those groups etc.)
13-
7. (temporarily disabled) ~[TheFuck](https://github.com/nvbn/thefuck) - corrects errors in previous console commands~
13+
7. [pay-respects](https://github.com/iffse/pay-respects) - corrects errors in previous console commands
1414
8. [BAT](https://github.com/sharkdp/bat) - (much) better CAT
1515
9. [Zoxide](https://github.com/ajeetdsouza/zoxide) - traverse directories with ease (also with FZF)
1616
10. [Helm](https://github.com/helm/helm) - Kubernetes 'package manager'
@@ -59,7 +59,6 @@ Available software excludes:
5959
- git-fuzzy
6060
- lazygit
6161
- gita
62-
- thefuck
6362
- bat
6463
- zoxide
6564
- helm
@@ -78,3 +77,7 @@ Available software excludes:
7877
- neovim
7978
- astronvim
8079
- puppet
80+
- kubecolor
81+
- pay-respects
82+
- kubeswitch
83+
- az-account-switcher

docs-web/docs/main/roles/20-config.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Available configs excludes:
2929
- git
3030
- lazygit
3131
- neovim-config
32-
- thefuck
3332
- ansible
3433
3534
## Backups

0 commit comments

Comments
 (0)