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

feat: flag to ignore cluster-info check #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
13 changes: 10 additions & 3 deletions kube-dump
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Flags:
--detailed Do not remove detailed state specific fields
--output-by-type Organize output into directories by resource type
--flat Organize all resources of the same type in the same file
--ignore-cluster-info Ignore cluster-info fail (useful for OpenShift w/o full admin permissions)

Kubernetes flags:
-n, --namespaces List of kubernetes namespaces
Expand Down Expand Up @@ -150,7 +151,7 @@ args=$(
getopt \
-l "namespaces:,namespaced-resources:,cluster-resources:" \
-l "kube-config:,kube-context:,kube-cluster:,kube-insecure-tls" \
-l "help,silent,destination:,force-remove,detailed,output-by-type,flat" \
-l "help,silent,destination:,force-remove,detailed,output-by-type,flat,ignore-cluster-info" \
-l "git-commit,git-push,git-branch:,git-commit-user:,git-commit-email:" \
-l "git-remote-name:,git-remote-url:" \
-l "archivate,archive-rotate-days:,archive-type:" \
Expand All @@ -175,6 +176,7 @@ while [ $# -ge 1 ]; do
--detailed) detailed='true'; shift;;
--output-by-type) output_by_type='true'; shift;;
--flat) output_flat='true'; shift;;
--ignore-cluster-info) ignore_cluster_info="true"; shift;;
# Dump opts
-f|--force-remove) force_remove='true'; shift;;
# Commit opts
Expand Down Expand Up @@ -204,6 +206,7 @@ fi
: "${detailed:=$DETAILED}"
: "${output_by_type:=$OUTPUT_BY_TYPE}"
: "${output_flat:=$FLAT}"
: "${ignore_cluster_info:=$IGNORE_CLUSTER_INFO}"
: "${kube_config:=$KUBE_CONFIG}"
: "${kube_context:=$KUBE_CONTEXT}"
: "${kube_cluster:=$KUBE_CLUSTER}"
Expand Down Expand Up @@ -295,8 +298,12 @@ if [ -n "$kube_cluster" ]; then
fi

# Try get cluster info
kubectl cluster-info "${k_args[@]}" >/dev/null || \
fail "Cluster $kube_api not accessible"
if [ "$ignore_cluster_info" != 'true' ]; then
kubectl cluster-info "${k_args[@]}" >/dev/null || \
fail "Cluster $kube_api not accessible. See --ignore-cluster-info option."
else
warn "Ignoring cluster-info check"
fi

# Set namespaces list
if [ -z "${namespaces:-$NAMESPACES}" ]; then
Expand Down