Skip to content

Commit

Permalink
fix: added generic examples
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandremahdhaoui committed Sep 24, 2023
1 parent a211b1e commit e09550d
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 72 deletions.
7 changes: 0 additions & 7 deletions examples/expression_0.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions examples/expression_1.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions examples/expression_2.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions examples/expression_set_0.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions examples/profile_0.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions examples/profile_1.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions examples/set_0.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions examples/set_1.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions examples/set_2.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: vib.alexandre.mahdhaoui.com/v1alpha1
kind: ExpressionSet
metadata:
name: alias
spec:
keyValues:
- grep: grep --color=always
- less: less -N
- ls: ls --color=always
- ll: ls -laF
- h: helm
- hi: helm upgrade --install
- hid: h install --dry-run
- hdu: h dependency update
resolverRef: alias
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: vib.alexandre.mahdhaoui.com/v1alpha1
kind: ExpressionSet
metadata:
name: env
spec:
keyValues:
- GOPATH: $(go env GOPATH)
- GOBIN: ${GOPATH}/bin
- PATH: ${PATH}:${GOBIN}
resolverRef: environment-exported
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: vib.alexandre.mahdhaoui.com/v1alpha1
kind: ExpressionSet
metadata:
name: kubectl
spec:
keyValues:
- k: kubectl "${@}"
- ka: kubectl apply -f "${@}"
- kns-current: kubectl config view --minify -o jsonpath='{..namespace}'
- kctx: |-
__err_no_match() { echo Cannot match context with pattern \"${1}\"; }
CONTEXT_PATTERN="${1}"
CONTEXTS="$(kubectl config get-contexts -oname)"
if [ -z "${CONTEXT_PATTERN}" ]; then echo "${CONTEXTS}"; return ;fi
# select between available context from the CONTEXT_MATCH
# - if no match: return err no match
# - if and only if 1 match: don't prompt for selection and use this context
CONTEXT_MATCH=$(echo "${CONTEXTS}" | grep --color=none "${CONTEXT_PATTERN}")
if [ -z "${CONTEXT_MATCH}" ]; then __err_no_match "${CONTEXT_PATTERN}"; return 1; fi
CONTEXT_SELECTED=""
if [ $(echo ${CONTEXT_MATCH} | wc -w) == "1" ]; then
CONTEXT_SELECTED="${CONTEXT_MATCH}"
else
PS3="Please select a context: "
select X in ${CONTEXT_MATCH}; do
CONTEXT_SELECTED="${X}"
break
done
fi
if [ -z "${CONTEXT_SELECTED}" ]; then echo Please select a context; return 1; fi
# Use context on selected context
kubectl config use-context "${CONTEXT_SELECTED}" &&\
echo Successfully selected context \"${CONTEXT_SELECTED}\" ||\
echo Failed to select context \"${CONTEXT_SELECTED}\"
- kd: kubectl describe "${@}"
- kdds: kubectl describe daemonset "${@}"
- kdp: kubectl describe pod "${@}"
- kdrs: kubectl describe replicaset "${@}"
- kdsts: kubectl describe statefulset "${@}"
- ke: kubectl edit "${@}"
- kex: kubectl exec -it "${@}"
- kg: kubectl get "${@}"
- kga: kubectl get -A "${@}"
- kgp: kubectl get pods "${@}"
- kgpa: kubectl get pods -A "${@}"
- kgd: kubectl get deployments "${@}"
- kgsts: kubectl get sts "${@}"
- kgrs: kubectl get rs "${@}"
- kgg: kubectl get "${1}" | grep "${2}"
- kgga: kubectl get "${1}" -A | grep "${2}"
- kns: |-
NAMESPACE="${1:-default}"
kubectl config set-context --current --namespace "${NAMESPACE}" && echo Successfully switched to namespace: \"${NAMESPACE}\"
- kl: kubectl logs "${@}"
- kll: kubectl logs -l "${@}"
- klp: kubectl logs --previous "${@}"
- klf: kubectl logs -f "${@}"
- kpf: kubectl port-forward "${@}"
resolverRef: function
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: vib.alexandre.mahdhaoui.com/v1alpha1
kind: Profile
metadata:
name: myprofile
spec:
setRefs:
- env
- alias
- kubectl

0 comments on commit e09550d

Please sign in to comment.