MCPcopy Index your code
hub / github.com/cli/cli / getTunnelManager

Function getTunnelManager

internal/codespaces/connection/connection.go:127–143  ·  view source on GitHub ↗

getTunnelManager creates a tunnel manager for the given codespace. The tunnel manager is used to get the tunnel hosted in the codespace that we want to connect to and perform operations on ports (add, remove, list, etc.).

(tunnelProperties api.TunnelProperties, httpClient *http.Client)

Source from the content-addressed store, hash-verified

125// The tunnel manager is used to get the tunnel hosted in the codespace that we
126// want to connect to and perform operations on ports (add, remove, list, etc.).
127func getTunnelManager(tunnelProperties api.TunnelProperties, httpClient *http.Client) (tunnelManager *tunnels.Manager, err error) {
128 userAgent := []tunnels.UserAgent{{Name: clientName}}
129 url, err := url.Parse(tunnelProperties.ServiceUri)
130 if err != nil {
131 return nil, fmt.Errorf("error parsing tunnel service uri: %w", err)
132 }
133
134 // Create the tunnel manager
135 // This api version seems to be the only acceptable api version: https://github.com/microsoft/dev-tunnels/blob/bf96ae5a128041d1a23f81d53a47e9e6c26fdc8d/go/tunnels/manager.go#L66
136 apiVersion := "2023-09-27-preview"
137 tunnelManager, err = tunnels.NewManager(userAgent, nil, url, httpClient, apiVersion)
138 if err != nil {
139 return nil, fmt.Errorf("error creating tunnel manager: %w", err)
140 }
141
142 return tunnelManager, nil
143}
144
145// getTunnelClient creates a tunnel client for the given tunnel.
146// The tunnel client is used to connect to the tunnel and allows

Callers 1

NewCodespaceConnectionFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected