-
Notifications
You must be signed in to change notification settings - Fork 0
/
kustomize.plugin.zsh
50 lines (41 loc) · 1.87 KB
/
kustomize.plugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Command Completino
if (( $+commands[kustomize] )); then
# If the completion file does not exist, generate it and then source it
if is-at-least 3.8.6 $(kustomize version | awk 'match($0, /([0-9.]+) /) { print substr($0, RSTART, RLENGTH) }'); then
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kustomize" ]]; then
kustomize completion zsh | tee "$ZSH_CACHE_DIR/completions/_kustomize" >/dev/null
source "$ZSH_CACHE_DIR/completions/_kustomize"
else
source "$ZSH_CACHE_DIR/completions/_kustomize"
kustomize completion zsh | tee "$ZSH_CACHE_DIR/completions/_kustomize" >/dev/null &|
fi
fi
fi
# This command is used a LOT both below and in daily life
alias kz=kustomize
# Build
alias kzb='kustomize build'
# Create a new kustomization
alias kzc='kustomize create'
# Create a new kustomization and autodetect manifests in current folder
alias kzca='kustomize create --autodetect'
# Create a new kustomization and autodetect manifests current and all sub folders
alias kzcar='kustomize create --autodetect --recursive'
# Edit
alias kze='kustomize edit'
# Print version
alias kzv='kustomize version'
# Only run if the user actually has kustomize installed
if (( ${+_comps[kustomize]} )); then
# Build and pipe output to YQ for colors
function kzby() { kustomize build "$@" | yh; }
# Kustomize build and pipe to kubectl apply
function kzba() { kustomize build "$@" | kubectl apply -f -; }
# Kustomize build and pipe to kubectl apply server side
function kzbas() { kustomize build "$@" | kubectl apply -f - --server-side; }
# Kustomize build and pipe to kubectl apply server side with force-conflicts
function kzbasf() { kustomize build "$@" | kubectl apply -f - --server-side --force-conflicts; }
# Kustomize build and pipe to kubectl delete
function kzbdel() { kustomize build "$@" | kubectl delete -f -; }
fi