Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --export deprecation #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions fubectl.source
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,17 @@ function kfor() {
function ksearch() {
local search_query="$1"
[ -z "$search_query" ] && printf "ksearch: missing argument.\nUsage: ksearch SEARCH_QUERY\n" && return 255
for ns in $(kubectl get --export -o=json ns | jq -r '.items[] | .metadata.name'); do
kubectl --namespace="${ns}" get --export -o=json \
deployment,ingress,daemonset,secrets,configmap,service,serviceaccount,statefulsets,pod,endpoints,customresourcedefinition,events,networkpolicies,persistentvolumeclaims,persistentvolumes,replicasets,replicationcontrollers,statefulsets,storageclasses | \
jq '.items[]' -c | \
grep "$search_query" | \
jq -r '. | [.kind, .metadata.name] | @tsv' | \
awk -v prefix="$ns" '{print "kubectl get -n " prefix " " $0}'
search_query="$1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already local search_query="$1"

for ns in $(kubectl get ns -o=json | jq -r '.items[].metadata.name'); do
kubeItems=$(kubectl --namespace="${ns}" get svc,pods -o=json | jq -r 'del(.metadata.resourceVersion,.metadata.uid,.metadata.selfLink,.metadata.creationTimestamp,.metadata.annotations,.metadata.generation,.metadata.ownerReferences,.status)')
kron4eg marked this conversation as resolved.
Show resolved Hide resolved
items=$(echo "$kubeItems" | jq '.items ' | jq -c .)
item_count=$(echo "$kubeItems" | jq '.items | length')
for ((i = 0; i < item_count; i++)); do
item=$(echo "$kubeItems" | jq -r ".items[$i]" | jq -c .)
if echo "$kubeItems" | jq -r ".items[$i]" | grep "$search_query" > /dev/null 2>&1; then
echo $item| jq -r '. | [.kind, .metadata.name] | @tsv' | awk -v prefix="$ns" '{print "kubectl get -n " prefix " "$0}'
fi
done
done
}

Expand Down