(dbApp database.WorkspaceApp, agentName, workspaceName, ownerName string)
| 639 | } |
| 640 | |
| 641 | func 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 | |
| 669 | func 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 { |
no test coverage detected