Skip to content

Commit

Permalink
Handle @ sign in user suffixes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
John Wregglesworth committed Jun 12, 2024
1 parent d05b595 commit 5de586b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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())
Expand All @@ -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) {
Expand Down

0 comments on commit 5de586b

Please sign in to comment.