utils

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

Source Files

  • utils.go

Jump to

Keyboard shortcuts

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