Skip to content

Commit

Permalink
fix(k8s): honor options.RestConfig in tunnel.ForwardPortE
Browse files Browse the repository at this point in the history
The tunnel.ForwardPortE function does not honor the rest config
configured inside the KubectlOptions. This leads to a mismatch with
other functions.

This commit uses the RestConfig if defined instead of getting a new one.
  • Loading branch information
jduepmeier committed Nov 7, 2024
1 parent 5686dc5 commit 4e5b68f
Showing 1 changed file with 12 additions and 9 deletions.
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

0 comments on commit 4e5b68f

Please sign in to comment.