common

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSetNotExist      = errors.New("set does not exists")
	ErrInvalidIPAddress = errors.New("invalid ipaddress, no equivalent pod found")
	ErrInvalidInput     = errors.New("invalid input")
	ErrSetType          = errors.New("invalid set type")
)

error type

Functions

func GetContainerPortList

func GetContainerPortList(podObj *corev1.Pod) []corev1.ContainerPort

func IsSystemNs

func IsSystemNs(nsObj *corev1.Namespace) bool

Types

type Cache

type Cache struct {
	NodeName string
	NsMap    map[string]*Namespace
	PodMap   map[string]*NpmPod
	SetMap   map[string]string
	ListMap  map[string]string // not used in NPMV2
}

func (*Cache) GetListMap

func (c *Cache) GetListMap() map[string]string

func (*Cache) GetNamespaceLabel

func (c *Cache) GetNamespaceLabel(namespace, labelkey string) string

func (*Cache) GetPod

func (c *Cache) GetPod(input *Input) (*NpmPod, error)

func (*Cache) GetSetMap

func (c *Cache) GetSetMap() map[string]string

type GenericCache

type GenericCache interface {
	GetPod(*Input) (*NpmPod, error)
	GetNamespaceLabel(namespace string, key string) string
	GetListMap() map[string]string
	GetSetMap() map[string]string
}

type Input

type Input struct {
	Content string
	Type    InputType
}

type InputType

type InputType int32

InputType indicates allowed typle for source and destination input

const (
	// IPADDRS indicates the IP Address input type, example: 10.0.0.1
	IPADDRS InputType = 0
	// NSPODNAME indicates the podname input type, example: x/a
	NSPODNAME InputType = 1
	// EXTERNAL indicates the external input type
	EXTERNAL InputType = 2
)

func GetInputType

func GetInputType(input string) InputType

GetInputType returns the type of the input for GetNetworkTuple.

type LabelAppendOperation

type LabelAppendOperation bool
const (
	ClearExistingLabels    LabelAppendOperation = true
	AppendToExistingLabels LabelAppendOperation = false
)

type Namespace

type Namespace struct {
	Name      string
	LabelsMap map[string]string // Namespace labels
}

func NewNs

func NewNs(name string) *Namespace

newNS constructs a new namespace object.

func (*Namespace) AppendLabels

func (nsObj *Namespace) AppendLabels(newm map[string]string, clear LabelAppendOperation)

func (*Namespace) GetNamespaceObjFromNsObj

func (nsObj *Namespace) GetNamespaceObjFromNsObj() *corev1.Namespace

func (*Namespace) RemoveLabelsWithKey

func (nsObj *Namespace) RemoveLabelsWithKey(key string)

type NpmPod

type NpmPod struct {
	Name           string
	Namespace      string
	PodIP          string
	Labels         map[string]string
	ContainerPorts []corev1.ContainerPort
	Phase          corev1.PodPhase
}

func NewNpmPod

func NewNpmPod(podObj *corev1.Pod) *NpmPod

func (*NpmPod) AppendContainerPorts

func (n *NpmPod) AppendContainerPorts(podObj *corev1.Pod)

func (*NpmPod) AppendLabels

func (n *NpmPod) AppendLabels(newPod map[string]string, clear LabelAppendOperation)

func (*NpmPod) IP

func (n *NpmPod) IP() string

func (*NpmPod) NamespaceString

func (n *NpmPod) NamespaceString() string

func (*NpmPod) NoUpdate

func (n *NpmPod) NoUpdate(podObj *corev1.Pod) bool

noUpdate evaluates whether NpmPod is required to be update given podObj.

func (*NpmPod) RemoveContainerPorts

func (n *NpmPod) RemoveContainerPorts()

func (*NpmPod) RemoveLabelsWithKey

func (n *NpmPod) RemoveLabelsWithKey(key string)

func (*NpmPod) UpdateNpmPodAttributes

func (n *NpmPod) UpdateNpmPodAttributes(podObj *corev1.Pod)

This function can be expanded to other attribs if needed

Jump to

Keyboard shortcuts

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