From 5de586bb1aa29bc9b6e8e372a8273f7aee0ee907 Mon Sep 17 00:00:00 2001 From: John Wregglesworth Date: Wed, 12 Jun 2024 14:07:24 -0700 Subject: [PATCH] Handle @ sign in user suffixes correctly --- internal/reporting.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/reporting.go b/internal/reporting.go index 622f35f..5810bab 100644 --- a/internal/reporting.go +++ b/internal/reporting.go @@ -262,7 +262,7 @@ type ServiceInfoPort struct { Protocol string `json:"protocol"` } -//ServiceInfo contains info about a service +// ServiceInfo contains info about a service type ServiceInfo struct { MetaInfo Ports []ServiceInfoPort `json:"ports"` @@ -473,7 +473,7 @@ func (i *Internal) getFilteredIngresses(ctx context.Context, filter map[string]s return ingresses, nil } -//FilterableIngressesHandler lists ingresses in use by VICE apps. +// FilterableIngressesHandler lists ingresses in use by VICE apps. func (i *Internal) FilterableIngressesHandler(c echo.Context) error { ctx := c.Request().Context() filter := filterMap(c.Request().URL.Query()) @@ -499,10 +499,16 @@ type ResourceInfo struct { } func (i *Internal) fixUsername(username string) string { - if strings.HasSuffix(username, i.UserSuffix) { + var userSuffix string + if strings.HasPrefix("@", i.UserSuffix) { + userSuffix = i.UserSuffix + } else { + userSuffix = fmt.Sprintf("@%s", i.UserSuffix) + } + if strings.HasSuffix(username, userSuffix) { return username } - return fmt.Sprintf("%s%s", username, i.UserSuffix) + return fmt.Sprintf("%s%s", username, userSuffix) } func (i *Internal) doResourceListing(ctx context.Context, filter map[string]string) (*ResourceInfo, error) {