From e2ebf9973bec9884154093d6bd7a9688261e6fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Catarino?= Date: Sat, 19 Mar 2022 13:52:41 +0100 Subject: [PATCH] select environments --- docs/customservices.md | 4 ++++ src/components/services/Portainer.vue | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/docs/customservices.md b/docs/customservices.md index cb68e1d..2e65f19 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -131,6 +131,7 @@ For Prometheus you need to set the type to Prometheus and provide a url. This service displays info about the total number of containers managed by your Portainer instance. In order to use it, you must be using Portainer version 1.11 or later. Generate an access token from the UI and pass it to the apikey field. +By default, every connected environments will be checked. To select specific ones,add an "environments" entry which can be a simple string or an array containing all the selected environments name. See https://docs.portainer.io/v/ce-2.11/user/account-settings#access-tokens @@ -140,4 +141,7 @@ See https://docs.portainer.io/v/ce-2.11/user/account-settings#access-tokens url: "http://192.168.0.151/" type: "Portainer" apikey: "MY-SUPER-SECRET-API-KEY" + # environments: + # - "raspberry" + # - "local" ``` diff --git a/src/components/services/Portainer.vue b/src/components/services/Portainer.vue index c7e9962..2e0d1e2 100644 --- a/src/components/services/Portainer.vue +++ b/src/components/services/Portainer.vue @@ -83,6 +83,12 @@ export default { let containers = []; for (let endpoint of this.endpoints) { + if ( + this.item.environments && + !this.item.environments.includes(endpoint.Name) + ) { + continue; + } const uri = `/api/endpoints/${endpoint.Id}/docker/containers/json?all=1`; const endpointContainers = await this.fetch(uri, { headers }).catch( (e) => {