From a79dac0cf3a40346008b8ad9e6d257d8f74e579f Mon Sep 17 00:00:00 2001 From: VRamakrishna Date: Wed, 8 May 2024 08:15:09 +0000 Subject: [PATCH] Refactored Corda Simple Application Makefile to better handle errors Signed-off-by: VRamakrishna --- .../corda/corda-simple-application/makefile | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/samples/corda/corda-simple-application/makefile b/samples/corda/corda-simple-application/makefile index 3b107455a..81d41b24e 100644 --- a/samples/corda/corda-simple-application/makefile +++ b/samples/corda/corda-simple-application/makefile @@ -52,31 +52,43 @@ test: github.properties .PHONY: initialise-vault initialise-vault: - (docker logs corda_partya_1 && REMOTE_FLOW="localhost:30006#com.cordaSimpleApplication.flow.GetStateByKey:*" ./clients/build/install/clients/bin/clients configure all) || true + if [ $(shell docker ps | grep corda_partya_1 | wc -l) -eq 1 ]; then \ + REMOTE_FLOW="localhost:30006#com.cordaSimpleApplication.flow.GetStateByKey:*" ./clients/build/install/clients/bin/clients configure all; \ + fi if [ $(shell docker ps | grep corda_network2_partya_1 | wc -l) -eq 1 ]; then \ - (docker logs corda_network2_partya_1 && CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 REMOTE_FLOW="localhost:10006#com.cordaSimpleApplication.flow.GetStateByKey:*" ./clients/build/install/clients/bin/clients configure all) || true; \ + CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 REMOTE_FLOW="localhost:10006#com.cordaSimpleApplication.flow.GetStateByKey:*" ./clients/build/install/clients/bin/clients configure all; \ fi .PHONY: initialise-vault-docker initialise-vault-docker: - (docker logs corda_partya_1 && MEMBER_CREDENTIAL_FOLDER="clients/src/main/resources/config/credentials_docker" REMOTE_FLOW="corda_network2_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:*" LOCAL_FLOW="corda_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:*" ./clients/build/install/clients/bin/clients configure all) || true + if [ $(shell docker ps | grep corda_partya_1 | wc -l) -eq 1 ]; then \ + MEMBER_CREDENTIAL_FOLDER="clients/src/main/resources/config/credentials_docker" REMOTE_FLOW="corda_network2_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:*" LOCAL_FLOW="corda_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:*" ./clients/build/install/clients/bin/clients configure all; \ + fi if [ $(shell docker ps | grep corda_network2_partya_1 | wc -l) -eq 1 ]; then \ - (docker logs corda_network2_partya_1 && CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 MEMBER_CREDENTIAL_FOLDER="clients/src/main/resources/config/credentials_docker" REMOTE_FLOW="corda_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:*" LOCAL_FLOW="corda_network2_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:*" ./clients/build/install/clients/bin/clients configure all) || true; \ + CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 MEMBER_CREDENTIAL_FOLDER="clients/src/main/resources/config/credentials_docker" REMOTE_FLOW="corda_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:*" LOCAL_FLOW="corda_network2_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:*" ./clients/build/install/clients/bin/clients configure all; \ fi .PHONY: initialise-vault-asset-transfer initialise-vault-asset-transfer: - (docker logs corda_partya_1 && ./clients/build/install/clients/bin/clients configure network) || true - (docker logs corda_partya_1 && ./clients/build/install/clients/bin/clients network-id create-state -m "O=PartyA, L=London, C=GB;O=PartyB, L=London, C=GB") || true - (docker logs corda_network2_partya_1 && CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 ./clients/build/install/clients/bin/clients configure network) || true - (docker logs corda_network2_partya_1 && CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 ./clients/build/install/clients/bin/clients network-id create-state -m "O=PartyA, L=London, C=GB;O=PartyB, L=London, C=GB") || true + if [ $(shell docker ps | grep corda_partya_1 | wc -l) -eq 1 ]; then \ + ./clients/build/install/clients/bin/clients configure network; \ + ./clients/build/install/clients/bin/clients network-id create-state -m "O=PartyA, L=London, C=GB;O=PartyB, L=London, C=GB"; \ + fi + if [ $(shell docker ps | grep corda_network2_partya_1 | wc -l) -eq 1 ]; then \ + CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 ./clients/build/install/clients/bin/clients configure network; \ + CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 ./clients/build/install/clients/bin/clients network-id create-state -m "O=PartyA, L=London, C=GB;O=PartyB, L=London, C=GB"; \ + fi .PHONY: initialise-vault-asset-transfer-docker initialise-vault-asset-transfer-docker: - (docker logs corda_partya_1 && MEMBER_CREDENTIAL_FOLDER="clients/src/main/resources/config/credentials_docker" ./clients/build/install/clients/bin/clients configure network) || true - (docker logs corda_partya_1 && ./clients/build/install/clients/bin/clients network-id create-state -m "O=PartyA, L=London, C=GB;O=PartyB, L=London, C=GB") || true - (docker logs corda_network2_partya_1 && MEMBER_CREDENTIAL_FOLDER="clients/src/main/resources/config/credentials_docker" CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 ./clients/build/install/clients/bin/clients configure network) || true - (docker logs corda_network2_partya_1 && CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 ./clients/build/install/clients/bin/clients network-id create-state -m "O=PartyA, L=London, C=GB;O=PartyB, L=London, C=GB") || true + if [ $(shell docker ps | grep corda_partya_1 | wc -l) -eq 1 ]; then \ + MEMBER_CREDENTIAL_FOLDER="clients/src/main/resources/config/credentials_docker" ./clients/build/install/clients/bin/clients configure network; \ + ./clients/build/install/clients/bin/clients network-id create-state -m "O=PartyA, L=London, C=GB;O=PartyB, L=London, C=GB"; \ + fi + if [ $(shell docker ps | grep corda_network2_partya_1 | wc -l) -eq 1 ]; then \ + MEMBER_CREDENTIAL_FOLDER="clients/src/main/resources/config/credentials_docker" CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 ./clients/build/install/clients/bin/clients configure network; \ + CORDA_PORT=30006 NETWORK_NAME=Corda_Network2 ./clients/build/install/clients/bin/clients network-id create-state -m "O=PartyA, L=London, C=GB;O=PartyB, L=London, C=GB"; \ + fi .PHONY: get-access-control-policies get-access-control-policies: