portforward

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2019 License: Apache-2.0 Imports: 19 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 PortForwardSpec

type DefaultPortForwarder

type DefaultPortForwarder struct {
	IOStreams
}

func (*DefaultPortForwarder) ForwardPorts

func (f *DefaultPortForwarder) ForwardPorts(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 PortForwardSpec

type PortForwardSpec struct {
	ID        string                `json:"id"`
	Status    string                `json:"status"`
	Message   string                `json:"message"`
	Ports     []PortForwardPortSpec `json:"ports"`
	CreatedAt time.Time             `json:"createdAt"`
}

PortForwardSpec describes a port forward. TODO Merge with PortForwardState

type PortForwarder

type PortForwarder interface {
	List(ctx context.Context) []State
	Get(id string) (State, bool)
	Create(ctx context.Context, gvk schema.GroupVersionKind, name string, namespace string, remotePort uint16) (CreateResponse, error)
	Find(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, logger log.Logger) *Service

New creates an instance of Service.

func (*Service) Create

func (s *Service) Create(ctx context.Context, 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) Find

func (s *Service) Find(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
}

PortForwardSvcOptions 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

Jump to

Keyboard shortcuts

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