Skip to content

Commit

Permalink
[minor] Add Update and Upgrade command support (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
durera authored Aug 15, 2022
1 parent 97e569f commit 6777ac5
Show file tree
Hide file tree
Showing 20 changed files with 781 additions and 110 deletions.
3 changes: 3 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Changes

- [`2.3`](https://github.com/ibm-mas/cli/releases/tag/2.3.0) Add Update and Upgrade command support
- [`2.2`](https://github.com/ibm-mas/cli/releases/tag/2.2.0) Catalog update for IoT airgap support fix
- [`2.1`](https://github.com/ibm-mas/cli/releases/tag/2.1.0) Support Maximo Optimizer & Visual Inspection on Air Gap
- [`2.0`](https://github.com/ibm-mas/cli/releases/tag/2.0.0) Support for MAS 8.8 & Maximo Curated Operator Catalog
- [`1.0`](https://github.com/ibm-mas/cli/releases/tag/1.0.0) Initial release
150 changes: 95 additions & 55 deletions image/cli/bin/functions/mirror_to_registry
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ Red Hat Catalog Selection (Optional):
--mirror-redhat-operators ${COLOR_YELLOW}OPENSHIFT_OPERATORS_VERSION${TEXT_RESET} Mirror Red Hat Release catalog images at the specified version (e.g. 4.10.18)
Maximo Operator Catalog Selection (Optional):
-c, --catalog ${COLOR_YELLOW}MAS_CATALOG_VERSION${TEXT_RESET} Maximo Operator Catalog Version to mirror (e.g. v8-220717)
-c, --catalog ${COLOR_YELLOW}MAS_CATALOG_VERSION${TEXT_RESET} Maximo Operator Catalog Version to mirror (e.g. v8-220805)
--mirror-core Mirror images for IBM Maximo Application Suite Core & dependencies
--mirror-assist Mirror images for IBM Maximo Assist
--mirror-hputilities Mirror images for IBM Maximo Health & Predict Utilities
--mirror-iot Mirror images for IBM Maximo IoT & dependencies
--mirror-manage Mirror images for IBM Maximo Manage & dependencies
--mirror-monitor Mirror images for IBM Maximo Monitor
--mirror-predict Mirror images for IBM Maximo Predict
--mirror-optimizer Mirror images for IBM Maximo Optimizer
--mirror-safety Mirror images for IBM Maximo Safety
--mirror-visualinspection Mirror images for IBM Maximo Visual Inspection
Maximo Core Image Mirroring Configuration (Optional):
Expand All @@ -56,12 +61,21 @@ EOM


function mirror_to_registry_noninteractive() {
# Red Hat
MIRROR_RH_RELEASE=false
MIRROR_RH_OPERATORS=false
# Main content
MIRROR_MAS_CORE=false
MIRROR_MAS_ASSIST=false
MIRROR_MAS_HPUTILITIES=false
MIRROR_MAS_IOT=false
MIRROR_MAS_MANAGE=false
MIRROR_MAS_MONITOR=false
MIRROR_MAS_PREDICT=false
MIRROR_MAS_OPTIMIZER=false
MIRROR_MAS_SAFETY=false
MIRROR_MAS_VISUALINSPECTION=false
MIRROR_MAS_X=false
# Dependencies
MIRROR_COMMONSERVICES=true
MIRROR_UDS=true
Expand Down Expand Up @@ -108,18 +122,43 @@ function mirror_to_registry_noninteractive() {
;;
--mirror-core)
MIRROR_MAS_CORE=true
MIRROR_MAS_X=true
;;
--mirror-assist)
MIRROR_MAS_ASSIST=true
MIRROR_MAS_X=true
;;
--mirror-hputilities)
MIRROR_MAS_HPUTILITIES=true
MIRROR_MAS_X=true
;;
--mirror-iot)
MIRROR_MAS_IOT=true
MIRROR_MAS_X=true
;;
--mirror-manage)
MIRROR_MAS_MANAGE=true
MIRROR_MAS_X=true
;;
--mirror-monitor)
MIRROR_MAS_MONITOR=true
MIRROR_MAS_X=true
;;
--mirror-predict)
MIRROR_MAS_PREDICT=true
MIRROR_MAS_X=true
;;
--mirror-optimizer)
MIRROR_MAS_OPTIMIZER=true
MIRROR_MAS_X=true
;;
--mirror-safety)
MIRROR_MAS_SAFETY=true
MIRROR_MAS_X=true
;;
--mirror-visualinspection)
MIRROR_MAS_VISUALINSPECTION=true
MIRROR_MAS_X=true
;;
--skip-cfs)
MIRROR_COMMONSERVICES=false
Expand Down Expand Up @@ -157,13 +196,15 @@ function mirror_to_registry_noninteractive() {
# Check all args have been set
[[ -z "$REGISTRY_PUBLIC_HOST" ]] && mirror_to_registry_help "REGISTRY_PUBLIC_HOST is not set"
[[ -z "$REGISTRY_PUBLIC_PORT" ]] && mirror_to_registry_help "REGISTRY_PUBLIC_PORT is not set"
if [[ $MIRROR_MAS_CORE == "true" || $MIRROR_MAS_IOT == "true" || $MIRROR_MAS_MANAGE == "true" ]]; then
if [[ $MIRROR_MAS_X == "true" ]]; then
[[ -z "$MAS_CATALOG_VERSION" ]] && mirror_to_registry_help "MAS_CATALOG_VERSION is not set"
[[ -z "$IBM_ENTITLEMENT_KEY" ]] && mirror_to_registry_help "IBM_ENTITLEMENT_KEY is not set"
fi
if [[ $MIRROR_UDS == "true" || $MIRROR_RH_RELEASE == "true" || $MIRROR_RH_OPERATORS == "true" ]]; then
[[ -z "$REDHAT_CONNECT_USERNAME" ]] && mirror_to_registry_help "REDHAT_CONNECT_USERNAME is not set"
[[ -z "$REDHAT_CONNECT_PASSWORD" ]] && mirror_to_registry_help "REDHAT_CONNECT_PASSWORD is not set"
if [[ $MIRROR_MAS_CORE == "true" ]]; then
if [[ $MIRROR_UDS == "true" || $MIRROR_RH_RELEASE == "true" || $MIRROR_RH_OPERATORS == "true" ]]; then
[[ -z "$REDHAT_CONNECT_USERNAME" ]] && mirror_to_registry_help "REDHAT_CONNECT_USERNAME is not set"
[[ -z "$REDHAT_CONNECT_PASSWORD" ]] && mirror_to_registry_help "REDHAT_CONNECT_PASSWORD is not set"
fi
fi
}

