Skip to content

Commit

Permalink
add SHOW_NETWORKS option
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenasm committed Sep 23, 2024
1 parent 6d5fb58 commit 74e93a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ List of environment variables for more customization:
| CADVISOR_SERVICE_NAME_REGEX | cadvisor | Use this env to enable `cadvisor` integration. |
| CADVISOR_PORT | 8080 | |
| ENABLE_DATA_API | true | Use this env to export the `/data` API that returns the swarm status as a JSON object. Note that it requires basic-auth if `ENABLE_AUTHENTICATION` is activated. |

| SHOW_NETWORKS | false | `true` by default, set to "false" to remove the network section from the dashboard. |

## Security

Expand Down
21 changes: 12 additions & 9 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const httpsHostname = process.env.HTTPS_HOSTNAME;
const dockerUpdateInterval = parseInt(process.env.DOCKER_UPDATE_INTERVAL || "5000");
const metricsUpdateInterval = parseInt(process.env.METRICS_UPDATE_INTERVAL || "30000");
const showTaskTimestamp = !(process.env.SHOW_TASK_TIMESTAMP === "false");
const showNetworks = !(process.env.SHOW_NETWORKS === "false");
const debugMode = process.env.DEBUG_MODE === "true";
const enableDataAPI = process.env.ENABLE_DATA_API === "true";

Expand Down Expand Up @@ -164,14 +165,16 @@ const parseAndRedactDockerData = data => {
nodes.push(node);
}

for (let i = 0; i < data.networks.length; i++) {
const baseNetwork = data.networks[i];
let network = {
"Id": baseNetwork["Id"],
"Name": baseNetwork["Name"],
"Ingress": baseNetwork["Ingress"],
};
networks.push(network);
if (showNetworks) {
for (let i = 0; i < data.networks.length; i++) {
const baseNetwork = data.networks[i];
let network = {
"Id": baseNetwork["Id"],
"Name": baseNetwork["Name"],
"Ingress": baseNetwork["Ingress"],
};
networks.push(network);
}
}

for (let i = 0; i < data.services.length; i++) {
Expand All @@ -187,7 +190,7 @@ const parseAndRedactDockerData = data => {
},
},
};
if (baseService["Endpoint"] !== undefined) {
if (showNetworks && (baseService["Endpoint"] !== undefined)) {
const _baseVIPs = baseService["Endpoint"]["VirtualIPs"];
if (_baseVIPs !== undefined && Array.isArray(_baseVIPs) && _baseVIPs.length > 0) {
let vips = []
Expand Down

0 comments on commit 74e93a2

Please sign in to comment.