diff --git a/Makefile b/Makefile index e01b3cfc..bf5fbdb9 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ install: ./scripts/delete-standard-storageclass.sh ./scripts/deploy-cr-scale-operator.sh ./scripts/deploy-custom-catalogsource.sh + ./scripts/deploy-operator.sh # Creates an install path specifically for the Kind QE clusters to use install-for-qe: @@ -152,4 +153,4 @@ deploy-cr-scale-operator: ./scripts/deploy-cr-scale-operator.sh lint: - shellcheck scripts/*.sh + shellcheck --nocomments scripts/*.sh diff --git a/scripts/delete-operator.sh b/scripts/delete-operator.sh index 1a053ee5..e4541a8d 100755 --- a/scripts/delete-operator.sh +++ b/scripts/delete-operator.sh @@ -6,19 +6,24 @@ SCRIPT_DIR=$(dirname "$0") # shellcheck disable=SC1091 # Not following. source "$SCRIPT_DIR"/init-env.sh +# shellcheck disable=SC2016 +: ' + # Cleanup previous deployment if present operator-sdk cleanup nginx-operator -n "$CERTSUITE_EXAMPLE_NAMESPACE" #Wait until pod is deleted until [[ -z "$(oc get pod "$OPERATOR_REGISTRY_POD_NAME" -n "$CERTSUITE_EXAMPLE_NAMESPACE" 2>/dev/null)" ]]; do sleep 5; done +' + # Delete nginx-operator in ninginx-ops namespace echo "Deleting nginx-ingress-operator .." NGINX_OPERATOR_NS="nginx-ops" NGINX_APPS_NS="nginx-apps" -CSV=$(oc get subscription nginx-ingress-operator -n "$NGINX_OPERATOR_NS" -o json | jq -r '.status.installedCSV') +CSV=$(oc get subscription nginx-ingress-operator -n "$NGINX_OPERATOR_NS" -o json | jq -r ".status.installedCSV") oc delete subscription nginx-ingress-operator -n "$NGINX_OPERATOR_NS" oc delete csv "$CSV" -n "$NGINX_OPERATOR_NS" oc delete csv "$CSV" -n "$NGINX_APPS_NS" diff --git a/scripts/deploy-operator.sh b/scripts/deploy-operator.sh index 9bc925da..40202258 100755 --- a/scripts/deploy-operator.sh +++ b/scripts/deploy-operator.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC2016,SC2086,SC1083 # Initialization SCRIPT_DIR=$(dirname "$0") @@ -6,6 +7,7 @@ SCRIPT_DIR=$(dirname "$0") # shellcheck disable=SC1091 # Not following. source "$SCRIPT_DIR"/init-env.sh +: ' #check if operator-sdk is installed and install it if needed if [[ -z "$(which operator-sdk 2>/dev/null)" ]]; then echo "operator-sdk executable cannot be found in the path. Will try to install it." @@ -13,34 +15,38 @@ if [[ -z "$(which operator-sdk 2>/dev/null)" ]]; then else echo "operator-sdk was found in the path, no need to install it" fi +' # Installing OLM "$SCRIPT_DIR"/install-olm.sh "$SCRIPT_DIR"/delete-operator.sh -# Creates a secret if a pem file exists -"$SCRIPT_DIR"/create-secret.sh +: ' + # Creates a secret if a pem file exists + "$SCRIPT_DIR"/create-secret.sh -ADD_SECRET="" + ADD_SECRET="" -# shellcheck disable=SC2143 # Use grep -q. -if [[ -n "$(oc get secret -n "$CERTSUITE_EXAMPLE_NAMESPACE" | awk '{print $1}' | grep "$SECRET_NAME")" ]]; then - ADD_SECRET="--ca-secret-name $SECRET_NAME" -fi + # shellcheck disable=SC2143 # Use grep -q. + if [[ -n "$(oc get secret -n "$CERTSUITE_EXAMPLE_NAMESPACE" | awk '{print $1}' | grep "$SECRET_NAME")" ]]; then + ADD_SECRET="--ca-secret-name $SECRET_NAME" + fi -# Deploy the operator bundle -operator-sdk run bundle "$OPERATOR_BUNDLE_IMAGE_FULL_NAME" -n "$CERTSUITE_EXAMPLE_NAMESPACE" "$ADD_SECRET" + # Deploy the operator bundle + operator-sdk run bundle "$OPERATOR_BUNDLE_IMAGE_FULL_NAME" -n "$CERTSUITE_EXAMPLE_NAMESPACE" "$ADD_SECRET" -# Important: this line (output of command is now captured) is required to enable csv short names with non-ocp cluster -# If short name "csv" is used, the call will fail the first time -# With long name the first time it will work and subsequent time it will work with long or short names -CSV_MATCH=$(oc get clusterserviceversions.operators.coreos.com -n "$CERTSUITE_EXAMPLE_NAMESPACE" -ogo-template='{{ range .items}}{{.metadata.name}}{{end}}' 2>/dev/null | grep "nginx-operator.v0.0.1") -if [ "$CSV_MATCH" = "nginx-operator.v0.0.1" ]; then - echo "CSV successfully deployed" -else - echo "ERROR: CSV not deployed. Operator deployment failed -- interrupting tests" - exit 1 -fi + # Important: this line (output of command is now captured) is required to enable csv short names with non-ocp cluster + # If short name "csv" is used, the call will fail the first time + # With long name the first time it will work and subsequent time it will work with long or short names + CSV_MATCH=$(oc get clusterserviceversions.operators.coreos.com -n "$CERTSUITE_EXAMPLE_NAMESPACE" -ogo-template='{{ range .items}}{{.metadata.name}}{{end}}' 2>/dev/null | grep "nginx-operator.v0.0.1") + if [ "$CSV_MATCH" = "nginx-operator.v0.0.1" ]; then + echo "CSV successfully deployed" + else + echo "ERROR: CSV not deployed. Operator deployment failed -- interrupting tests" + exit 1 + fi + +' # deploy single namespace operator nginx in namespace nginx-ops oc apply --filename ./test-target/operator-single-install-mode.yaml diff --git a/test-target/operator-single-install-mode.yaml b/test-target/operator-single-install-mode.yaml index 18a75254..d4ae72d5 100644 --- a/test-target/operator-single-install-mode.yaml +++ b/test-target/operator-single-install-mode.yaml @@ -26,8 +26,6 @@ kind: Subscription metadata: name: nginx-ingress-operator namespace: nginx-ops - labels: - nginx-ingress-operator.v2.4.2 spec: channel: alpha installPlanApproval: Automatic