diff --git a/src/mojafos/configurationManager/config.sh b/src/mojafos/configurationManager/config.sh index ad18aaf..db35517 100755 --- a/src/mojafos/configurationManager/config.sh +++ b/src/mojafos/configurationManager/config.sh @@ -8,11 +8,11 @@ APPS_DIR="$BASE_DIR/src/mojafos/deployer/apps/" INFRA_NAMESPACE="infra" INFRA_RELEASE_NAME="mojafos-infra" #mojaloop -MOJALOOPBRANCH="alpha-1.1" +MOJALOOPBRANCH="beta1" MOJALOOPREPO_DIR="mojaloop" MOJALOOP_NAMESPACE="mojaloop" MOJALOOP_REPO_LINK="https://github.com/mojaloop/platform-shared-tools.git" -MOJALOOP_LAYER_DIRS=("$BASE_DIR/src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/crosscut" "$BASE_DIR/src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/ttk" "$BASE_DIR/src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps") +MOJALOOP_LAYER_DIRS=("$BASE_DIR/src/mojafos/deployer/apps/mojaloop/packages/installer/manifests/crosscut" "$BASE_DIR/src/mojafos/deployer/apps/mojaloop/packages/installer/manifests/ttk" "$BASE_DIR/src/mojafos/deployer/apps/mojaloop/packages/installer/manifests/apps" "$BASE_DIR/src/mojafos/deployer/apps/mojaloop/packages/installer/manifests/reporting") MOJALOOP_VALUES_FILE="$BASE_DIR/src/mojafos/configurationManager/mojaloop_values.json" #paymenthubee PHBRANCH="v1.2.0-release" @@ -54,98 +54,57 @@ FIN_VALUES_FILE="$BASE_DIR/src/mojafos/deployer/fin_values.yaml" ######################################################################## # FUNCTIONS FOR CONFIGURATION MANAGEMENT ######################################################################## -function replaceValuesInFile() { - local file="$1" - local old_value="$2" - local new_value="$3" - - # Check if sed is available, if not, exit with an error message - if ! command -v sed &>/dev/null; then - echo "Error: 'sed' is not available. Please make sure it's installed on your system." - return 1 - fi - - # Print debugging information - printf "\rUpdating file: $file" - printf "\rOld value: $old_value" - printf "\rNew value: $new_value" - - # Use sed to update the YAML file with the new value - if sed -i "s/$old_value/$new_value/" "$file"; then - printf "\rValue updated successfully." - return 0 - else - echo "Error updating the value." - return 1 - fi -} - -function renameOffToYaml() { - local folder="$1" - local previous_dir="$PWD" # Save the current working directory - - # Check if the folder exists - if [ ! -d "$folder" ]; then - echo "Error: The specified folder does not exist." - return 1 - fi - - # Navigate to the folder - cd "$folder" || return 1 - - # Rename all .off files to .yaml - for file in *.off; do - if [ -e "$file" ]; then - new_name="${file%.off}.yaml" # Remove .off and add .yaml - mv "$file" "$new_name" - echo "Renamed: $file -> $new_name" +function replaceValuesInFiles() { + local directories=("$@") + local json_file="$MOJALOOP_VALUES_FILE" + + # Check if jq is installed, if not, exit with an error message + if ! command -v jq &>/dev/null; then + echo "Error: 'jq' is not installed. Please install it (https://stedolan.github.io/jq/) and make sure it's in your PATH." + return 1 fi - done - # Return to the previous working directory - cd "$previous_dir" || return 1 + # Check if the JSON file exists + if [ ! -f "$json_file" ]; then + echo "Error: JSON file '$json_file' does not exist." + return 1 + fi - echo "Renaming completed." + # Read the JSON file and create an associative array + declare -A replacements + while IFS= read -r json_object; do + local old_value new_value + old_value=$(echo "$json_object" | jq -r '.old_value') + new_value=$(echo "$json_object" | jq -r '.new_value') + replacements["$old_value"]="$new_value" + done < <(jq -c '.[]' "$json_file") + + # Loop through the directories and process each file + for dir in "${directories[@]}"; do + if [ -d "$dir" ]; then + find "$dir" -type f | while read -r file; do + local changed=false + for old_value in "${!replacements[@]}"; do + if grep -q "$old_value" "$file"; then + sed -i "s|$old_value|${replacements[$old_value]}|g" "$file" + changed=true + fi + done + if $changed; then + echo "Updated: $file" + fi + done + else + echo "Directory $dir does not exist." + fi + done } function configureMojaloop() { - echo -e "${BLUE}Configuring Mojaloop Manifests ${RESET}" - local json_file=$MOJALOOP_VALUES_FILE - - # Check if jq is installed, if not, exit with an error message - if ! command -v jq &>/dev/null; then - echo "Error: 'jq' is not installed. Please install it (https://stedolan.github.io/jq/) and make sure it's in your PATH." - return 1 - fi - - # Check if the JSON file exists - if [ ! -f "$json_file" ]; then - echo "Error: JSON file '$json_file' does not exist." - return 1 - fi - - # Loop over JSON objects in the file and call the process_json_object function - jq -c '.[]' "$json_file" | while read -r json_object; do - local file_name - local old_value - local new_value - - # Extract attributes from the JSON object - file_name=$(echo "$json_object" | jq -r '.file_name') - old_value=$(echo "$json_object" | jq -r '.old_value') - new_value=$(echo "$json_object" | jq -r ".new_value") - - # Call the function with the extracted attributes - replaceValuesInFile "$file_name" "$old_value" "$new_value" - done - - if [ $? -eq 0 ]; then - echo -e "\n==> Mojaloop Manifests edited successfully" - else - echo -e "${RED}Mojaloop Manifests were not edited successfully${RESET}" - fi + replaceValuesInFiles "${MOJALOOP_LAYER_DIRS[0]}" "${MOJALOOP_LAYER_DIRS[2]}" "${MOJALOOP_LAYER_DIRS[3]}" } + function createSecret(){ local namespace="$1" echo -e "Creating secrets in the $namespace namespace" diff --git a/src/mojafos/configurationManager/mojaloop_values.json b/src/mojafos/configurationManager/mojaloop_values.json index 4391b8d..fff606d 100644 --- a/src/mojafos/configurationManager/mojaloop_values.json +++ b/src/mojafos/configurationManager/mojaloop_values.json @@ -1,162 +1,18 @@ [ { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/fspiop-api-svc-deployment.yaml", "old_value": "value: kafka:9092", "new_value": "value: kafka.infra.svc.cluster.local:9092" }, { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/fspiop-api-svc-deployment.yaml", "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" }, { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/account-lookup-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/account-lookup-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/quoting-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/quoting-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/settlements-api-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/settlements-api-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/settlements-api-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/crosscut/platform-configuration-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/crosscut/authorization-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/transfers-event-handler-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/crosscut/authentication-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/transfers-command-handler-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/transfers-command-handler-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/settlements-command-handler-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/settlements-command-handler-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/transfers-api-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/transfers-api-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/accounts-and-balances-coa-grpc-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/accounts-and-balances-coa-grpc-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/accounts-and-balances-coa-grpc-svc-deployment.yaml", - "old_value": "value: redis-master", - "new_value": "value: redis-master.infra.svc.cluster.local" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/accounts-and-balances-builtin-ledger-grpc-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/settlements-event-handler-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/participants-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/participants-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/accounts-and-balances-builtin-ledger-grpc-svc-deployment.yaml", - "old_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb:27017\\/", - "new_value": "value: mongodb:\\/\\/root:mongoDbPas42@mongodb.infra.svc.cluster.local:27017\\/" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/apps/accounts-and-balances-builtin-ledger-grpc-svc-deployment.yaml", "old_value": "value: redis-master", "new_value": "value: redis-master.infra.svc.cluster.local" }, { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/crosscut/auditing-svc-deployment.yaml", - "old_value": "value: http:\\/\\/infra-elasticsearch:9200", - "new_value": "value: http:\\/\\/mojafos-infra-elasticsearch.infra.svc.cluster.local:9200" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/crosscut/auditing-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/crosscut/logging-svc-deployment.yaml", "old_value": "value: http:\\/\\/infra-elasticsearch:9200", "new_value": "value: http:\\/\\/mojafos-infra-elasticsearch.infra.svc.cluster.local:9200" - }, - { - "file_name": "src/mojafos/deployer/apps/mojaloop/packages/deployment/k8s/crosscut/logging-svc-deployment.yaml", - "old_value": "value: kafka:9092", - "new_value": "value: kafka.infra.svc.cluster.local:9092" } ] diff --git a/src/mojafos/deployer/deployer.sh b/src/mojafos/deployer/deployer.sh index b739db7..630af21 100755 --- a/src/mojafos/deployer/deployer.sh +++ b/src/mojafos/deployer/deployer.sh @@ -348,7 +348,7 @@ function deployMojaloop() { echo cloneRepo "$MOJALOOPBRANCH" "$MOJALOOP_REPO_LINK" "$APPS_DIR" "$MOJALOOPREPO_DIR" echo - renameOffToYaml "${MOJALOOP_LAYER_DIRS[0]}" + # renameOffToYaml "${MOJALOOP_LAYER_DIRS[0]}" echo configureMojaloop diff --git a/src/mojafos/deployer/helm/infra/values.yaml b/src/mojafos/deployer/helm/infra/values.yaml index ba37812..11d0bfd 100644 --- a/src/mojafos/deployer/helm/infra/values.yaml +++ b/src/mojafos/deployer/helm/infra/values.yaml @@ -59,6 +59,21 @@ kafka: value: SettlementsBcCommands - name: PlatformConfigurationBcEvents value: PlatformConfigurationBcEvents + - name: TransfersBcTimeouts + value: TransfersBcTimeouts + - name: ParticipantsBcEvents + value: ParticipantsBcEvents + - name: SchedulingBcCommands + value: SchedulingBcCommands + - name: SchedulingBcEvents + value: SchedulingBcEvents + - name: SecurityBcAuthorizationEvents + value: SecurityBcAuthorizationEvents + - name: SecurityBcEvents + value: SecurityBcEvents + + + nodeSelector: {} tolerations: []