utils

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 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

This section is empty.

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 FormatLatency added in v0.6.0

func FormatLatency(latency time.Duration) string

FormatLatency returns a string representing the given latency in a human readable format.

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 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)

GetPodIP returns the pod IP address.

func GetPodName added in v0.9.4

func GetPodName() (string, error)

GetPodName returns the pod name.

func GetPodNamespace

func GetPodNamespace() (string, error)

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

func GetTunnelIP added in v0.6.0

func GetTunnelIP(externalCIDR string) (string, error)

GetTunnelIP returns the IP address of the tunnel, which is the first external CIDR ip.

func IsLocalNetworkConfig added in v0.7.0

func IsLocalNetworkConfig(networkConfig *netv1alpha1.NetworkConfig) bool

IsLocalNetworkConfig checks if the given network configuration is local.

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.
Package signals contains signals utilities which cannot be imported by windows.
Package signals contains signals utilities which cannot be imported by windows.

Jump to

Keyboard shortcuts

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