Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Add script to automate RS org settings updates for local testing (#1489)
Browse files Browse the repository at this point in the history
* Added script to automate updating RS org settings for local testing

* Replaced step in RS setup with script

* Extracted relative path into variable

* Added documentation for script

* Added check for yq tool in the script
basiliskus authored Oct 28, 2024
1 parent f1058b3 commit 2b1b01d
Showing 2 changed files with 52 additions and 6 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -347,12 +347,10 @@ with this option enabled.
4. Run the `./cleanslate` script. For more information you can refer to the [ReportStream docs](https://github.com/CDCgov/prime-reportstream/blob/master/prime-router/docs/docs-deprecated/getting-started/getting-started.md#building-the-baseline)
5. If attempting to access the metadata endpoint in ReportStream add the variable `ETOR_TI_baseurl="http://host.docker.internal:8080"` to `.prime-router/.vault/env/.env.local` file before building the container
6. Run RS with `docker compose up --build -d`
7. Edit `/settings/STLTs/Flexion/flexion.yml` to comment the lines related to staging settings, and uncomment the ones for local settings:
- `authTokenUrl`, `reportUrl`, `authHeaders.host` under REST `transport` in `receivers`
- `type` and `credentialName` under SFTP `transport` in `receivers`
8. Run the `./reset.sh` script to reset the database
9. Run the `./load-etor-org-settings.sh` to apply the ETOR organization settings
10. Run the `./setup-local-vault.sh` script to set up the local vault secrets
7. Run the `reset.sh` script to reset the database
8. Run the `update_org_yaml.sh` script to update the RS organization settings
9. Run the `load-etor-org-settings.sh` to apply the ETOR organization settings
10. Run the `setup-local-vault.sh` script to set up the local vault secrets
- You can verify that the script created the secrets successfully by going to `http://localhost:8200/` in your browser, use the token in `prime-router/.vault/env/.env.local` to authenticate, and then go to `Secrets engines` > `secret/` to check the available secrets

#### Submit request to ReportStream
48 changes: 48 additions & 0 deletions scripts/rs/update_org_yaml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

source "$CDCTI_HOME/scripts/hurl/utils.sh"

# This script updates the organization settings YAML files in RS to:
# - use local REST transport settings for Flexion's etor-service-receiver receivers
# - use local SFTP transport settings for Flexion's simulated-hospital and simulated-lab receivers
# - use local SFTP transport settings for partner organizations

# Requirements:
# - yq (https://github.com/mikefarah/yq)
# - This script should run inside the prime-router directory of the prime-reportstream codebase

ORG_SETTINGS_DIR="settings/STLTs"

check_installed_commands yq

echo "Updating transport in Flexion org settings file..."
yq eval '.[0].receivers[] |= (
select(.name == "simulated-hospital" or .name == "simulated-lab").transport = {
"type": "SFTP",
"host": "sftp",
"port": 22,
"filePath": "./upload",
"credentialName": "DEFAULT-SFTP"
} |
select(.name == "etor-service-receiver-orders") |= (
.transport.authTokenUrl = "http://host.docker.internal:8080/v1/auth/token" |
.transport.reportUrl = "http://host.docker.internal:8080/v1/etor/orders"
) |
select(.name == "etor-service-receiver-results") |= (
.transport.authTokenUrl = "http://host.docker.internal:8080/v1/auth/token" |
.transport.reportUrl = "http://host.docker.internal:8080/v1/etor/results"
)
)' -i "$ORG_SETTINGS_DIR/Flexion/flexion.yml"

echo "Updating transport in partner org settings files..."
for file in "$ORG_SETTINGS_DIR/CA/ucsd.yml" "$ORG_SETTINGS_DIR/LA/la-ochsner.yml" "$ORG_SETTINGS_DIR/LA/la-phl.yml"; do
yq eval '.[0].receivers[] |= select(.name == "etor-nbs-results" or .name == "etor-nbs-orders").transport = {
"type": "SFTP",
"host": "sftp",
"port": 22,
"filePath": "./upload",
"credentialName": "DEFAULT-SFTP"
}' -i "$file"
done

echo "Updates completed."

0 comments on commit 2b1b01d

Please sign in to comment.