Expand Down Expand Up @@ -227,9 +268,14 @@ function mirror_to_registry_interactive() {
MIRROR_TRUSTSTOREMGR=true
MIRROR_MONGOCE=true
# Apps
MIRROR_MAS_ASSIST=true
MIRROR_MAS_HPUTILITIES=true
MIRROR_MAS_IOT=true
MIRROR_MAS_MANAGE=true
MIRROR_MAS_MONITOR=true
MIRROR_MAS_PREDICT=true
MIRROR_MAS_OPTIMIZER=true
MIRROR_MAS_SAFETY=true
MIRROR_MAS_VISUALINSPECTION=true
# App Dependencies
MIRROR_DB2U=true
Expand All @@ -253,9 +299,13 @@ function mirror_to_registry_interactive() {
prompt_for_confirm_default_yes " + MongoDb Community Edition" MIRROR_MONGOCE
fi

prompt_for_confirm "IBM Maximo Application Suite - IoT" MIRROR_MAS_IOT
prompt_for_confirm "IBM Maximo Application Suite - IoT" MIRROR_MAS_HPUTILITIES
prompt_for_confirm "IBM Maximo Application Suite - HP Utilities" MIRROR_MAS_HPUTILITIES
prompt_for_confirm "IBM Maximo Application Suite - Manage" MIRROR_MAS_MANAGE
prompt_for_confirm "IBM Maximo Application Suite - Monitor" MIRROR_MAS_MONITOR
prompt_for_confirm "IBM Maximo Application Suite - Predict" MIRROR_MAS_PREDICT
prompt_for_confirm "IBM Maximo Application Suite - Optimizer" MIRROR_MAS_OPTIMIZER
prompt_for_confirm "IBM Maximo Application Suite - Safety" MIRROR_MAS_SAFETY
prompt_for_confirm "IBM Maximo Application Suite - Visual Inspection" MIRROR_MAS_VISUALINSPECTION
if [[ "$MIRROR_MAS_IOT" == "true" || "$MIRROR_MAS_MANAGE" == "true" ]]; then
prompt_for_confirm_default_yes " + IBM Db2" MIRROR_DB2U
Expand Down Expand Up @@ -294,6 +344,14 @@ function mirror_one_thing() {
fi
}


function show_mirror_status() {
if [[ "$2" == "true" ]]
then echo_reset_dim "$1 ${COLOR_GREEN}Mirror"
else echo_reset_dim "$1 ${COLOR_RED}Skip"
fi
}

function mirror_to_registry() {
# Take the first parameter off (it will be mirror-images)
shift
Expand Down Expand Up @@ -322,9 +380,14 @@ function mirror_to_registry() {
export MIRROR_TRUSTSTOREMGR
export MIRROR_MONGOCE
# Apps & Dependencies
export MIRROR_MAS_ASSIST
export MIRROR_MAS_HPUTILITIES
export MIRROR_MAS_IOT
export MIRROR_MAS_MANAGE
export MIRROR_MAS_MONITOR
export MIRROR_MAS_PREDICT
export MIRROR_MAS_OPTIMIZER
export MIRROR_MAS_SAFETY
export MIRROR_MAS_VISUALINSPECTION
export MIRROR_DB2U
# Authentication
Expand Down Expand Up @@ -372,71 +435,43 @@ function mirror_to_registry() {

echo "${TEXT_DIM}"
echo_h2 "IBM Operator Catalog" " "
if [[ "$MIRROR_MAS_CORE" == "true" || "$MIRROR_MAS_IOT" == "true" || "$MIRROR_MAS_MANAGE" == "true" \
|| "$MIRROR_MAS_OPTIMIZER" == "true" || MIRROR_MAS_VISUALINSPECTION == "true" ]]
if [[ "$MIRROR_MAS_CORE" == "true" || "$MIRROR_MAS_ASSIST" == "true" || "$MIRROR_MAS_HPUTILITIES" == "true" || "$MIRROR_MAS_IOT" == "true" \
|| "$MIRROR_MAS_MANAGE" == "true" || "$MIRROR_MAS_MONITOR" == "true" || "$MIRROR_MAS_PREDICT" == "true" \
|| "$MIRROR_MAS_OPTIMIZER" == "true" || "$MIRROR_MAS_SAFETY" == "true" || "$MIRROR_MAS_VISUALINSPECTION" == "true" ]]
then
echo_reset_dim "Catalog Version ..................... ${COLOR_MAGENTA}${MAS_CATALOG_VERSION}"
echo_reset_dim "IBM Authentication .................. ${COLOR_MAGENTA}cp/${IBM_ENTITLEMENT_KEY:0:4}<snip>"

# Core
if [[ "$MIRROR_MAS_CORE" == "true" ]]
then echo_reset_dim "IBM Maximo Application Suite Core ... ${COLOR_GREEN}Mirror"
else echo_reset_dim "IBM Maximo Application Suite Core ... ${COLOR_RED}Skip"
fi
show_mirror_status "IBM Maximo Application Suite Core ..." $MIRROR_MAS_CORE

# Applications
if [[ "$MIRROR_MAS_IOT" == "true" ]]
then echo_reset_dim "IBM Maximo IoT ...................... ${COLOR_GREEN}Mirror"
else echo_reset_dim "IBM Maximo IoT ...................... ${COLOR_RED}Skip"
fi
if [[ "$MIRROR_MAS_MANAGE" == "true" ]]
then echo_reset_dim "IBM Maximo Manage ................... ${COLOR_GREEN}Mirror"
else echo_reset_dim "IBM Maximo Manage ................... ${COLOR_RED}Skip"
fi
if [[ "$MIRROR_MAS_OPTIMIZER" == "true" ]]
then echo_reset_dim "IBM Maximo Optimizer ................ ${COLOR_GREEN}Mirror"
else echo_reset_dim "IBM Maximo Optimizer ................ ${COLOR_RED}Skip"
fi
if [[ "$MIRROR_MAS_VISUALINSPECTION" == "true" ]]
then echo_reset_dim "IBM Maximo Visual Inspection ........ ${COLOR_GREEN}Mirror"
else echo_reset_dim "IBM Maximo Visual Inspection ........ ${COLOR_RED}Skip"
fi

# Dependencies
show_mirror_status "IBM Maximo Assist ..................." $MIRROR_MAS_ASSIST
show_mirror_status "IBM Maximo IoT ......................" $MIRROR_MAS_IOT
show_mirror_status "IBM Maximo Manage ..................." $MIRROR_MAS_MANAGE
show_mirror_status "IBM Maximo Monitor .................." $MIRROR_MAS_MONITOR
show_mirror_status "IBM Maximo Predict .................." $MIRROR_MAS_PREDICT
show_mirror_status "IBM Maximo Optimizer ................" $MIRROR_MAS_OPTIMIZER
show_mirror_status "IBM Maximo Safety ..................." $MIRROR_MAS_SAFETY
show_mirror_status "IBM Maximo Visual Inspection ........" $MIRROR_MAS_VISUALINSPECTION

# Core Dependencies
if [[ "$MIRROR_MAS_CORE" == "true" ]]; then
if [[ "$MIRROR_COMMONSERVICES" == "true" ]]
then echo_reset_dim " + IBM Db2 .......................... ${COLOR_GREEN}Mirror"
else echo_reset_dim " + IBM Db2 .......................... ${COLOR_RED}Skip"
fi
if [[ "$MIRROR_UDS" == "true" ]]
then echo_reset_dim " + IBM User Data Services ........... ${COLOR_GREEN}Mirror"
else echo_reset_dim " + IBM User Data Services ........... ${COLOR_RED}Skip"
fi
if [[ "$MIRROR_SLS" == "true" ]]
then echo_reset_dim " + IBM Suite License Service ........ ${COLOR_GREEN}Mirror"
else echo_reset_dim " + IBM Suite License Service ........ ${COLOR_RED}Skip"
fi
if [[ "$MIRROR_TRUSTSTOREMGR" == "true" ]]
then echo_reset_dim " + IBM Truststore Manager ........... ${COLOR_GREEN}Mirror"
else echo_reset_dim " + IBM Truststore Manager ........... ${COLOR_RED}Skip"
fi
if [[ "$MIRROR_MONGOCE" == "true" ]]
then echo_reset_dim " + MongoDb Community Edition ........ ${COLOR_GREEN}Mirror"
else echo_reset_dim " + MongoDb Community Edition ........ ${COLOR_RED}Skip"
fi
show_mirror_status " + IBM Cloud Pak Foundation Services " $MIRROR_COMMONSERVICES
show_mirror_status " + IBM User Data Services ..........." $MIRROR_UDS
show_mirror_status " + IBM Suite License Service ........" $MIRROR_SLS
show_mirror_status " + IBM Truststore Manager ..........." $MIRROR_TRUSTSTOREMGR
show_mirror_status " + MongoDb Community Edition ........" $MIRROR_MONGOCE
fi
# IoT & Manage Dependencies
if [[ "$MIRROR_MAS_IOT" == "true" || "$MIRROR_MAS_MANAGE" == "true" ]]; then
if [[ "$MIRROR_MAS_MANAGE" == "true" ]]
then echo_reset_dim " + IBM Db2 .......................... ${COLOR_GREEN}Mirror"
else echo_reset_dim " + IBM Db2 .......................... ${COLOR_RED}Skip"
fi
show_mirror_status " + IBM Db2 .......................... " $MIRROR_DB2U
fi
else
echo_reset_dim "${COLOR_RED}Skip"
fi
reset_colors


echo
reset_colors
if [[ "$NO_CONFIRM" != "true" ]]; then
Expand All @@ -452,8 +487,13 @@ function mirror_to_registry() {
mirror_one_thing $MIRROR_RH_OPERATORS "Red Hat Operators" "$LOG_PREFIX-ocp-operators.log" mirror_openshift_operators

mirror_one_thing $MIRROR_MAS_CORE "IBM Maximo Application Suite Core" "$LOG_PREFIX-core.log" mirror_core
mirror_one_thing $MIRROR_MAS_ASSIST "IBM Maximo Assist" "$LOG_PREFIX-assist.log" mirror_add_assist
mirror_one_thing $MIRROR_MAS_HPUTILITIES "IBM Maximo HP Utilties" "$LOG_PREFIX-hputilties.log" mirror_add_hputilities
mirror_one_thing $MIRROR_MAS_IOT "IBM Maximo IoT" "$LOG_PREFIX-iot.log" mirror_add_iot
mirror_one_thing $MIRROR_MAS_MANAGE "IBM Maximo Manage" "$LOG_PREFIX-manage.log" mirror_add_manage
mirror_one_thing $MIRROR_MAS_MONITOR "IBM Maximo Monitor" "$LOG_PREFIX-monitor.log" mirror_add_monitor
mirror_one_thing $MIRROR_MAS_PREDICT "IBM Maximo Predict" "$LOG_PREFIX-predict.log" mirror_add_predict
mirror_one_thing $MIRROR_MAS_OPTIMIZER "IBM Maximo Optimizer" "$LOG_PREFIX-optimizer.log" mirror_add_optimizer
mirror_one_thing $MIRROR_MAS_SAFETY "IBM Maximo Safety" "$LOG_PREFIX-safety.log" mirror_add_safety
mirror_one_thing $MIRROR_MAS_VISUALINSPECTION "IBM Maximo Visual Inspection" "$LOG_PREFIX-visualinspection.log" mirror_add_visualinspection
}
29 changes: 23 additions & 6 deletions image/cli/bin/functions/pipeline_config
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,30 @@ function pipeline_config() {
fi
prompt_for_input "MAS Instance ID" MAS_INSTANCE_ID

MAS_CATALOG_SOURCE=ibm-operator-catalog
if [[ -z "$AIRGAP_MODE" ]]; then
prompt_for_confirm "Use online catalog?" USE_ONLINE_CATALOG
if [[ "$USE_ONLINE_CATALOG" == "true" ]]; then
MAS_CATALOG_VERSION=v8-amd64
else
echo -e "${COLOR_YELLOW}Catalog Version:"
echo " 1. v8 (2022-08-05)"
echo " 2. v8 (2022-07-17)"
prompt_for_input "Select Catalog Source" MAS_CATALOG_SELECTION "1"

case $MAS_CATALOG_SELECTION in
1|220805|2022-08-05)
MAS_CATALOG_VERSION=v8-220805-amd64
;;
2|220717|2022-07-17)
MAS_CATALOG_VERSION=v8-220717-amd64
;;
*)
exit 1
;;
esac
fi

echo -e "${COLOR_YELLOW}MAS Version:"
echo " 1. 8.8"
echo " 2. 8.7"
Expand All @@ -23,20 +46,14 @@ function pipeline_config() {
case $MAS_CHANNEL_SELECTION in
1|8.8|8.8.x)
MAS_CHANNEL=8.8.x
MAS_CATALOG_SOURCE=ibm-operator-catalog
MAS_CATALOG_VERSION=v8
;;

2|8.7|8.7.x)
MAS_CHANNEL=8.7.x
MAS_CATALOG_SOURCE=ibm-operator-catalog
MAS_CATALOG_VERSION=v8
;;

3|8.6|8.6.x)
MAS_CHANNEL=8.6.x
MAS_CATALOG_SOURCE=ibm-operator-catalog
MAS_CATALOG_VERSION=v8
;;

*)
Expand Down
40 changes: 40 additions & 0 deletions image/cli/bin/functions/pipeline_install_tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# - Set up namespace
# - Create tasks and pipeline resources
# - Set up RBAC
function pipeline_install_tasks() {
# Install the MAS Tekton definitions
cp $DIR/templates/ibm-mas-tekton.yaml $CONFIG_DIR/ibm-mas-tekton-$MAS_INSTANCE_ID.yaml
sed -e "s/:latest/:$VERSION/g" $DIR/templates/deployment.yaml > $CONFIG_DIR/deployment-$MAS_INSTANCE_ID.yaml
CLI_IMAGE=quay.io/ibmmas/cli:$VERSION

if [[ "$AIRGAP_MODE" == "true" ]]; then
# If we're installing on airgap then we can't reference the images by tag, we need to prompt the user to enter the digest of
# a specific version of the container image ... we can't do this automatically as we are inside the image.
prompt_for_confirm_default_yes "Override image tag '$VERSION' with digest?" USE_DIGEST
if [[ "$USE_DIGEST" == "true" ]]; then
CLI_IMAGE_DIGEST=$(skopeo inspect docker://quay.io/ibmmas/cli:$VERSION 2>> $LOGFILE | jq -r ".Digest")
if [[ "$CLI_IMAGE_DIGEST" == "" ]]; then
echo_warning "Unable to retrieve image digest for quay.io/ibmmas/cli:$VERSION"
exit 1
fi
echo "Using image digest $CLI_IMAGE_DIGEST"
# Overwrite the tekton definitions with one that uses the looked up image digest
sed -e "s/:$VERSION/@$CLI_IMAGE_DIGEST/g" $DIR/templates/ibm-mas-tekton.yaml > $CONFIG_DIR/ibm-mas-tekton-$MAS_INSTANCE_ID.yaml
sed -e "s/:latest/@$CLI_IMAGE_DIGEST/g" $DIR/templates/deployment.yaml > $CONFIG_DIR/deployment-$MAS_INSTANCE_ID.yaml
CLI_IMAGE=quay.io/ibmmas/cli@$CLI_IMAGE_DIGEST
fi
fi

# Set up namespace
sed "s/{{mas_instance_id}}/$MAS_INSTANCE_ID/g" $DIR/templates/namespace.yaml > $CONFIG_DIR/namespace-$MAS_INSTANCE_ID.yaml
oc apply -f $CONFIG_DIR/namespace-$MAS_INSTANCE_ID.yaml &>> $LOGFILE

# Create tasks and pipeline resources in namespace
oc -n mas-$MAS_INSTANCE_ID-pipelines apply -f $CONFIG_DIR/ibm-mas-tekton-$MAS_INSTANCE_ID.yaml &>> $LOGFILE

# Set up RBAC in namespace
sed "s/{{mas_instance_id}}/$MAS_INSTANCE_ID/g" $DIR/templates/rbac.yaml > $CONFIG_DIR/rbac-$MAS_INSTANCE_ID.yaml
oc apply -f $CONFIG_DIR/rbac-$MAS_INSTANCE_ID.yaml &>> $LOGFILE
}
Loading

0 comments on commit 6777ac5

Please sign in to comment.