MCPcopy Index your code
hub / github.com/devspace-sh/devspace / NewPortForwarder

Function NewPortForwarder

pkg/devspace/kubectl/util.go:188–209  ·  view source on GitHub ↗

NewPortForwarder creates a new port forwarder object for the specified pods, ports and addresses

(client Client, pod *corev1.Pod, ports []string, addresses []string, stopChan chan struct{}, readyChan chan struct{}, errorChan chan error)

Source from the content-addressed store, hash-verified

186
187// NewPortForwarder creates a new port forwarder object for the specified pods, ports and addresses
188func NewPortForwarder(client Client, pod *corev1.Pod, ports []string, addresses []string, stopChan chan struct{}, readyChan chan struct{}, errorChan chan error) (*portforward.PortForwarder, error) {
189 execRequest := client.KubeClient().CoreV1().RESTClient().Post().
190 Resource("pods").
191 Name(pod.Name).
192 Namespace(pod.Namespace).
193 SubResource("portforward")
194
195 transport, upgrader, err := GetUpgraderWrapper(client)
196 if err != nil {
197 return nil, err
198 }
199
200 logFile := log.GetFileLogger("portforwarding")
201 dialer := spdy.NewDialer(upgrader, &http.Client{Transport: transport}, "POST", execRequest.URL())
202
203 fw, err := portforward.NewOnAddresses(dialer, addresses, ports, stopChan, readyChan, errorChan, logFile.Writer(logrus.InfoLevel, false), logFile.Writer(logrus.WarnLevel, false))
204 if err != nil {
205 return nil, err
206 }
207
208 return fw, nil
209}
210
211// IsLocalKubernetes returns true if the context belongs to a local Kubernetes cluster
212func IsLocalKubernetes(kubeClient Client) bool {

Callers 2

StartForwardingFunction · 0.92
forwardMethod · 0.92

Calls 7

GetFileLoggerFunction · 0.92
NewOnAddressesFunction · 0.92
GetUpgraderWrapperFunction · 0.85
NamespaceMethod · 0.65
NameMethod · 0.65
KubeClientMethod · 0.65
WriterMethod · 0.65

Tested by

no test coverage detected