Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PortForwardCmd = &cobra.Command{ Use: "forward [PORT] [WORKSPACE] [PROJECT]", Short: "Forward a port from a project to your local machine", Args: cobra.RangeArgs(2, 3), Run: func(cmd *cobra.Command, args []string) { port, err := strconv.Atoi(args[0]) if err != nil { log.Fatal(err) } workspace, err := apiclient.GetWorkspace(args[1]) if err != nil { log.Fatal(err) } workspaceId = *workspace.Id if len(args) == 3 { projectName = args[2] } else { projectName, err = apiclient.GetFirstWorkspaceProjectName(workspaceId, projectName, nil) if err != nil { log.Fatal(err) } } hostPort, errChan := tailscale.ForwardPort(workspaceId, projectName, uint16(port)) if hostPort == nil { if err = <-errChan; err != nil { log.Fatal(err) } } else { if *hostPort != uint16(port) { views.RenderInfoMessage(fmt.Sprintf("Port %d already in use.", port)) } views.RenderInfoMessage(fmt.Sprintf("Port available at http://localhost:%d\n", *hostPort)) } if publicPreview { go func() { errChan <- ForwardPublicPort(workspaceId, projectName, *hostPort, uint16(port)) }() } for { err := <-errChan if err != nil { log.Debug(err) } } }, }
Functions ¶
func ForwardPublicPort ¶ added in v0.15.0
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.