Skip to content

Commit

Permalink
handle corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
osamamagdy committed Sep 15, 2024
1 parent 8a27630 commit d39e5e3
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions samples/deployment/test-network/update-external-connection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,25 @@ for org in "${orgs[@]}"; do

# Copy the file from the connection profile
cp "${CONNECTIONS_PATH}" "${EXTERNAL_CONNECTIONS_PATH}"

backup "${EXTERNAL_CONNECTIONS_PATH}"

# edit localhost urls to use hostnames
## At the root level


# This is needed in both files
yq eval ".\"peer0.org1.example.com\".url = \"grpcs://peer0.org1.example.com:7051\"" -i "$EXTERNAL_CONNECTIONS_PATH"
yq eval ".\"peer0.org2.example.com\".url = \"grpcs://peer0.org2.example.com:9051\"" -i "$EXTERNAL_CONNECTIONS_PATH"

## At the peers level
yq eval ".peers.\"peer0.org1.example.com\".url = \"grpcs://peer0.org1.example.com:7051\"" -i "$EXTERNAL_CONNECTIONS_PATH"
yq eval ".peers.\"peer0.org2.example.com\".url = \"grpcs://peer0.org2.example.com:9051\"" -i "$EXTERNAL_CONNECTIONS_PATH"

## At the CA level
yq eval ".certificateAuthorities.\"ca.org1.example.com\".url = \"https://ca.org1.example.com:7054\"" -i "$EXTERNAL_CONNECTIONS_PATH"
yq eval ".certificateAuthorities.\"ca.org2.example.com\".url = \"https://ca.org2.example.com:8054\"" -i "$EXTERNAL_CONNECTIONS_PATH"





# Check if the org is org1
if [[ "$org" == "org1" ]]; then
# edit localhost urls to use hostnames for org1
yq eval ".peers.\"peer0.org1.example.com\".url = \"grpcs://peer0.org1.example.com:7051\"" -i "$EXTERNAL_CONNECTIONS_PATH"
yq eval ".certificateAuthorities.\"ca.org1.example.com\".url = \"https://ca.org1.example.com:7054\"" -i "$EXTERNAL_CONNECTIONS_PATH"

# Check if the org is org2
elif [[ "$org" == "org2" ]]; then
# edit localhost urls to use hostnames for org2
yq eval ".peers.\"peer0.org2.example.com\".url = \"grpcs://peer0.org2.example.com:9051\"" -i "$EXTERNAL_CONNECTIONS_PATH"
yq eval ".certificateAuthorities.\"ca.org2.example.com\".url = \"https://ca.org2.example.com:8054\"" -i "$EXTERNAL_CONNECTIONS_PATH"
fi
# remove entity matcher
yq eval 'del(.entityMatchers)' -i "$EXTERNAL_CONNECTIONS_PATH"

Expand Down

0 comments on commit d39e5e3

Please sign in to comment.