hvtag

package
v1.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package hvtag contains objects and utility functions to handle tags of Hivelocity devices.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDeviceTagKeyInvalid indicates that the device tag key is invalid.
	ErrDeviceTagKeyInvalid = fmt.Errorf("invalid device tag key")
	// ErrDeviceTagInvalidFormat indicates that the device tag has an invalid format.
	ErrDeviceTagInvalidFormat = fmt.Errorf("invalid format of device tag")
	// ErrDeviceTagEmptyKey indicates that the device tag has an empty key.
	ErrDeviceTagEmptyKey = fmt.Errorf("device tag has empty key")
	// ErrDeviceTagEmptyValue indicates that the device tag has an empty value.
	ErrDeviceTagEmptyValue = fmt.Errorf("device tag has empty value")
	// ErrMultipleDeviceTagsFound indicates that multiple device tags have been found in a list.
	ErrMultipleDeviceTagsFound = fmt.Errorf("found multiple device tags")
	// ErrDeviceTagNotFound indicates that no device tag has been found.
	ErrDeviceTagNotFound = fmt.Errorf("no device tag found")
)

Functions

This section is empty.

Types

type DeviceTag

type DeviceTag struct {
	Key   DeviceTagKey
	Value string
}

DeviceTag defines the object that represents a key-value pair that is stored as tag of Hivelocity devices.

func ClusterTagFromList

func ClusterTagFromList(tagList []string) (DeviceTag, error)

ClusterTagFromList returns the machine tag from a list of tag strings.

func DeviceTagFromList

func DeviceTagFromList(key DeviceTagKey, tagList []string) (DeviceTag, error)

DeviceTagFromList takes the tag of a HV device and returns a DeviceTag or an error if it is invalid.

func DeviceTypeTagFromList

func DeviceTypeTagFromList(tagList []string) (DeviceTag, error)

DeviceTypeTagFromList returns the machine tag from a list of tag strings.

func MachineTagFromList

func MachineTagFromList(tagList []string) (DeviceTag, error)

MachineTagFromList returns the machine tag from a list of tag strings.

func (DeviceTag) IsInStringList

func (deviceTag DeviceTag) IsInStringList(tagList []string) bool

IsInStringList checks whether a DeviceTag object can be found in a list of tag strings.

func (DeviceTag) RemoveFromList

func (deviceTag DeviceTag) RemoveFromList(tagList []string) (newTagList []string, updated bool)

RemoveFromList removes all tag strings from a list that equal the string representation of DeviceTag.

func (DeviceTag) ToString

func (deviceTag DeviceTag) ToString() string

ToString returns the string representation of a DeviceTag object.

type DeviceTagKey

type DeviceTagKey string

DeviceTagKey defines the key of the key-value pair that is stored as tag of Hivelocity devices.

const (
	// DeviceTagKeyMachine is the key for the name of the associated HivelocityMachine object.
	DeviceTagKeyMachine DeviceTagKey = "caphv-machine-name"

	// DeviceTagKeyCluster is the key for the name of the associated HivelocityCluster object.
	DeviceTagKeyCluster DeviceTagKey = "caphv-cluster-name"

	// DeviceTagKeyDeviceType is the key for the device type that users can reference in HivelocityMachine.Spec.
	DeviceTagKeyDeviceType DeviceTagKey = "caphv-device-type"

	// DeviceTagKeyMachineType is the key for the machine type, i.e. worker, control_plane.
	DeviceTagKeyMachineType DeviceTagKey = "caphv-machine-type"
)

func (DeviceTagKey) IsValid

func (key DeviceTagKey) IsValid() bool

IsValid checks whether a DeviceTagKey is valid.

func (DeviceTagKey) Prefix

func (key DeviceTagKey) Prefix() string

Prefix returns the prefix based on this DeviceTagKey used in Hivelocity tag strings.

Jump to

Keyboard shortcuts

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