From 501ff6faf39bfc349d291cf31aa307c682bd5e7d Mon Sep 17 00:00:00 2001 From: Markus Blaschke Date: Mon, 4 Sep 2023 23:05:11 +0200 Subject: [PATCH] allow spaces for AZURE_SERVICEDISCOVERY_SUBSCRIPTION_ID Signed-off-by: Markus Blaschke --- azuresdk/README.md | 2 +- azuresdk/armclient/client.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/azuresdk/README.md b/azuresdk/README.md index b19dbf5..904cc75 100644 --- a/azuresdk/README.md +++ b/azuresdk/README.md @@ -7,7 +7,7 @@ | Variable name | Default | Description | |----------------------------------------------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `AZURE_SERVICEDISCOVERY_CACHE_TTL` | `60m` (time.Duration) | ServiceDiscovery cache (eg. subscription, resourceGroup list,...) | -| `AZURE_SERVICEDISCOVERY_SUBSCRIPTION_ID` | | Subscription IDs separated by commas (whitespaces are trimmed) | +| `AZURE_SERVICEDISCOVERY_SUBSCRIPTION_ID` | | Subscription IDs separated by commas or spaces (whitespaces are trimmed) | | `AZURE_SERVICEDISCOVERY_SUBSCRIPTION_TAG_SELECTOR` | | Tag selector `tagName=tagValue,tagName2=tagValue2` to filter subscriptions for ServiceDiscovery (uses [kubernetes label selector library](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors)) | ### Authentication diff --git a/azuresdk/armclient/client.go b/azuresdk/armclient/client.go index 3c6aa57..92cf6ee 100644 --- a/azuresdk/armclient/client.go +++ b/azuresdk/armclient/client.go @@ -106,6 +106,9 @@ func (azureClient *ArmClient) initServiceDiscovery() { // use fixed list of subscription ids if val := os.Getenv(EnvVarServiceDiscoverySubscriptionId); val != "" { azureClient.serviceDiscovery.subscriptionIds = []string{} + // replace spaces with commas, + // we should be able to use both for easier usage in yaml files + val = strings.ReplaceAll(val, " ", ",") for _, subscriptionId := range strings.Split(val, ",") { subscriptionId = strings.TrimSpace(subscriptionId) if subscriptionId != "" {