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

Function printBanner

scripts/develop/main.go:1323–1401  ·  view source on GitHub ↗
(ctx context.Context, logger slog.Logger, cfg *devConfig, prometheusServerStarted bool)

Source from the content-addressed store, hash-verified

1321}
1322
1323func printBanner(ctx context.Context, logger slog.Logger, cfg *devConfig, prometheusServerStarted bool) {
1324 ifaces := []string{"localhost"}
1325 if addrs, err := net.InterfaceAddrs(); err == nil {
1326 for _, addr := range addrs {
1327 if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() && ipnet.IP.To4() != nil {
1328 ifaces = append(ifaces, ipnet.IP.String())
1329 }
1330 }
1331 }
1332 if os.Getenv("CODER") == "true" {
1333 // Inside a workspace, add Coder Desktop entry.
1334 ifaces = append(ifaces, fmt.Sprintf("%s.%s.me.coder", os.Getenv("CODER_WORKSPACE_AGENT_NAME"), os.Getenv("CODER_WORKSPACE_NAME")))
1335 ifaces = append(ifaces, fmt.Sprintf("%s.%s.%s.coder", os.Getenv("CODER_WORKSPACE_AGENT_NAME"), os.Getenv("CODER_WORKSPACE_NAME"), os.Getenv("CODER_WORKSPACE_OWNER_NAME")))
1336 }
1337 var b strings.Builder
1338 w := 64
1339 line := func(content ...string) {
1340 for _, c := range content {
1341 _, _ = fmt.Fprintf(&b, "║ %-*s ║\n", w, c)
1342 }
1343 }
1344 indent := func(s string) string {
1345 return " " + s
1346 }
1347 divider := "╔" + strings.Repeat("═", w+2) + "╗"
1348 bottom := "╚" + strings.Repeat("═", w+2) + "╝"
1349
1350 _, _ = fmt.Fprintln(&b)
1351 _, _ = fmt.Fprintln(&b, divider)
1352 line(
1353 "",
1354 indent("Coder is now running in development mode."),
1355 "",
1356 "Effective ports:",
1357 indent(portBannerLine("API", cfg.apiPort, cfg.apiPortSource, cfg.portOffset)),
1358 indent(portBannerLine("Web UI", cfg.webPort, cfg.webPortSource, cfg.portOffset)),
1359 indent(portBannerLine("Proxy", cfg.proxyPort, cfg.proxyPortSource, cfg.portOffset)),
1360 indent(portBannerLine("Coder metrics", cfg.coderMetricsPort, cfg.metricsPortSource, cfg.portOffset)),
1361 "",
1362 "API:",
1363 )
1364
1365 for _, h := range ifaces {
1366 line(indent(fmt.Sprintf("http://%s:%d", h, cfg.apiPort)))
1367 }
1368 line(
1369 "",
1370 "Web UI:",
1371 )
1372 for _, h := range ifaces {
1373 line(indent(fmt.Sprintf("http://%s:%d", h, cfg.webPort)))
1374 }
1375 if cfg.useProxy {
1376 line(
1377 "",
1378 "Proxy:",
1379 )
1380 for _, h := range ifaces {

Callers 1

developFunction · 0.85

Calls 4

portBannerLineFunction · 0.85
prometheusBannerEntryFunction · 0.85
StringMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected