mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-20 06:35:22 +02:00
refactor(network-service): enhance network addition logic to include default network
- Updated the addDokployNetworkToService function to automatically include the "default" network when adding new networks. - Modified test cases to reflect the new behavior, ensuring no duplicates of the default network are added. - Improved handling of network addition for both arrays and objects.
This commit is contained in:
@@ -330,6 +330,7 @@ export const addDokployNetworkToService = (
|
||||
) => {
|
||||
let networks = networkService;
|
||||
const network = "dokploy-network";
|
||||
const defaultNetwork = "default";
|
||||
if (!networks) {
|
||||
networks = [];
|
||||
}
|
||||
@@ -338,10 +339,16 @@ export const addDokployNetworkToService = (
|
||||
if (!networks.includes(network)) {
|
||||
networks.push(network);
|
||||
}
|
||||
if (!networks.includes(defaultNetwork)) {
|
||||
networks.push(defaultNetwork);
|
||||
}
|
||||
} else if (networks && typeof networks === "object") {
|
||||
if (!(network in networks)) {
|
||||
networks[network] = {};
|
||||
}
|
||||
if (!(defaultNetwork in networks)) {
|
||||
networks[defaultNetwork] = {};
|
||||
}
|
||||
}
|
||||
|
||||
return networks;
|
||||
|
||||
Reference in New Issue
Block a user