MCPcopy Index your code
hub / github.com/coder/coder / AppSubdomain

Function AppSubdomain

coderd/database/db2sdk/db2sdk.go:641–667  ·  view source on GitHub ↗
(dbApp database.WorkspaceApp, agentName, workspaceName, ownerName string)

Source from the content-addressed store, hash-verified

639}
640
641func AppSubdomain(dbApp database.WorkspaceApp, agentName, workspaceName, ownerName string) string {
642 if !dbApp.Subdomain || agentName == "" || ownerName == "" || workspaceName == "" {
643 return ""
644 }
645
646 appSlug := dbApp.Slug
647 if appSlug == "" {
648 appSlug = dbApp.DisplayName
649 }
650
651 // Agent name is optional when app slug is present
652 normalizedAgentName := agentName
653 if !appurl.PortRegex.MatchString(appSlug) {
654 normalizedAgentName = ""
655 }
656
657 return appurl.ApplicationURL{
658 // We never generate URLs with a prefix. We only allow prefixes when
659 // parsing URLs from the hostname. Users that want this feature can
660 // write out their own URLs.
661 Prefix: "",
662 AppSlugOrPort: appSlug,
663 AgentName: normalizedAgentName,
664 WorkspaceName: workspaceName,
665 Username: ownerName,
666 }.String()
667}
668
669func Apps(dbApps []database.WorkspaceApp, statuses []database.WorkspaceAppStatus, agent database.WorkspaceAgent, ownerName string, workspace database.WorkspaceTable) []codersdk.WorkspaceApp {
670 sort.Slice(dbApps, func(i, j int) bool {

Callers 2

dbAppToProtoFunction · 0.92
AppsFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected