#!/bin/bash set -e CHART_REPO="$1" if [[ -z "$CHART_REPO" ]]; then echo "[ERR] Chart directory argument missing. Usage: $0 " exit 1 fi if [[ ! -d "$CHART_REPO" ]]; then echo "[ERR] Path not found: $CHART_REPO" exit 1 fi SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT="$(cd $SCRIPT_DIR/../../.. && pwd)" CFG_DIR="$ROOT/tests/config/k8s" CHT_DIR="$CHART_REPO/charts/ocis" TPL_DIR="$CHT_DIR/templates" function patch_templates(){ # patch ocis service templates for service in "$TPL_DIR"/*/; do if [[ -f "$service/deployment.yaml" ]]; then if grep -qE 'ocis.caEnv' "$service/deployment.yaml"; then sed -i '/.*ocis.caEnv.*/a\{{- include "ocis.extraEnvs" . | nindent 12 }}' "$service/deployment.yaml" sed -i '/.*ocis.caPath.*/a\{{- include "ocis.extraVolMounts" . | nindent 12 }}' "$service/deployment.yaml" sed -i '/.*ocis.caVolume.*/a\{{- include "ocis.extraVolumes" . | nindent 8 }}' "$service/deployment.yaml" else sed -i '/env:/a\{{- include "ocis.extraEnvs" . | nindent 12 }}' "$service/deployment.yaml" sed -i '/volumeMounts:/a\{{- include "ocis.extraVolMounts" . | nindent 12 }}' "$service/deployment.yaml" sed -i '/volumes:/a\{{- include "ocis.extraVolumes" . | nindent 8 }}' "$service/deployment.yaml" fi fi done # copy custom template resources cp -r $CFG_DIR/templates/* $TPL_DIR/ # add authbasic service sed -i "/{{- define \"ocis.basicServiceTemplates\" -}}/a\ {{- \$_ := set .scope \"appNameAuthBasic\" \"authbasic\" -}}" $TPL_DIR/_common/_tplvalues.tpl # [NOTE] # Remove schema validation to add extra configs in values.yaml. # Also this allows us to use fakeoffice as web-office server rm "$CHT_DIR/values.schema.json" } if [[ -f "$CHT_DIR/values.schema.json" ]]; then patch_templates fi if [[ "$ENABLE_ANTIVIRUS" == "true" ]]; then sed -i '/virusscan:/{n;s|false|true|}' $CFG_DIR/values.yaml fi if [[ "$ENABLE_EMAIL" == "true" ]]; then sed -i '/emailNotifications:/{n;s|false|true|}' $CFG_DIR/values.yaml fi if [[ "$ENABLE_TIKA" == "true" ]]; then sed -i 's|type: basic|type: tika|' $CFG_DIR/values.yaml fi if [[ "$ENABLE_WOPI" == "true" ]]; then sed -i '/appsIntegration:/{n;s|false|true|}' $CFG_DIR/values.yaml # patch collaboration service # - allow dynamic wopi src sed -i -E "s|value: http://.*:9300|value: {{ \$officeSuite.wopiSrc }}|" $TPL_DIR/collaboration/deployment.yaml sed -i \ -e 's/{{- include "ocis.extraEnvs" \. | nindent 12 }}/{{- include "ocis.extraEnvs" $ | nindent 12 }}/' \ -e 's/{{- include "ocis.extraVolMounts" \. | nindent 12 }}/{{- include "ocis.extraVolMounts" $ | nindent 12 }}/' \ -e 's/{{- include "ocis.extraVolumes" \. | nindent 8 }}/{{- include "ocis.extraVolumes" $ | nindent 8 }}/' \ $TPL_DIR/collaboration/deployment.yaml sed -i "s|availableUnifiedRoles: \[\]|availableUnifiedRoles: ['b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5','a8d5fe5e-96e3-418d-825b-534dbdf22b99','fb6c3e19-e378-47e5-b277-9732f9de6e21','58c63c02-1d89-4572-916a-870abc5a1b7d','2d00ce52-1fc2-4dbc-8b95-a73b73395f5a','1c996275-f1c9-4e71-abdf-a42f6495e960','312c0871-5ef7-4b3a-85b6-0e4074c64049','aa97fe03-7980-45ac-9e50-b325749fd7e6']|" $CFG_DIR/values.yaml fi if [[ "$ENABLE_OCM" == "true" ]]; then sed -i '/ocm:/{n;s|false|true|}' $CFG_DIR/values.yaml fi if [[ "$ENABLE_AUTH_APP" == "true" ]]; then sed -i '/authapp:/{n;s|false|true|}' $CFG_DIR/values.yaml fi if [[ "$ENABLE_VAULT" == "true" ]]; then sed -i '/vault:/{n;s|false|true|}' $CFG_DIR/values.yaml sed -i '/mfa:/{n;s|false|true|}' $CFG_DIR/values.yaml # baking keycloak url into the base CSP would affect every other suite that # shares this same values.yaml, breaking their fixed CSP header assertions. sed -i "/defaultSrc:/i\\ - 'https://keycloak:8443/'" $CFG_DIR/values.yaml sed -i "/imgSrc:/i\\ - 'https://keycloak:8443/'" $CFG_DIR/values.yaml fi # copy custom values file cp $CFG_DIR/values.yaml "$CHT_DIR/ci/deployment-values.yaml"