Fetching data from registries

This commit is contained in:
Mishalabdullah
2024-05-26 05:43:52 +05:30
parent 9bbe63d0b1
commit 1fa30b6a8b

View File

@@ -163,11 +163,44 @@ install_bpp_protocol_server(){
} }
mergingNetworks(){ mergingNetworks(){
# Now need implement the logic where registry A gets merged to registry B
# And also registry B & registry A gets merged into a super registry
echo -e "1. Merge Two Different Registries \n2. Merge Multiple Registries into a Super Registry" echo -e "1. Merge Two Different Registries \n2. Merge Multiple Registries into a Super Registry"
read -p "Enter your choice: " merging_network read -p "Enter your choice: " merging_network
if [[ $merging_network == 1 ]]; then if [[ $merging_network == 1 ]]; then
echo "Merging Registry A to Registry B"
read -p "Enter Registry A URL: " registry_a_url
read -p "Enter Registry B URL: " registry_b_url
response1=$(curl -s -H 'ACCEPT: application/json' -H 'CONTENT-TYPE: application/json' "$registry_a_url" -d '{}')
response2=$(curl -s -H 'ACCEPT: application/json' -H 'CONTENT-TYPE: application/json' "$registry_b_url" -d '{}')
combined_response="${response1}${response2}"
echo "$combined_response"
# Need to to know how to send data to registry B , facing issues in authorization
echo "Merging Two Different Registries" echo "Merging Two Different Registries"
elif [[ $merging_network == 2 ]]; then elif [[ $merging_network == 2 ]]; then
urls=()
while true; do
read -p "Enter registry URL (or 'N' to stop): " url
if [[ $url == 'N' ]]; then
break
else
urls+=("$url")
fi
done
if [[ ${#urls[@]} -gt 0 ]]; then
echo "Entered registry URLs:"
all_responses=""
for url in "${urls[@]}"; do
response=$(curl -s -H 'ACCEPT: application/json' -H 'CONTENT-TYPE: application/json' "$url/subscribers/lookup" -d '{}')
all_responses+="$response"
echo "$all_responses"
done
echo "$all_responses"
else
echo "No registry URLs entered."
fi
echo "Merging Multiple Registries into a Super Registry" echo "Merging Multiple Registries into a Super Registry"
else else
echo "Invalid option. Please restart the script and select a valid option." echo "Invalid option. Please restart the script and select a valid option."