#!/bin/bash

updateDockerNetworkConfig()
{
    local new_subnet="$1"
    
    if [[ -z "$new_subnet" ]]; then
        isNotice "No subnet provided to Update Network Config. Skipping..."
    else
        if checkAppNetworkCompatibility "$new_subnet"; then
            updateConfigOption "CFG_NETWORK_SUBNET" "$new_subnet"
            checkSuccess "Updated network configuration to: $new_subnet"
            CFG_NETWORK_SUBNET="$new_subnet"
            isSuccessful "Network configuration updated successfully."
        else
            isNotice "App network assignments need to be updated for the new subnet."
            updateConfigOption "CFG_NETWORK_SUBNET" "$new_subnet"
            checkSuccess "Updated network configuration to: $new_subnet"
            CFG_NETWORK_SUBNET="$new_subnet"
            isNotice "Note: You may need to reinstall applications to ensure proper network connectivity."
        fi
    fi
}
