Documentation
      ¶
    
    
  
    
  
    Overview ¶
portforward contains functionality for port-forwarding an entire application from Kubernetes. This functionality is based on the kubenetes client APIs and implemented inside this package.
Package portforward is a generated GoMock package.
Index ¶
- Constants
 - func NewApplicationWatcher(options Options) *applicationWatcher
 - func NewDeploymentWatcher(options Options, matchLabels map[string]string, revision string, cancel func()) *deploymentWatcher
 - func NewFakeForwarder(ports map[int32]bool) forwarder
 - func NewPodWatcher(options Options, pod *corev1.Pod, cancel func()) *podWatcher
 - type Impl
 - type Interface
 - type MockInterface
 - type MockInterfaceMockRecorder
 - type Options
 - type StatusKind
 - type StatusMessage
 
Constants ¶
const ( KindConnected = "connected" KindDisconnected = "disconnected" )
Variables ¶
This section is empty.
Functions ¶
func NewApplicationWatcher ¶
func NewApplicationWatcher(options Options) *applicationWatcher
NewApplicationWatcher creates a new applicationWatcher struct with the given options and initializes the done channel and deploymentWatchers map.
func NewDeploymentWatcher ¶
func NewDeploymentWatcher(options Options, matchLabels map[string]string, revision string, cancel func()) *deploymentWatcher
NewDeploymentWatcher creates a new deploymentWatcher struct with the given parameters and returns a pointer to it.
func NewFakeForwarder ¶
NewFakeForwarder takes in a map of ports and returns a fakeforwarder which contains a ready channel and a list of ForwardedPort objects with the same local and remote ports.
func NewPodWatcher ¶
"NewPodWatcher" creates a new podWatcher struct with the given options, pod and cancel function, and initializes the done, forwarderDone, log, and Updated channels.
Types ¶
type Interface ¶
type Interface interface {
	// Run will establish port-forward connections to every Kubernetes pod that
	// is labeled as being part of the Radius Application. Basing the logic on Kubernetes deployments rather
	// than Radius containers allows us to support resources created in recipes.
	//
	// Run will block until the provided context is cancelled.
	//
	// Run will allocate local ports that match the container ports of the deployments/pods where possible.
	// When a conflict occurs or when the local port is unavailable, a random port will be chosen.
	Run(ctx context.Context, options Options) error
}
    Interface is the interface type for port-forwarding.
type MockInterface ¶
type MockInterface struct {
	// contains filtered or unexported fields
}
    MockInterface is a mock of Interface interface.
func NewMockInterface ¶
func NewMockInterface(ctrl *gomock.Controller) *MockInterface
NewMockInterface creates a new mock instance.
func (*MockInterface) EXPECT ¶
func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockInterfaceMockRecorder ¶
type MockInterfaceMockRecorder struct {
	// contains filtered or unexported fields
}
    MockInterfaceMockRecorder is the mock recorder for MockInterface.
func (*MockInterfaceMockRecorder) Run ¶
func (mr *MockInterfaceMockRecorder) Run(arg0, arg1 interface{}) *gomock.Call
Run indicates an expected call of Run.
type Options ¶
type Options struct {
	// ApplicationName is the name of the application.
	ApplicationName string
	// Namespace is the kubernetes namespace of the application.
	Namespace string
	// KubeContext is the kubernetes context to use. If Client or RESTConfig is unset, this will be
	// used to initialize those fields.
	KubeContext string
	// Client is the Kubernetes client used to access the cluster. If this is set then RESTConfig
	// must also be set.
	//
	// We are using client-go here because the fake client from client-go has
	// better support for watch.
	Client k8sclient.Interface
	// Out is where output will be written.
	Out io.Writer
	// RESTConfig is the Kubernetes configuration for connecting to the server. If this is set then
	// Client must also be set.
	RESTConfig *rest.Config
	// Status chan will receive StatusMessage updates if provided.
	StatusChan chan<- StatusMessage
}
    Options specifies the options for port-forwarding.
type StatusKind ¶
type StatusKind = string
type StatusMessage ¶
type StatusMessage struct {
	Kind          StatusKind
	ContainerName string
	ReplicaName   string
	LocalPort     uint16
	RemotePort    uint16
}
    StatusMessage is the type used to communicate a change in port-forward status.