Skip to content

Commit

Permalink
Merge pull request #117 from ibm-apiconnect/wmce-9073
Browse files Browse the repository at this point in the history
prompt to download kubectl-cnp plugin
  • Loading branch information
WilliamMcEnery committed Feb 2, 2024
2 parents 5e11762 + 0a82c92 commit 9450693
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 20 deletions.
29 changes: 23 additions & 6 deletions edb_mustgather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,29 @@ fi
EDB_CLUSTER_NAMESPACE=$1
LOG_PATH=$2

if which kubectl-cnp >/dev/null; then
echo kubectl-cnp plugin found
else
echo kubectl-cnp plugin not found, please install it and add it to your PATH, see https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin
exit 1
fi
if which kubectl-cnp >/dev/null; then
echo kubectl-cnp plugin found
else
echo -e "kubectl-cnp plugin not found"
read -p "Download and Install kubectl-cnp plugin (y/n)? " yn
case $yn in
[Yy]* )
echo -e "Proceeding..."
echo -e "Executing: curl -sSfL https://github.com/EnterpriseDB/kubectl-cnp/raw/main/install.sh | sudo sh -s -- -b /usr/local/bin"
curl -sSfL \
https://github.com/EnterpriseDB/kubectl-cnp/raw/main/install.sh | \
sudo sh -s -- -b /usr/local/bin
if [[ $? -ne 0 ]]; then
echo "Error installing kubectl-cnp plugin. Exiting..."
exit 1
fi
;;
[Nn]* )
echo -e "Exiting... please install kubectl-cnp plugin and add it to your PATH, see https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin."
exit 1
;;
esac
fi

if [ -z "$1" ] || [ -z "$2" ]
then
Expand Down
43 changes: 29 additions & 14 deletions generate_postmortem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,33 @@ else
KUBECTL="kubectl"
fi

# Check if kubectl-cnp plugin is installed
function is_kubectl_cnp_plugin {
if which kubectl-cnp >/dev/null; then
echo kubectl-cnp plugin found
else
echo -e "kubectl-cnp plugin not found"
read -p "Download and Install kubectl-cnp plugin (y/n)? " yn
case $yn in
[Yy]* )
echo -e "Proceeding..."
echo -e "Executing: curl -sSfL https://github.com/EnterpriseDB/kubectl-cnp/raw/main/install.sh | sudo sh -s -- -b /usr/local/bin"
curl -sSfL \
https://github.com/EnterpriseDB/kubectl-cnp/raw/main/install.sh | \
sudo sh -s -- -b /usr/local/bin
if [[ $? -ne 0 ]]; then
echo "Error installing kubectl-cnp plugin. Exiting..."
exit 1
fi
;;
[Nn]* )
echo -e "Exiting... please install kubectl-cnp plugin and add it to your PATH, see https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin."
exit 1
;;
esac
fi
}

for switch in $@; do
case $switch in
*"-h"*|*"--help"*)
Expand Down Expand Up @@ -114,14 +141,7 @@ for switch in $@; do
SCRIPT_LOCATION="`pwd`/crunchy_gather.py"
else
COLLECT_EDB=1

if which kubectl-cnp >/dev/null; then
echo kubectl-cnp plugin found
else
echo -e "kubectl-cnp plugin not found, please install it and add it to your PATH, see https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin. Exiting..."
exit 1
fi

is_kubectl_cnp_plugin
SCRIPT_LOCATION="`pwd`/edb_mustgather.sh"
fi
if [[ ! -f $SCRIPT_LOCATION ]]; then
Expand Down Expand Up @@ -186,12 +206,7 @@ for switch in $@; do
*"--collect-edb"*)
COLLECT_EDB=1

if which kubectl-cnp >/dev/null; then
echo kubectl-cnp plugin found
else
echo -e "kubectl-cnp plugin not found, please install it and add it to your PATH, see https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin. Exiting..."
exit 1
fi
is_kubectl_cnp_plugin

SCRIPT_LOCATION="`pwd`/edb_mustgather.sh"
if [[ ! -f $SCRIPT_LOCATION ]]; then
Expand Down

0 comments on commit 9450693

Please sign in to comment.