portforward

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	Namespace  string                `json:"namespace"`
	APIVersion string                `json:"apiVersion"`
	Kind       string                `json:"kind"`
	Name       string                `json:"name"`
	Ports      []PortForwardPortSpec `json:"ports"`
}

type CreateResponse

type CreateResponse struct {
	ID    string                `json:"id"`
	Ports []PortForwardPortSpec `json:"ports"`
}

CreateResponse describes a port forward. TODO Merge with State (GH#498)

type DefaultPortForwarder

type DefaultPortForwarder struct {
	IOStreams
}

func (*DefaultPortForwarder) ForwardPorts

func (f *DefaultPortForwarder) ForwardPorts(alerter action.Alerter, method string, url *url.URL, opts Options) error

type ForwardedPort

type ForwardedPort struct {
	Local  uint16
	Remote uint16
}

type IOStreams

type IOStreams struct {
	// In think, os.Stdin
	In io.Reader
	// Out think, os.Stdout
	Out io.Writer
	// ErrOut think, os.Stderr
	ErrOut io.Writer
}

IOStreams provides the standard names for iostreams. This is useful for embedding and for unit testing. Inconsistent and different names make it hard to read and review code

type Options

type Options struct {
	Config        *restclient.Config
	RESTClient    rest.Interface
	Address       []string
	Ports         []string
	PortForwarder portForwarder
	StopChannel   <-chan struct{}
	ReadyChannel  chan struct{}
	PortsChannel  chan []ForwardedPort
}

Options contains all the options for running a port-forward <snip> from pkg/kubectl/cmd/portforward/portforward.go <snip>

type PortForwardPortSpec

type PortForwardPortSpec struct {
	Remote uint16 `json:"remote"`
	Local  uint16 `json:"local,omitempty"`
}

PortForwardPortSpec describes a forwarded port.

type PortForwarder

type PortForwarder interface {
	List(ctx context.Context) []State
	Get(id string) (State, bool)
	Create(ctx context.Context, alerter action.Alerter, gvk schema.GroupVersionKind, name string, namespace string, remotePort uint16) (CreateResponse, error)
	FindTarget(namespace string, gvk schema.GroupVersionKind, name string) ([]State, error)
	FindPod(namespace string, gvk schema.GroupVersionKind, name string) ([]State, error)
	Stop()
	StopForwarder(id string)
}

PortForwarder allows querying active port-forwards

func Default

func Default(ctx context.Context, client cluster.ClientInterface, objectStore store.Store) (PortForwarder, error)

Default create a port forward instance.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a port forwarding service.

func New

func New(ctx context.Context, opts ServiceOptions) *Service

New creates an instance of Service.

func (*Service) Create

func (s *Service) Create(ctx context.Context, alerter action.Alerter, gvk schema.GroupVersionKind, name string, namespace string, remotePort uint16) (CreateResponse, error)

Create creates a new port forward for the specified object and remote port. Implements PortForwardInterface.

func (*Service) FindPod added in v0.14.0

func (s *Service) FindPod(namespace string, gvk schema.GroupVersionKind, name string) ([]State, error)

func (*Service) FindTarget added in v0.14.0

func (s *Service) FindTarget(namespace string, gvk schema.GroupVersionKind, name string) ([]State, error)

func (*Service) Get

func (s *Service) Get(id string) (State, bool)

Get gets a single port forward state

func (*Service) List

func (s *Service) List(ctx context.Context) []State

List lists port forwards

func (*Service) Stop

func (s *Service) Stop()

Stop stops all forwarders. The portForwardService is invalid after calling stop.

func (*Service) StopForwarder

func (s *Service) StopForwarder(id string)

StopForwarder stops an individual port forward specified by id. Implements PortForwardInterface.

type ServiceOptions

type ServiceOptions struct {
	RESTClient    rest.Interface
	Config        *restclient.Config
	ObjectStore   store.Store
	PortForwarder portForwarder
}

ServiceOptions contains all the options for running a port-forward service

type State

type State struct {
	ID        string
	CreatedAt time.Time
	Ports     []ForwardedPort
	Target    Target
	Pod       Target
	// contains filtered or unexported fields
}

State describes a single port-forward's runtime state

func (*State) Clone

func (pf *State) Clone() State

Clone clones a port forward state.

type States

type States struct {
	sync.Mutex
	// contains filtered or unexported fields
}

States describes all active port-forwards' runtime state

type Target

type Target struct {
	GVK       schema.GroupVersionKind
	Namespace string
	Name      string
}

Target references a kubernetes object

Directories

Path Synopsis
Package fake is a generated GoMock package.
Package fake is a generated GoMock package.

Jump to

Keyboard shortcuts

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