startPortForward launches `kubectl port-forward deploy/ local:remote` for the given context and returns the running command.
(kubeContext, ns, deploy string, localPort, remotePort int)
| 159 | if err != nil { |
| 160 | return "", fmt.Errorf("decode secret %s/%s: %w", name, key, err) |
| 161 | } |
| 162 | return string(dec), nil |
| 163 | } |
| 164 | |
| 165 | // startPortForward launches `kubectl port-forward deploy/<deploy> local:remote` |
| 166 | // for the given context and returns the running command. |
| 167 | func startPortForward(kubeContext, ns, deploy string, localPort, remotePort int) *exec.Cmd { |
| 168 | cmd := exec.Command("kubectl", "--context", kubeContext, "-n", ns, "port-forward", |
| 169 | "deploy/"+deploy, fmt.Sprintf("%d:%d", localPort, remotePort)) |
| 170 | cmd.Stdout, cmd.Stderr = os.Stderr, os.Stderr |
| 171 | if err := cmd.Start(); err != nil { |
| 172 | log.Fatalf("start port-forward: %v", err) |