Skip to content

Commit

Permalink
Use homegrown map to slice converter
Browse files Browse the repository at this point in the history
  • Loading branch information
CannonLock committed Nov 14, 2024
1 parent 364ec45 commit 6062afe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion director/director_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"github.com/pelicanplatform/pelican/param"
"github.com/pelicanplatform/pelican/server_structs"
"github.com/pelicanplatform/pelican/utils"
"github.com/pelicanplatform/pelican/web_ui"
)

Expand Down Expand Up @@ -362,7 +363,7 @@ func listNamespaceResponses() []NamespaceAdV2MappedResponse {
}
}

return maps.Values(namespaceMap)
return utils.MapToSlice(namespaceMap)
}

// Get list of all namespaces
Expand Down
9 changes: 9 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,12 @@ func ExtractProjectFromUserAgent(userAgents []string) string {

return ""
}

// Convert map to slice of values
func MapToSlice[K comparable, V any](m map[K]V) []V {
s := make([]V, 0, len(m))
for _, v := range m {
s = append(s, v)
}
return s
}

0 comments on commit 6062afe

Please sign in to comment.