diff --git a/compose.yaml b/compose.yaml index e00cda9..8dcd926 100644 --- a/compose.yaml +++ b/compose.yaml @@ -28,6 +28,7 @@ x-app-environment: &app-environment SMTP_SSL: ${SMTP_SSL:-false} UNISENDER_GO_API_KEY: ${UNISENDER_GO_API_KEY:-} UNISENDER_GO_BASE_URL: ${UNISENDER_GO_BASE_URL:-https://goapi.unisender.ru/ru/transactional/api/v1} + UNISENDER_GO_SKIP_UNSUBSCRIBE: ${UNISENDER_GO_SKIP_UNSUBSCRIBE:-false} EMAIL_HTTP_CONNECT_TIMEOUT_MS: ${EMAIL_HTTP_CONNECT_TIMEOUT_MS:-} EMAIL_HTTP_RECEIVE_TIMEOUT_MS: ${EMAIL_HTTP_RECEIVE_TIMEOUT_MS:-} EMAIL_FROM_NAME: ${EMAIL_FROM_NAME:?Set EMAIL_FROM_NAME in .env} diff --git a/deploy/helm/who-need-help/templates/deployments.yaml b/deploy/helm/who-need-help/templates/deployments.yaml index 7011f28..5a6ace3 100644 --- a/deploy/helm/who-need-help/templates/deployments.yaml +++ b/deploy/helm/who-need-help/templates/deployments.yaml @@ -55,6 +55,8 @@ spec: value: {{ $root.Values.app.emailDeliveryProvider | quote }} - name: UNISENDER_GO_BASE_URL value: {{ $root.Values.app.unisenderGoBaseUrl | quote }} + - name: UNISENDER_GO_SKIP_UNSUBSCRIBE + value: {{ $root.Values.app.unisenderGoSkipUnsubscribe | quote }} securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true @@ -101,6 +103,8 @@ spec: value: {{ $root.Values.app.smtpPort | quote }} - name: UNISENDER_GO_BASE_URL value: {{ $root.Values.app.unisenderGoBaseUrl | quote }} + - name: UNISENDER_GO_SKIP_UNSUBSCRIBE + value: {{ $root.Values.app.unisenderGoSkipUnsubscribe | quote }} - name: CODEX_SESSION_ID value: {{ $root.Values.app.codexSessionId | quote }} - name: RATE_LIMIT_POLICIES_JSON diff --git a/deploy/helm/who-need-help/templates/migrate-job.yaml b/deploy/helm/who-need-help/templates/migrate-job.yaml index d6d6e04..2a473d5 100644 --- a/deploy/helm/who-need-help/templates/migrate-job.yaml +++ b/deploy/helm/who-need-help/templates/migrate-job.yaml @@ -47,6 +47,8 @@ spec: value: {{ .Values.app.emailDeliveryProvider | quote }} - name: UNISENDER_GO_BASE_URL value: {{ .Values.app.unisenderGoBaseUrl | quote }} + - name: UNISENDER_GO_SKIP_UNSUBSCRIBE + value: {{ .Values.app.unisenderGoSkipUnsubscribe | quote }} securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true diff --git a/deploy/helm/who-need-help/values.schema.json b/deploy/helm/who-need-help/values.schema.json index a1e126e..c3f1c9c 100644 --- a/deploy/helm/who-need-help/values.schema.json +++ b/deploy/helm/who-need-help/values.schema.json @@ -20,12 +20,16 @@ "unisenderGoBaseUrl": { "type": "string", "pattern": "^https://" + }, + "unisenderGoSkipUnsubscribe": { + "type": "boolean" } }, "required": [ "erlangPortLimit", "emailDeliveryProvider", - "unisenderGoBaseUrl" + "unisenderGoBaseUrl", + "unisenderGoSkipUnsubscribe" ] } } diff --git a/deploy/helm/who-need-help/values.yaml b/deploy/helm/who-need-help/values.yaml index 36e366e..720b526 100644 --- a/deploy/helm/who-need-help/values.yaml +++ b/deploy/helm/who-need-help/values.yaml @@ -37,6 +37,7 @@ app: smtpRelay: mailpit smtpPort: "1025" unisenderGoBaseUrl: https://goapi.unisender.ru/ru/transactional/api/v1 + unisenderGoSkipUnsubscribe: false # Required. The Secret must contain DATABASE_URL, SECRET_KEY_BASE, # HANDOVER_SECRET, RELEASE_COOKIE, and METRICS_TOKEN. It may also contain both diff --git a/scripts/quality.sh b/scripts/quality.sh index a15f866..6c61b13 100755 --- a/scripts/quality.sh +++ b/scripts/quality.sh @@ -136,6 +136,16 @@ PRODUCTION_CODEX_SESSION_ID=00000000-0000-0000-0000-000000000001 \ ./scripts/init-production-env.sh help.test "$api_production_env" >/dev/null ./scripts/validate-production-env.sh "$api_production_env" help.test >/dev/null grep -Fx 'EMAIL_DELIVERY_PROVIDER=unisender_go' "$api_production_env" >/dev/null +grep -Fx 'UNISENDER_GO_SKIP_UNSUBSCRIBE=false' "$api_production_env" >/dev/null +api_override_env="$scan_dir/.env.production.unisender-go-skip-unsubscribe" +PRODUCTION_EMAIL_DELIVERY_PROVIDER=unisender_go \ +PRODUCTION_UNISENDER_GO_API_KEY=quality-unisender-go-api-key \ +PRODUCTION_UNISENDER_GO_SKIP_UNSUBSCRIBE=true \ +PRODUCTION_EMAIL_FROM_ADDRESS=contact@help.test \ +PRODUCTION_CODEX_SESSION_ID=00000000-0000-0000-0000-000000000001 \ + ./scripts/init-production-env.sh help.test "$api_override_env" >/dev/null +./scripts/validate-production-env.sh "$api_override_env" help.test >/dev/null +grep -Fx 'UNISENDER_GO_SKIP_UNSUBSCRIBE=true' "$api_override_env" >/dev/null if PRODUCTION_EMAIL_DELIVERY_PROVIDER=unisender_go \ PRODUCTION_CODEX_SESSION_ID=00000000-0000-0000-0000-000000000001 \ ./scripts/init-production-env.sh \ @@ -280,6 +290,11 @@ docker compose --project-directory "$ROOT" --env-file "$edge_env" \ ./scripts/compose.sh .env.example config --quiet ./scripts/compose.sh "$production_env" config --quiet ./scripts/compose.sh "$api_production_env" config --quiet +./scripts/compose.sh "$api_override_env" config --format json | + jq --exit-status ' + .services.app.environment.UNISENDER_GO_SKIP_UNSUBSCRIBE == "true" and + .services.migrate.environment.UNISENDER_GO_SKIP_UNSUBSCRIBE == "true" + ' >/dev/null ./scripts/compose.sh "$external_production_env" config --quiet ./scripts/compose.sh "$external_socket_production_env" config --quiet ./scripts/compose.sh "$external_split_production_env" config --quiet @@ -503,12 +518,29 @@ tar --extract --file="$scan_tar" --directory "$scan_dir" --values "$ROOT/deploy/helm/who-need-help/values-kind.yaml" \ "$ROOT/deploy/helm/who-need-help" \ >"$scan_dir/rendered-helm.yaml" +"$ROOT/.tools/bin/helm" template who-need-help \ + --values "$ROOT/deploy/helm/who-need-help/values-kind.yaml" \ + --set app.unisenderGoSkipUnsubscribe=true \ + "$ROOT/deploy/helm/who-need-help" \ + >"$scan_dir/rendered-helm-unisender-override.yaml" test "$( grep -c 'name: ERL_ZFLAGS' "$scan_dir/rendered-helm.yaml" )" -eq 5 test "$( grep -c 'value: "+Q 65536"' "$scan_dir/rendered-helm.yaml" )" -eq 5 +test "$( + grep -c 'name: UNISENDER_GO_SKIP_UNSUBSCRIBE' "$scan_dir/rendered-helm.yaml" +)" -eq 5 +test "$( + grep -c 'name: UNISENDER_GO_SKIP_UNSUBSCRIBE' \ + "$scan_dir/rendered-helm-unisender-override.yaml" +)" -eq 5 +test "$( + grep -A1 'name: UNISENDER_GO_SKIP_UNSUBSCRIBE' \ + "$scan_dir/rendered-helm-unisender-override.yaml" | + grep -c 'value: "true"' +)" -eq 5 test "$( grep -c '^kind: NetworkPolicy$' "$scan_dir/rendered-helm.yaml" )" -eq 1