Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(k8s): honor options.RestConfig in tunnel.ForwardPortE #1464

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions modules/k8s/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,18 @@ func (tunnel *Tunnel) ForwardPortE(t testing.TestingT) error {
tunnel.logger.Logf(t, "Error creating a new Kubernetes client: %s", err)
return err
}
kubeConfigPath, err := tunnel.kubectlOptions.GetConfigPath(t)
if err != nil {
tunnel.logger.Logf(t, "Error getting kube config path: %s", err)
return err
}
config, err := LoadApiClientConfigE(kubeConfigPath, tunnel.kubectlOptions.ContextName)
if err != nil {
tunnel.logger.Logf(t, "Error loading Kubernetes config: %s", err)
return err
config := tunnel.kubectlOptions.RestConfig
if config == nil {
kubeConfigPath, err := tunnel.kubectlOptions.GetConfigPath(t)
if err != nil {
tunnel.logger.Logf(t, "Error getting kube config path: %s", err)
return err
}
config, err = LoadApiClientConfigE(kubeConfigPath, tunnel.kubectlOptions.ContextName)
if err != nil {
tunnel.logger.Logf(t, "Error loading Kubernetes config: %s", err)
return err
}
}

// Find the pod to port forward to
Expand Down