utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package utils contain utility functions for the Liqonet package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ShutdownSignals signals used to terminate the programs.
	ShutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM, syscall.SIGKILL}
)

Functions

func AddAnnotationToObj

func AddAnnotationToObj(obj client.Object, aKey, aValue string) bool

AddAnnotationToObj for a given object it adds the annotation with the given key and value. It return a bool which is true when the annotations has been added or false if the annotation is already present.

func AddLabelToObj

func AddLabelToObj(obj client.Object, labelKey, labelValue string) bool

AddLabelToObj for a given object it adds the label with the given key and value. It return a bool which is true when the label has been added or false if the label is already present.

func CheckTep

func CheckTep(tep *netv1alpha1.TunnelEndpoint) error

CheckTep checks validity of TunnelEndpoint resource fields.

func GetAnnotationValueFromObj

func GetAnnotationValueFromObj(obj client.Object, akey string) string

GetAnnotationValueFromObj for a given object it return the value of the label denoted by the given key. If the key does not exist it returns an empty string.

func GetExternalCIDRS

func GetExternalCIDRS(tep *netv1alpha1.TunnelEndpoint) (localExternalCIDR, remoteExternalCIDR string)

GetExternalCIDRS for a given tep the function retrieves the values for localExternalCIDR and remoteExternalCIDR. Their values depend if the NAT is required or not.

func GetFirstIP

func GetFirstIP(network string) (string, error)

GetFirstIP returns the first IP address of a network.

func GetLabelValueFromObj

func GetLabelValueFromObj(obj client.Object, labelKey string) string

GetLabelValueFromObj for a given object it return the value of the label denoted by the given key. If the key does not exist it returns an empty string.

func GetMask

func GetMask(network string) uint8

GetMask retrieves the mask from a CIDR.

func GetNodeName

func GetNodeName() (string, error)

GetNodeName gets the name of the node where the pod is running passed as an environment variable.

func GetOverlayIP

func GetOverlayIP(ip string) string

GetOverlayIP given an IP address it is mapped in to the overlay network, described by consts.OverlayNetworkPrefix. It uses the overlay prefix and the last three octets of the original IP address.

func GetPodCIDRS

func GetPodCIDRS(tep *netv1alpha1.TunnelEndpoint) (localRemappedPodCIDR, remotePodCIDR string)

GetPodCIDRS for a given tep the function retrieves the values for localPodCIDR and remotePodCIDR. Their values depend if the NAT is required or not.

func GetPodIP

func GetPodIP() (net.IP, error)

func GetPodNamespace

func GetPodNamespace() (string, error)

GetPodNamespace gets the namespace of the pod passed as an environment variable.

func IsValidCIDR

func IsValidCIDR(cidr string) error

IsValidCIDR returns an error if the received CIDR is invalid.

func MapIPToNetwork

func MapIPToNetwork(newNetwork, oldIP string) (newIP string, err error)

MapIPToNetwork creates a new IP address obtained by means of the old IP address and the new network.

func Next

func Next(network string) string

Next used to get the second half of a given network.

func SetMask

func SetMask(network string, mask uint8) string

SetMask forges a new cidr from a network cidr and a mask.

func SplitNetwork added in v0.3.1

func SplitNetwork(network string) []string

SplitNetwork returns the two halves that make up a given network.

Types

This section is empty.

Directories

Path Synopsis
Package links contains utils functions to interact with link in linux systems.
Package links contains utils functions to interact with link in linux systems.

Jump to

Keyboard shortcuts

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