Documentation
¶
Overview ¶
Package forwardconnection provides an easy interface to create a port forward from the local test to a service or pod inside the testing k8s cluster
Index ¶
- Constants
- func NewDialer(kubeInterface kubernetes.Interface, config *rest.Config, namespace string, ...) (httpstream.Dialer, error)
- func NewDialerFromService(ctx context.Context, kubeInterface kubernetes.Interface, config *rest.Config, ...) (dialer httpstream.Dialer, portMaps []string, err error)
- type ForwardConnection
Constants ¶
const PostgresPortMap = "0:5432"
PostgresPortMap is the default port map for the PostgreSQL Pod
Variables ¶
This section is empty.
Functions ¶
func NewDialer ¶
func NewDialer( kubeInterface kubernetes.Interface, config *rest.Config, namespace string, pod string, ) (httpstream.Dialer, error)
NewDialer returns a Dialer to be used with a PortForwarder
func NewDialerFromService ¶
func NewDialerFromService( ctx context.Context, kubeInterface kubernetes.Interface, config *rest.Config, namespace, service string, ) (dialer httpstream.Dialer, portMaps []string, err error)
NewDialerFromService returns a Dialer against the service specified
Types ¶
type ForwardConnection ¶
type ForwardConnection struct {
// contains filtered or unexported fields
}
ForwardConnection holds the necessary information to manage a port-forward against a service of pod inside Kubernetes
func NewForwardConnection ¶
func NewForwardConnection( dialer httpstream.Dialer, portMaps []string, outWriter, errWriter io.Writer, ) (*ForwardConnection, error)
NewForwardConnection returns a PortForwarder against the pod specified
func (*ForwardConnection) Close ¶ added in v1.27.4
func (fc *ForwardConnection) Close()
Close stops the port-forward and waits for the forwarding goroutine to exit. It is safe to call multiple times and safe to call even if StartAndWait was never called.
func (*ForwardConnection) GetLocalPort ¶
func (fc *ForwardConnection) GetLocalPort() (string, error)
GetLocalPort will return the local port where the forward has started
func (*ForwardConnection) StartAndWait ¶
func (fc *ForwardConnection) StartAndWait(ctx context.Context) error
StartAndWait begins the port-forwarding and waits until it's ready. It must be called at most once per ForwardConnection.