From 10ccd0c2d7ab911c8efef1d348757dd1cf02af7d Mon Sep 17 00:00:00 2001 From: Sofiane A Date: Tue, 29 Apr 2025 19:34:52 +0200 Subject: [PATCH] Correct logic for default site condition --- pkg/inputunifi/collector.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/inputunifi/collector.go b/pkg/inputunifi/collector.go index b708fede..8b74a4fe 100644 --- a/pkg/inputunifi/collector.go +++ b/pkg/inputunifi/collector.go @@ -280,11 +280,9 @@ func (u *InputUnifi) getFilteredSites(c *Controller) ([]*unifi.Site, error) { return nil, fmt.Errorf("controller: %w", err) } - // Apply the default_site_name_override if the site is marked as default. - for _, site := range sites { - if site.IsDefaultSite && c.DefaultSiteNameOverride != "" { - site.Name = c.DefaultSiteNameOverride - } + // Apply the default_site_name_override to the first site in the list, if configured. + if len(sites) > 0 && c.DefaultSiteNameOverride != "" { + sites[0].Name = c.DefaultSiteNameOverride } if len(c.Sites) == 0 || StringInSlice("all", c.Sites) {