Documentation ¶
Index ¶
- Constants
- Variables
- func CreateDataDiskName(vmName, diskName string, lun int32) string
- func CreateNICName(vmName string) string
- func CreateOSDiskName(vmName string) string
- func CreateResourceTags(tags map[string]string) map[string]*string
- func DataDisksMarkedForDetachment(vm *armcompute.VirtualMachine) bool
- func ExtractVMNameFromNICName(nicName string) string
- func ExtractVMNameFromOSDiskName(osDiskName string) string
- func GetDataDiskNameSuffix(diskName string, lun int32) string
- func IsEmptyString(s string) bool
- func IsNilOrEmptyStringPtr(s *string) bool
- func IsSliceNilOrEmpty[T any](s []T) bool
- func RunConcurrently(ctx context.Context, tasks []Task, bound int) []error
- func ToImageReference(urn string) armcompute.ImageReference
- type ResourceType
- type RunGroup
- type Task
Constants ¶
const ( // NICSuffix is the suffix for NIC names. NICSuffix = "-nic" // OSDiskSuffix is the suffix for OSDisk names. OSDiskSuffix = "-os-disk" //DataDiskSuffix is the suffix for Data disk names. DataDiskSuffix = "-data-disk" // AzureCSIDriverName is the name of the CSI driver name for Azure provider AzureCSIDriverName = "disk.csi.azure.com" )
const ( // ClusterTagPrefix is a prefix for a mandatory cluster tag on resources ClusterTagPrefix = "kubernetes.io-cluster-" // RoleTagPrefix is a prefix for a mandatory role tag on resources RoleTagPrefix = "kubernetes.io-role-" )
const (
// ProvisioningStateFailed is the provisioning state of the VM set by the provider indicating that the VM is in terminal state.
ProvisioningStateFailed = "Failed"
)
Variables ¶
var ErrorEncapsulatingPanic = errors.New("panic has occurred")
ErrorEncapsulatingPanic is a sentinel error indicating that there has been a panic which has been captured as an error and returned as value.
Functions ¶
func CreateDataDiskName ¶
CreateDataDiskName creates a name for a DataDisk using VM name and data disk name specified in the provider Spec
func CreateNICName ¶
CreateNICName creates a NIC name given a VM name
func CreateOSDiskName ¶
CreateOSDiskName creates OSDisk name from VM name
func CreateResourceTags ¶
CreateResourceTags changes the tag value to be a pointer to string. Azure APIs require tags to be represented as map[string]*string
func DataDisksMarkedForDetachment ¶
func DataDisksMarkedForDetachment(vm *armcompute.VirtualMachine) bool
DataDisksMarkedForDetachment checks if there is at least DataDisk that is marked for detachment. If there are no DataDisk(s) configured then it will return false.
func ExtractVMNameFromNICName ¶
ExtractVMNameFromNICName extracts VM Name from NIC name
func ExtractVMNameFromOSDiskName ¶
ExtractVMNameFromOSDiskName extracts VM name from OSDisk name
func GetDataDiskNameSuffix ¶
GetDataDiskNameSuffix creates the suffix based on an optional data disk name and required lun fields.
func IsEmptyString ¶
IsEmptyString trims the spaces around the string and checks its length. If it is 0 then it will return true else it will return false
func IsNilOrEmptyStringPtr ¶
IsNilOrEmptyStringPtr returns true if the string pointer is nil or the return value of IsEmptyString(s).
func IsSliceNilOrEmpty ¶
IsSliceNilOrEmpty returns true of the slice is nil or has 0 length (empty).
func RunConcurrently ¶
RunConcurrently runs tasks concurrently with number of goroutines bounded by bound. If there is a panic executing a single Task then it will capture the panic and capture it as an error which will then subsequently be returned from this function. It will not propagate the panic causing the app to exit.
func ToImageReference ¶ added in v0.14.0
func ToImageReference(urn string) armcompute.ImageReference
ToImageReference transforms an image urn string (publisher:offer:sku:version) into an ImageReference
Types ¶
type ResourceType ¶
type ResourceType string
ResourceType is an enum type representing type different resource types supported by Azure.
const ( // VirtualMachinesResourceType is a type used by Azure to represent virtual machine resources. VirtualMachinesResourceType ResourceType = "microsoft.compute/virtualmachines" // NetworkInterfacesResourceType is a type used by Azure to represent network interfaces resources. NetworkInterfacesResourceType ResourceType = "microsoft.network/networkinterfaces" //as defined in azure // DiskResourceType is a type used by Azure to represent disks (both OS and Data disks) DiskResourceType ResourceType = "microsoft.compute/disks" // VMImageResourceType is a type used by Azure to represent VM Image resources. // This is not defined in azure, however we have created this to allow defining API behavior for VM Images. VMImageResourceType ResourceType = "microsoft.compute/vmimage" // MarketPlaceOrderingOfferType is a type used by Azure to represent marketplace ordering offer types. MarketPlaceOrderingOfferType ResourceType = "microsoft.marketplaceordering/offertypes" // SubnetResourceType is a type used by Azure to represent subnet resources. SubnetResourceType ResourceType = "microsoft.network/virtualnetworks/subnets" )
type RunGroup ¶
type RunGroup struct {
// contains filtered or unexported fields
}
RunGroup is a runner for concurrently spawning multiple asynchronous tasks. If any task errors or panics then these are captured as errors.
func NewRunGroup ¶
NewRunGroup creates a new RunGroup.
func (*RunGroup) WaitAndCollectErrors ¶
WaitAndCollectErrors waits for all tasks to finish, collects and returns any errors.
type Task ¶
type Task struct { // Name is the name of the task Name string // Fn is the function which accepts a context and returns an error if there is one. // Implementations of Fn should handle context cancellation properly. Fn func(ctx context.Context) error }
Task is a holder for a named function.