diff --git a/.ibm/images/Dockerfile b/.ibm/images/Dockerfile index a16a8fcc37..92c1d6c9ce 100644 --- a/.ibm/images/Dockerfile +++ b/.ibm/images/Dockerfile @@ -56,5 +56,19 @@ RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages. apt-get install google-cloud-cli google-cloud-sdk-gke-gcloud-auth-plugin -y && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Set working directory +# Install skopeo +RUN apt-get update -y && \ + apt-get install -y skopeo + +# Install umoci +RUN curl -LO "https://github.com/opencontainers/umoci/releases/download/v0.4.7/umoci.amd64" && \ + chmod +x umoci.amd64 && \ + mv umoci.amd64 /usr/local/bin/umoci + +# Install opm +RUN curl -LO "https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/linux-amd64-opm" && \ + chmod +x linux-amd64-opm && \ + mv linux-amd64-opm /usr/local/bin/opm + +# Set working directory WORKDIR /tmp/ diff --git a/.ibm/pipelines/env_variables.sh b/.ibm/pipelines/env_variables.sh index f65cae705f..d0ce3f2776 100755 --- a/.ibm/pipelines/env_variables.sh +++ b/.ibm/pipelines/env_variables.sh @@ -23,6 +23,7 @@ NAME_SPACE_RBAC="${NAME_SPACE_RBAC:-showcase-rbac}" NAME_SPACE_RUNTIME="${NAME_SPACE_RUNTIME:-showcase-runtime}" NAME_SPACE_POSTGRES_DB="${NAME_SPACE_POSTGRES_DB:-postgress-external-db}" NAME_SPACE_RDS="showcase-rds-nightly" +OPERATOR_MANAGER='rhdh-operator' CHART_VERSION="2.15.2" GITHUB_APP_APP_ID=$(cat /tmp/secrets/GITHUB_APP_3_APP_ID) GITHUB_APP_CLIENT_ID=$(cat /tmp/secrets/GITHUB_APP_3_CLIENT_ID) diff --git a/.ibm/pipelines/jobs/operator.sh b/.ibm/pipelines/jobs/operator.sh index ed0095a32d..57c1f01ada 100644 --- a/.ibm/pipelines/jobs/operator.sh +++ b/.ibm/pipelines/jobs/operator.sh @@ -1,8 +1,66 @@ #!/bin/sh +install_rhdh_operator() { + local dir=$1 + local namespace=$2 + + configure_namespace $namespace + + # Make sure script is up to date + rm -f /tmp/install-rhdh-catalog-source.sh + curl -L https://raw.githubusercontent.com/redhat-developer/rhdh-operator/refs/heads/main/.rhdh/scripts/install-rhdh-catalog-source.sh > /tmp/install-rhdh-catalog-source.sh + chmod +x /tmp/install-rhdh-catalog-source.sh + bash -x /tmp/install-rhdh-catalog-source.sh --next --install-operator rhdh + + # Wait for Operator to finish unpacking + sleep 30 +} + +deploy_rhdh_operator() { + local dir=$1 + local namespace=$2 + + if [[ "${namespace}" == "showcase-op-rbac-nightly" ]]; then + oc apply -f "${dir}/resources/rhdh-operator/rhdh-start-rbac.yaml" -n "${namespace}" + else + oc apply -f "${dir}/resources/rhdh-operator/rhdh-start.yaml" -n "${namespace}" + fi +} + +initiate_operator_deployments() { + configure_namespace "${OPERATOR_MANAGER}" + install_rhdh_operator "${DIR}" "${OPERATOR_MANAGER}" + + local rhdh_base_url="https://backstage-${RELEASE_NAME}-${NAME_SPACE}.${K8S_CLUSTER_ROUTER_BASE}" + apply_yaml_files "${DIR}" "${NAME_SPACE}" "${rhdh_base_url}" + create_dynamic_plugins_config "${DIR}/value_files/${HELM_CHART_VALUE_FILE_NAME}" "/tmp/configmap-dynamic-plugins.yaml" + oc apply -f /tmp/configmap-dynamic-plugins.yaml -n "${NAME_SPACE}" + oc apply -f "$DIR/resources/redis-cache/redis-deployment.yaml" --namespace="${NAME_SPACE}" + deploy_rhdh_operator "${DIR}" "${NAME_SPACE}" + + local rbac_rhdh_base_url="https://backstage-${RELEASE_NAME_RBAC}-${NAME_SPACE_RBAC}.${K8S_CLUSTER_ROUTER_BASE}" + apply_yaml_files "${DIR}" "${NAME_SPACE_RBAC}" "${rbac_rhdh_base_url}" + create_dynamic_plugins_config "${DIR}/value_files/${HELM_CHART_RBAC_VALUE_FILE_NAME}" "/tmp/configmap-dynamic-plugins-rbac.yaml" + oc apply -f /tmp/configmap-dynamic-plugins-rbac.yaml -n "${NAME_SPACE_RBAC}" + deploy_rhdh_operator "${DIR}" "${NAME_SPACE_RBAC}" +} + handle_operator() { oc_login - apply_yaml_files "${DIR}" "${NAME_SPACE}" + API_SERVER_URL=$(oc whoami --show-server) + ENCODED_API_SERVER_URL=$(echo "${API_SERVER_URL}" | base64) + ENCODED_CLUSTER_NAME=$(echo "my-cluster" | base64) + + export K8S_CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/^[^.]*\.//') + local url="https://backstage-${RELEASE_NAME}-${NAME_SPACE}.${K8S_CLUSTER_ROUTER_BASE}" + local rbac_url="https://backstage-${RELEASE_NAME_RBAC}-${NAME_SPACE_RBAC}.${K8S_CLUSTER_ROUTER_BASE}" + + configure_namespace "${NAME_SPACE}" + configure_namespace "${NAME_SPACE_RBAC}" deploy_test_backstage_provider "${NAME_SPACE}" + cluster_setup + initiate_operator_deployments + check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "${url}" + check_and_test "${RELEASE_NAME_RBAC}" "${NAME_SPACE_RBAC}" "${rbac_url}" } diff --git a/.ibm/pipelines/openshift-ci-tests.sh b/.ibm/pipelines/openshift-ci-tests.sh index 0c4c9a3c48..61ca0356be 100755 --- a/.ibm/pipelines/openshift-ci-tests.sh +++ b/.ibm/pipelines/openshift-ci-tests.sh @@ -33,6 +33,12 @@ for SCRIPT in "${SCRIPTS[@]}"; do echo "Loaded ${SCRIPT}" done +############# REMOVE ONCE PR IS READY ############################ +JOB_NAME=e2e-tests-operator-nightly +NAME_SPACE=showcase-operator-nightly +NAME_SPACE_RBAC=showcase-op-rbac-nightly +################################################################## + main() { echo "Log file: ${LOGFILE}" echo "JOB_NAME : $JOB_NAME" diff --git a/.ibm/pipelines/resources/cluster_role_binding/cluster-role-binding-ocm.yaml b/.ibm/pipelines/resources/cluster_role_binding/cluster-role-binding-ocm.yaml index 8cd8b1525d..bca2481f39 100644 --- a/.ibm/pipelines/resources/cluster_role_binding/cluster-role-binding-ocm.yaml +++ b/.ibm/pipelines/resources/cluster_role_binding/cluster-role-binding-ocm.yaml @@ -13,3 +13,9 @@ subjects: - kind: ServiceAccount name: rhdh-k8s-plugin namespace: showcase-ci-nightly + - kind: ServiceAccount + name: rhdh-k8s-plugin + namespace: showcase-operator-nightly + - kind: ServiceAccount + name: rhdh-k8s-plugin + namespace: showcase-op-rbac-nightly \ No newline at end of file diff --git a/.ibm/pipelines/resources/config_map/app-config-rhdh-rbac.yaml b/.ibm/pipelines/resources/config_map/app-config-rhdh-rbac.yaml index b951b8b68b..397dedc75e 100644 --- a/.ibm/pipelines/resources/config_map/app-config-rhdh-rbac.yaml +++ b/.ibm/pipelines/resources/config_map/app-config-rhdh-rbac.yaml @@ -1,6 +1,10 @@ app: + baseUrl: ${RHDH_BASE_URL} title: Red Hat Developer Hub backend: + baseUrl: ${RHDH_BASE_URL} + cors: + origin: ${RHDH_BASE_URL} auth: keys: - secret: temp diff --git a/.ibm/pipelines/resources/config_map/app-config-rhdh.yaml b/.ibm/pipelines/resources/config_map/app-config-rhdh.yaml index a2a5411046..9d7d7d35ea 100644 --- a/.ibm/pipelines/resources/config_map/app-config-rhdh.yaml +++ b/.ibm/pipelines/resources/config_map/app-config-rhdh.yaml @@ -1,4 +1,5 @@ app: + baseUrl: ${RHDH_BASE_URL} title: Red Hat Developer Hub branding: fullLogo: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDIwMDEwOTA0Ly9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSLzIwMDEvUkVDLVNWRy0yMDAxMDkwNC9EVEQvc3ZnMTAuZHRkIj4KPCEtLSBDcmVhdGVkIHVzaW5nIEtyaXRhOiBodHRwczovL2tyaXRhLm9yZyAtLT4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciI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NTAzNDIsIDM1LjcyOTY4NzUpIiBmaWxsPSIjZmZmZmZmIiBzdHJva2Utb3BhY2l0eT0iMCIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjAiIHN0cm9rZS1saW5lY2FwPSJzcXVhcmUiIHN0cm9rZS1saW5lam9pbj0iYmV2ZWwiIGxldHRlci1zcGFjaW5nPSIwIiB3b3JkLXNwYWNpbmc9IjAiIHN0eWxlPSJ0ZXh0LWFsaWduOiBzdGFydDt0ZXh0LWFsaWduLWxhc3Q6IGF1dG87Zm9udC1mYW1pbHk6IFJlZCBIYXQgVGV4dDtmb250LXNpemU6IDE0O2ZvbnQtd2VpZ2h0OiA3MDA7Ij48dHNwYW4geD0iMCI+UmVkIEhhdDwvdHNwYW4+PHRzcGFuIHg9IjAiIGR5PSIxOC41MTU2MjUiPkRldmVsb3BlciBIdWI8L3RzcGFuPjwvdGV4dD4KPC9zdmc+Cg==" @@ -15,6 +16,9 @@ app: headerColor2: 'rgb(45, 190, 50)' navigationIndicatorColor: 'rgb(45, 113, 190)' backend: + baseUrl: ${RHDH_BASE_URL} + cors: + origin: ${RHDH_BASE_URL} reading: allow: - host: 'github.com' diff --git a/.ibm/pipelines/resources/rhdh-operator/rhdh-start-rbac.yaml b/.ibm/pipelines/resources/rhdh-operator/rhdh-start-rbac.yaml new file mode 100644 index 0000000000..5accf44551 --- /dev/null +++ b/.ibm/pipelines/resources/rhdh-operator/rhdh-start-rbac.yaml @@ -0,0 +1,19 @@ +kind: Backstage +apiVersion: rhdh.redhat.com/v1alpha2 +metadata: + name: rhdh-rbac +spec: + application: + image: 'quay.io/rhdh/rhdh-hub-rhel9:next' + appConfig: + configMaps: + - name: app-config-rhdh + mountPath: /opt/app-root/src + dynamicPluginsConfigMapName: dynamic-plugins + extraEnvs: + secrets: + - name: rhdh-secrets + extraFiles: + configMaps: + - name: rbac-policy + mountPath: /opt/app-root/src/rbac diff --git a/.ibm/pipelines/resources/rhdh-operator/rhdh-start.yaml b/.ibm/pipelines/resources/rhdh-operator/rhdh-start.yaml new file mode 100644 index 0000000000..9840257712 --- /dev/null +++ b/.ibm/pipelines/resources/rhdh-operator/rhdh-start.yaml @@ -0,0 +1,17 @@ +kind: Backstage +apiVersion: rhdh.redhat.com/v1alpha2 +metadata: + name: rhdh +spec: + application: + image: 'quay.io/rhdh/rhdh-hub-rhel9:next' + appConfig: + configMaps: + - name: app-config-rhdh + - name: dynamic-homepage-and-sidebar-config + mountPath: /opt/app-root/src + dynamicPluginsConfigMapName: dynamic-plugins + extraEnvs: + secrets: + - name: rhdh-secrets + - name: redis-secret diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index cae0016cc9..23117fbbe9 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -485,6 +485,18 @@ select_config_map_file() { fi } +create_dynamic_plugins_config() { + local base_file=$1 + local final_file=$2 + echo "kind: ConfigMap +apiVersion: v1 +metadata: + name: dynamic-plugins +data: + dynamic-plugins.yaml: |" >> ${final_file} + yq '.global.dynamic' ${base_file} | sed -e 's/^/ /' >> ${final_file} +} + create_app_config_map_k8s() { local config_file=$1 local project=$2 @@ -716,4 +728,3 @@ oc_login() { echo "OCP version: $(oc version)" export K8S_CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/^[^.]*\.//') } - diff --git a/e2e-tests/package.json b/e2e-tests/package.json index ae5f5998f0..8f189ebc8c 100644 --- a/e2e-tests/package.json +++ b/e2e-tests/package.json @@ -14,6 +14,8 @@ "showcase-rbac-nightly": "playwright test --project=showcase-rbac", "showcase-k8s-ci-nightly": "playwright test --project=showcase-k8s", "showcase-rbac-k8s-ci-nightly": "playwright test --project=showcase-rbac-k8s", + "showcase-operator-nightly": "playwright test --project=showcase-operator", + "showcase-op-rbac-nightly": "playwright test --project=showcase-operator-rbac", "showcase-rds-nightly": "playwright test --project=postgres-health-check", "showcase-runtime": "playwright test --project=showcase-runtime", "lint:check": "eslint . --ext .js,.ts", diff --git a/e2e-tests/playwright.config.ts b/e2e-tests/playwright.config.ts index d60763886f..34388fc2da 100644 --- a/e2e-tests/playwright.config.ts +++ b/e2e-tests/playwright.config.ts @@ -115,6 +115,36 @@ export default defineConfig({ "**/playwright/e2e/plugins/bulk-import.spec.ts", ], }, + { + name: "showcase-operator", + use: { + ...devices["Desktop Chrome"], + viewport: { width: 1920, height: 1080 }, + }, + testIgnore: [ + "**/playwright/e2e/plugins/rbac/**/*.spec.ts", + "**/playwright/e2e/plugins/analytics/analytics-disabled-rbac.spec.ts", + "**/playwright/e2e/verify-tls-config-with-external-postgres-db.spec.ts", + "**/playwright/e2e/authProviders/**/*.spec.ts", + "**/playwright/e2e/plugins/bulk-import.spec.ts", + "**/playwright/e2e/plugins/tekton/tekton.spec.ts", + "**/playwright/e2e/catalog-scaffoldedfromLink.spec.ts", + "**/playwright/e2e/audit-log/**/*.spec.ts", + "**/playwright/e2e/plugins/topology/topology.spec.ts", + "**/playwright/e2e/verify-tls-config-health-check.spec.ts", + "**/playwright/e2e/configuration-test/config-map.spec.ts", + ], + }, + { + name: "showcase-operator-rbac", + ...useCommonDeviceAndViewportConfig, + testMatch: [ + "**/playwright/e2e/plugins/rbac/**/*.spec.ts", + "**/playwright/e2e/plugins/analytics/analytics-disabled-rbac.spec.ts", + "**/playwright/e2e/verify-tls-config-with-external-postgres-db.spec.ts", + "**/playwright/e2e/plugins/bulk-import.spec.ts", + ], + }, { name: "postgres-health-check", ...useCommonDeviceAndViewportConfig,