Skip to content

Commit

Permalink
Merge pull request #137 from ibm-apiconnect/wmce-9269
Browse files Browse the repository at this point in the history
skip apicops prompt with --no-prompt
  • Loading branch information
WilliamMcEnery committed Mar 26, 2024
2 parents 71c9106 + 989f112 commit 3c98572
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions generate_postmortem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,37 @@ if [[ $NOT_DIAG_MANAGER -eq 0 ]]; then
exit 1
fi
fi

which apicops &> /dev/null
if [[ $? -eq 0 ]]; then
APICOPS="apicops"
else
if [[ ! -e /tmp/apicops-v10-linux ]]; then
if [[ $NO_PROMPT -eq 0 ]]; then
echo -e "apicops cli not found!"
read -p "Download and Install apicops cli (y/n)? " yn
case $yn in
[Yy]* )
echo -e "Downloading apicops......"
curl -L -o /tmp/apicops-v10-linux https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux
if [[ ! -e /tmp/apicops-v10-linux ]]; then
echo -e "Warning: Failed to download the apicops cli. Skipping to collect apicops mustgather. Please download the latest release of apicops manually before running the postmortem script. commands: curl -LO https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux"
else
chmod +x /tmp/apicops-v10-linux
APICOPS="/tmp/apicops-v10-linux"
fi
;;
[Nn]* )
echo -e "Skipping to collect apicops mustgather"
;;
esac
else
echo -e "Skipping to collect apicops mustgather"
fi
else
APICOPS="/tmp/apicops-v10-linux"
fi
fi
#------------------------------------------------------------------------------------------------------

#------------------------------------------ custom functions ------------------------------------------
Expand Down Expand Up @@ -1135,33 +1166,6 @@ for NAMESPACE in $NAMESPACE_LIST; do
MGMT=$(kubectl get mgmt -n $NAMESPACE 2>&1)
if [[ $MGMT != *"No resources found"* ]]; then

which apicops &> /dev/null
if [[ $? -eq 0 ]]; then
APICOPS="apicops"
else
if [[ ! -e /tmp/apicops-v10-linux ]]; then
echo -e "apicops cli not found!"
read -p "Download and Install apicops cli (y/n)? " yn
case $yn in
[Yy]* )
echo -e "Downloading apicops......"
curl -L -o /tmp/apicops-v10-linux https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux
if [[ ! -e /tmp/apicops-v10-linux ]]; then
echo -e "Warning: Failed to download the apicops cli. Skipping to collect apicops mustgather. Please download the latest release of apicops manually before running the postmortem script. commands: curl -LO https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux"
else
chmod +x /tmp/apicops-v10-linux
APICOPS="/tmp/apicops-v10-linux"
fi
;;
[Nn]* )
echo -e "Skipping to collect apicops mustgather"
;;
esac
else
APICOPS="/tmp/apicops-v10-linux"
fi
fi

if [ -v APICOPS ]; then
K8S_NAMESPACES_APICOPS_DATA="${K8S_NAMESPACES_SPECIFIC}/apicops"
mkdir -p $K8S_NAMESPACES_APICOPS_DATA
Expand Down

0 comments on commit 3c98572

Please sign in to comment.