util

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Gb = 1024 * 1024 * 1024
	Tb = 1024 * Gb

	// VolumeSnapshot parameters
	VolumeSnapshotTypeKey      = "type"
	VolumeSnapshotLocationKey  = "location"
	VolumeSnapshotTypeSnapshot = "snapshot"
	VolumeSnapshotTypeBackup   = "backup"

	SnapshotHandleBackupKey = "backups"
)

Variables

This section is empty.

Functions

func BackupVolumeSourceToCSIVolumeHandle added in v0.3.1

func BackupVolumeSourceToCSIVolumeHandle(backupVolumeSource string) (string, error)

func BytesToGb added in v0.3.1

func BytesToGb(bytes int64) int64

func ConvertLabelsStringToMap added in v0.3.1

func ConvertLabelsStringToMap(labels string) (map[string]string, error)

ConvertLabelsStringToMap converts the labels from string to map example: "key1=value1,key2=value2" gets converted into {"key1": "value1", "key2": "value2"}

func GbToBytes

func GbToBytes(gbs int64) int64

func GetBackupLocation added in v0.3.1

func GetBackupLocation(params map[string]string) string

func GetRegionFromZone added in v0.3.1

func GetRegionFromZone(location string) (string, error)

func IsBackupHandle added in v0.3.1

func IsBackupHandle(handle string) (bool, error)

func IsSnapshotTypeSupported added in v0.3.1

func IsSnapshotTypeSupported(params map[string]string) (bool, error)

func Max

func Max(a, b int64) int64

func Min

func Min(a, b int64) int64

func ParseTimestamp added in v0.3.1

func ParseTimestamp(timestamp string) (*timestamppb.Timestamp, error)

func RoundBytesToGb

func RoundBytesToGb(bytes int64) int64

Round up to the nearest Gb

Types

type IPAllocator added in v0.2.0

type IPAllocator struct {
	// contains filtered or unexported fields
}

IPAllocator struct consists of shared resources that are used to keep track of the /29 IPRanges currently reserved by service instances

func NewIPAllocator added in v0.2.0

func NewIPAllocator(pendingIPRanges map[string]bool) *IPAllocator

NewIPAllocator is the constructor to initialize the IPAllocator object Argument pendingIPRanges map[string]bool is a set of IP ranges currently reserved by service instances but pending reservation in the cloud instances

func (*IPAllocator) GetUnreservedIPRange added in v0.2.0

func (ipAllocator *IPAllocator) GetUnreservedIPRange(cidr string, cloudInstancesReservedIPRanges map[string]bool) (string, error)

GetUnreservedIPRange returns an unreserved /29 IP block. cidr: Provided cidr address in which we need to look for an unreserved /29 IP range cloudInstancesReservedIPRanges: All the used IP ranges in the cloud instances All the used IP ranges in the service instances not updated in cloud instances is extracted from the pendingIPRanges list in the IPAllocator Finally a final reservedIPRange list is created by merging these two lists Potential error cases: 1) No /29 IP range in the CIDR is unreserved 2) Parsing the CIDR resulted in an error

func (*IPAllocator) ReleaseIPRange added in v0.2.0

func (ipAllocator *IPAllocator) ReleaseIPRange(ipRange string)

ReleaseIPRange releases the pending IPRange Argument ipRange string is an IPV4 range which needs to be released

Jump to

Keyboard shortcuts

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