portforward

package
v0.11.7-merged-prereqs Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*properties)

func WithDeployment

func WithDeployment(name, namespace string) Option

func WithKindCluster

func WithKindCluster(kindClusterName string) Option

func WithKubeContext

func WithKubeContext(kubeContext string) Option

func WithPorts

func WithPorts(localPort, remotePort int) Option

func WithRemotePort

func WithRemotePort(remotePort int) Option

func WithResource

func WithResource(name, namespace, resourceType string) Option

func WithService

func WithService(name, namespace string) Option

func WithWriters

func WithWriters(out, err io.Writer) Option

type PortForwarder

type PortForwarder interface {
	// Start runs this PortForwarder.
	Start(ctx context.Context, options ...retry.Option) error

	// Address returns the local forwarded address. Only valid while the apiPortForwarder is running.
	Address() string

	// Close this apiPortForwarder and release any resources.
	Close()

	// ErrChan returns a channel that returns an error when one is encountered. While Start() may return an initial error,
	// the port-forward connection may be lost at anytime. The ErrChan can be read to determine if/when the port-forwarding terminates.
	// This can return nil if the port forwarding stops gracefully.
	ErrChan() <-chan error

	// WaitForStop blocks until connection closed (e.g. control-C interrupt)
	WaitForStop()
}

PortForwarder manages the forwarding of a single port. Implementations are NOT thread-safe, as the goroutine that Starts the PortForward should also be the one that Closes it

func NewApiPortForwarder

func NewApiPortForwarder(options ...Option) PortForwarder

NewApiPortForwarder returns an implementation of a PortForwarder that does not rely on the Kubernetes CLI but instead queries the Kubernetes API directly This implementation is preferred, but we have seen it fail occassionally with the following error:

portforward.go:394] error copying from local connection to remote stream: EOF

func NewCliPortForwarder

func NewCliPortForwarder(options ...Option) PortForwarder

NewCliPortForwarder returns an implementation of a PortForwarder that relies on the Kubernetes CLI to perform port-forwarding This implementation is NOT thread-safe

func NewPortForwarder

func NewPortForwarder(options ...Option) PortForwarder

NewPortForwarder returns an implementation of a PortForwarder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL