port

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// K9sAutoPortForwardKey represents an auto portforwards annotation.
	K9sAutoPortForwardsKey = "k9scli.io/auto-port-forwards"

	// K9sPortForwardKey represents a portforwards annotation.
	K9sPortForwardsKey = "k9scli.io/port-forwards"
)

Variables

This section is empty.

Functions

func IsPortFree

func IsPortFree(t PortTunnel) bool

Types

type Annotations

type Annotations map[string]string

func (Annotations) PreferredPorts

func (a Annotations) PreferredPorts(specs ContainerPortSpecs) (PFAnns, error)

type ContainerPortSpec

type ContainerPortSpec struct {
	Container string
	PortName  string
	PortNum   string
}

ContainerPortSpec represents a container port specification.

func NewPortSpec

func NewPortSpec(co, portName string, port int32) ContainerPortSpec

NewPortSpec returns a new instance.

func (ContainerPortSpec) Match

func (c ContainerPortSpec) Match(ann *PFAnn) bool

Match checks if the container spec matches an annotation.

func (ContainerPortSpec) MatchSpec

func (c ContainerPortSpec) MatchSpec(s string) bool

func (ContainerPortSpec) Port

func (ContainerPortSpec) String

func (c ContainerPortSpec) String() string

String dumps spec to string.

func (ContainerPortSpec) ToPFAnn

func (c ContainerPortSpec) ToPFAnn() *PFAnn

func (ContainerPortSpec) ToTunnel

func (c ContainerPortSpec) ToTunnel(address string) PortTunnel

type ContainerPortSpecs

type ContainerPortSpecs []ContainerPortSpec

ContainerPortSpecs represents a container exposed ports.

func FromContainerPorts

func FromContainerPorts(co string, pp []v1.ContainerPort) ContainerPortSpecs

FromContainerPorts hydrates from a pod container specification.

func (ContainerPortSpecs) Dump

func (c ContainerPortSpecs) Dump() string

func (ContainerPortSpecs) Find

Find finds a matching container port.

func (ContainerPortSpecs) Match

func (c ContainerPortSpecs) Match(pf *PFAnn) bool

Match checks if container ports match a pf annotation.

func (ContainerPortSpecs) MatchAnnotations

func (c ContainerPortSpecs) MatchAnnotations(s string) PFAnns

func (ContainerPortSpecs) MatchSpec

func (c ContainerPortSpecs) MatchSpec(s string) bool

InSpecs checks if given port matches a spec.

func (ContainerPortSpecs) ToTunnels

func (c ContainerPortSpecs) ToTunnels(address string) PortTunnels

ToTunnels convert port specs to tunnels.

type PFAnn

type PFAnn struct {
	Container     string
	ContainerPort intstr.IntOrString
	LocalPort     string
	// contains filtered or unexported fields
}

PFAnn represents a portforward annotation value. Shape: container/portname|portNum:localPort

func ParsePF

func ParsePF(ann string) (*PFAnn, error)

ParsePF hydrate a portforward annotation from string.

func ParsePlainPF

func ParsePlainPF(ann string) (*PFAnn, error)

func (*PFAnn) AsSpec

func (p *PFAnn) AsSpec() string

func (*PFAnn) Match

func (p *PFAnn) Match(ss ContainerPortSpecs) bool

Match checks if annotation matches any of the container ports.

func (*PFAnn) PortNum

func (p *PFAnn) PortNum() (string, error)

func (*PFAnn) String

func (p *PFAnn) String() string

String dumps the annotation.

func (*PFAnn) ToTunnel

func (p *PFAnn) ToTunnel(address string) (PortTunnel, error)

type PFAnns

type PFAnns []*PFAnn

PFAnns represents a collection of port forward annotations.

func ParsePFs

func ParsePFs(ann string) (PFAnns, error)

ParsePFs hydrates a collection of portforward annotations.

func (PFAnns) ToPortSpec

func (aa PFAnns) ToPortSpec(pp ContainerPortSpecs) (string, string)

ToPortSpec returns a container port and local port definitions.

func (PFAnns) ToTunnels

func (aa PFAnns) ToTunnels(address string, pp ContainerPortSpecs, available PortChecker) (PortTunnels, error)

type PortChecker

type PortChecker func(PortTunnel) bool

PortCheck checks if port is free on host.

type PortTunnel

type PortTunnel struct {
	Address, Container, LocalPort, ContainerPort string
}

PortTunnel represents a host tunnel port mapper.

func NewPortTunnel

func NewPortTunnel(a, co, lp, cp string) PortTunnel

func (PortTunnel) PortMap

func (t PortTunnel) PortMap() string

PortMap returns a port mapping.

type PortTunnels

type PortTunnels []PortTunnel

PortTunnels represents a collection of tunnels.

func ToTunnels

func ToTunnels(address, specs, localPorts string) (PortTunnels, error)

func (PortTunnels) CheckAvailable

func (t PortTunnels) CheckAvailable() error

Jump to

Keyboard shortcuts

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