-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #816 from IBM/806-cpd-script-fix
Fix project assignment and improve project existence checks in subscr…
- Loading branch information
Showing
2 changed files
with
57 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
#!/bin/bash | ||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ) | ||
|
||
# Determine the project that runs the operators | ||
oc get project ibm-common-services > /dev/null 2>&1 | ||
if [ $? -eq 0 ];then | ||
fs_project="ibm-common-services" | ||
else | ||
fs_project=cpd-operators" | ||
|
||
# Check if PROJECT_CPD_INST_OPERATORS and PROJECT_CPD_INST_OPERANDS are set, otherwise throw an error | ||
if [ -z "${PROJECT_CPD_INST_OPERATORS}" ] || [ -z "${PROJECT_CPD_INST_OPERANDS}" ]; then | ||
echo "Error: Environment variables PROJECT_CPD_INST_OPERATORS or PROJECT_CPD_INST_OPERANDS are not set." | ||
echo "Please source the cpd_vars file or define them" | ||
exit 1 | ||
fi | ||
|
||
echo "Listing subscriptions and their CSVs" | ||
oc get sub -n ${fs_project} \ | ||
--sort-by=.metadata.creationTimestamp \ | ||
--no-headers \ | ||
-o jsonpath='{range .items[*]}{.metadata.name}{","}{.metadata.creationTimestamp}{","}{.status.installedCSV}{","}{.status.state}{"\n"}{end}' | ||
#Operators Project | ||
fs_project=${PROJECT_CPD_INST_OPERATORS} | ||
|
||
# List subscriptions and their CSVs | ||
if oc get project ${fs_project} > /dev/null 2>&1; then | ||
echo "Listing subscriptions and their CSVs" | ||
oc get sub -n ${fs_project} \ | ||
--sort-by=.metadata.creationTimestamp \ | ||
--no-headers \ | ||
-o jsonpath='{range .items[*]}{.metadata.name}{","}{.metadata.creationTimestamp}{","}{.status.installedCSV}{","}{.status.state}{"\n"}{end}' | ||
else | ||
echo "Error: Project ${fs_project} does not exist or cannot be accessed." | ||
exit 1 | ||
fi |