utils

package
v3.3.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 6 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareIPNets

func CompareIPNets(a, b *net.IPNet) int

CompareIPNets returns -1, 0, 1 if a<b or a==b or a>b, respectively. It hold that if *a* is subset of *b*, then a<b (and vice-versa).

func CompareIPNetsBytes

func CompareIPNetsBytes(aPrefixLen uint8, aIP [16]byte, bPrefixLen uint8, bIP [16]byte) int

CompareIPNetsBytes returns an integer comparing two IP network addresses represented as raw bytes lexicographically.

func CompareInts

func CompareInts(a, b int) int

CompareInts is a comparison function for two integers.

func ComparePorts

func ComparePorts(a, b uint16) int

ComparePorts is a comparison function for two ports. Port=0 means "all-ports" and it is higher in the order than any specific port.

func ConstructLabels

func ConstructLabels(key string, values []string) []*policymodel.Policy_Label

ConstructLabels returns a key-value pair as a label given an expression

func Difference

func Difference(a []string, b []string) []string

Difference returns the difference of two slices

func GetOneHostSubnet

func GetOneHostSubnet(hostAddr string) *net.IPNet

GetOneHostSubnet returns the IP subnet that contains only the given host (i.e. /32 for IPv4, /128 for IPv6).

func GetOneHostSubnetFromIP

func GetOneHostSubnetFromIP(hostIP net.IP) *net.IPNet

GetOneHostSubnetFromIP returns the IP subnet that contains only the given host (i.e. /32 for IPv4, /128 for IPv6). Unlike GetOneHostSubnet, host address is not given as a string but rather as an instance of net.IP.

func Intersect

func Intersect(a []string, b []string, s ...[]string) []string

Intersect returns the common elements of two or more slices

func RemoveDuplicatePodIDs

func RemoveDuplicatePodIDs(el []podmodel.ID) []podmodel.ID

RemoveDuplicatePodIDs removes duplicate pod IDs from a slice.

func RemoveDuplicates

func RemoveDuplicates(el []string) []string

RemoveDuplicates removes duplicates entries for a slice of strings

func StringPodID

func StringPodID(pods []podmodel.ID) []string

StringPodID converts podmodelIDs to string podIDs

func StringPolicyID

func StringPolicyID(policies []policymodel.ID) []string

StringPolicyID converts policymodelIDs to string policyIDs

func UnstringNamespaceID

func UnstringNamespaceID(namespaces []string) []namespacemodel.ID

UnstringNamespaceID converts string namespaceIDs to namespacemodelIDs

func UnstringPodID

func UnstringPodID(pods []string) []podmodel.ID

UnstringPodID converts string podIDs to podmodelIDs

func UnstringPolicyID

func UnstringPolicyID(policies []string) []policymodel.ID

UnstringPolicyID converts string policyIDs to policymodelIDs

Types

This section is empty.

Jump to

Keyboard shortcuts

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