Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PortForwardOpt ¶
type PortForwardOpt func(pf *PortForwarder)
PortForwardOpt is an optional parameter for PortForwarder
func WithOnReadyCallback ¶
func WithOnReadyCallback(onReadyFunc func(int, string)) PortForwardOpt
WithOnReadyCallback registers a callback that will be invoked whenever the deployment's underlying pod changes and the port-forward is recreated. The callback must not invoke LocalPort from inside the callback, as this will lead to a deadlock.
type PortForwarder ¶
type PortForwarder struct {
// contains filtered or unexported fields
}
PortForwarder creates a port forwarding from localhost to a Deployment in the cluster. Assumes the Deployment has a single Pod, and keeps the port forward open if the Pod is deleted.
func NewPortForwarder ¶
func NewPortForwarder( kubeClient *testkubeclient.KubeClient, watcher *testwatcher.Watcher, logger *testlogger.TestLogger, retryTimeout time.Duration, kubeConfigPath, ns, deployment, port string, opts ...PortForwardOpt, ) *PortForwarder
NewPortForwarder creates a new instance of a PortForwarder
func (*PortForwarder) LocalPort ¶
func (pf *PortForwarder) LocalPort() (int, error)
LocalPort returns the current localhost port which forwards to the pod. lazily starts the port forward when called the first time.
func (*PortForwarder) Start ¶
func (pf *PortForwarder) Start(ctx context.Context) chan Event
Start creates a port forward to a deployment's pod and keeps it open, even if the pod is recreated. Once ctx is cancelled, the port forward will be closed and will no longer be recreated. Returns an unbuffered channel that returns instances of Event. Consumers must read from this channel. The channel will be closed when the PortForwarder stops.