resourceskus

package
v0.0.0-...-655af17 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EphemeralOSDisk identifies the capability for ephemeral os support.
	EphemeralOSDisk = "EphemeralOSDiskSupported"
	// AcceleratedNetworking identifies the capability for accelerated networking support.
	AcceleratedNetworking = "AcceleratedNetworkingEnabled"
	// VCPUs identifies the capability for the number of vCPUS.
	VCPUs = "vCPUs"
	// GPUs identifies the capability for the number of GPUs.
	GPUs = "GPUs"
	// MemoryGB identifies the capability for memory Size.
	MemoryGB = "MemoryGB"
	// MinimumVCPUS is the minimum vCPUS allowed.
	MinimumVCPUS = 2
	// MinimumMemory is the minimum memory allowed.
	MinimumMemory = 2
	// EncryptionAtHost identifies the capability for encryption at host.
	EncryptionAtHost = "EncryptionAtHostSupported"
	// MaximumPlatformFaultDomainCount identifies the maximum fault domain count for an availability set in a region.
	MaximumPlatformFaultDomainCount = "MaximumPlatformFaultDomainCount"
	// UltraSSDAvailable identifies the capability for the support of UltraSSD data disks.
	UltraSSDAvailable = "UltraSSDAvailable"
	// CPUArchitectureType identifies the capability for the CPU architecture.
	CPUArchitectureType = "CpuArchitectureType"
	// X64 and Arm64 are the possible values for CPUArchitectureType, in the Azure APIs. We will adapt them in the controller
	// to the ones kubernetes expect.
	X64   = "x64"
	Arm64 = "Arm64"
)

Variables

View Source
var (
	// ErrResourceNotFound is returned when a item is not found in a list.
	ErrResourceNotFound = errors.New("resource not found")
)

Functions

func NewService

func NewService(scope *actuators.MachineScope) azure.Service

NewService creates a new groups service.

Types

type AzureClient

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

AzureClient contains the Azure go-sdk Client.

func NewClient

func NewClient(azureClients actuators.AzureClients) *AzureClient

NewClient creates a new Resource SKUs client from subscription ID.

func (*AzureClient) List

func (ac *AzureClient) List(ctx context.Context, filter string) ([]compute.ResourceSku, error)

List returns all Resource SKUs available to the subscription.

type Cache

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

Cache loads resource SKUs at the beginning of reconcile to expose features available on compute resources. It exposes convenience functionality for trawling Azure SKU capabilities. It may be adapted to periodically refresh data in the background.

func GetCache

func GetCache(azureClients actuators.AzureClients, location string) (*Cache, error)

GetCache either creates a new SKUs cache or returns an existing one based on the location + SubscriptionID().

func NewStaticCache

func NewStaticCache(data []compute.ResourceSku, location string) *Cache

NewStaticCache initializes a cache with data and no ability to refresh. Used for testing.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, name string, kind ResourceType) (SKU, error)

Get returns a resource SKU with the provided name and category. It returns an error if we could not find a match. We should consider enhancing this function to handle restrictions (e.g. SKU not supported in region), which is why it returns an error and not a boolean.

func (*Cache) GetZones

func (c *Cache) GetZones(ctx context.Context, location string) ([]string, error)

GetZones looks at all virtual machine sizes and returns the unique set of zones into which some machine size may deploy. It removes restricted virtual machine sizes and duplicates.

func (*Cache) GetZonesWithVMSize

func (c *Cache) GetZonesWithVMSize(ctx context.Context, size, location string) ([]string, error)

GetZonesWithVMSize returns available zones for a virtual machine size in the given location.

func (*Cache) Map

func (c *Cache) Map(ctx context.Context, mapFn func(sku SKU)) error

Map invokes a function over all cached values.

type Cacher

type Cacher interface {
	Get(key interface{}) (value interface{}, ok bool)
	Add(key interface{}, value interface{}) bool
}

Cacher describes the ability to get and to add items to cache.

type Client

type Client interface {
	List(context.Context, string) ([]compute.ResourceSku, error)
}

Client wraps go-sdk.

type NewCacheFunc

type NewCacheFunc func(azureClients actuators.AzureClients, location string) *Cache

NewCacheFunc allows for mocking out the underlying client.

type ResourceSkusServiceBuilderFuncType

type ResourceSkusServiceBuilderFuncType func(*actuators.MachineScope) azure.Service

type ResourceType

type ResourceType string

ResourceType models available resource types as a set of known string constants.

const (
	// VirtualMachines is a convenience constant to filter resource SKUs to only include VMs.
	VirtualMachines ResourceType = "virtualMachines"
	// Disks is a convenience constant to filter resource SKUs to only include disks.
	Disks ResourceType = "disks"
	// AvailabilitySets is a convenience constant to filter resource SKUs to only include availability sets.
	AvailabilitySets ResourceType = "availabilitySets"
)

type SKU

type SKU compute.ResourceSku

SKU is a thin layer over the Azure resource SKU API to better introspect capabilities.

func (SKU) GetCapability

func (s SKU) GetCapability(name string) (string, bool)

GetCapability gets the value assigned to the given capability. Eg. MaximumPlatformFaultDomainCount -> "3" will return "3" for the capability "MaximumPlatformFaultDomainCount".

func (SKU) HasCapability

func (s SKU) HasCapability(name string) bool

HasCapability return true for a capability which can be either supported or not. Examples include "EphemeralOSDiskSupported", "UltraSSDAvavailable" "EncryptionAtHostSupported", "AcceleratedNetworkingEnabled", and "RdmaEnabled".

func (SKU) HasCapabilityWithCapacity

func (s SKU) HasCapabilityWithCapacity(name string, value int64) (bool, error)

HasCapabilityWithCapacity returns true when the provided resource exposes a numeric capability and the maximum value exposed by that capability exceeds the value requested by the user. Examples include "MaxResourceVolumeMB", "OSVhdSizeMB", "vCPUs", "MemoryGB","MaxDataDiskCount", "CombinedTempDiskAndCachedIOPS", "CombinedTempDiskAndCachedReadBytesPerSecond", "CombinedTempDiskAndCachedWriteBytesPerSecond", "UncachedDiskIOPS", and "UncachedDiskBytesPerSecond".

func (SKU) HasLocationCapability

func (s SKU) HasLocationCapability(capabilityName, location, zone string) bool

HasLocationCapability returns true if the provided resource supports the location capability.

type Service

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

func (*Service) CreateOrUpdate

func (s *Service) CreateOrUpdate(ctx context.Context, spec azure.Spec) error

CreateOrUpdate no-op.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, spec azure.Spec) error

Delete no-op.

func (*Service) Get

func (service *Service) Get(ctx context.Context, spec azure.Spec) (interface{}, error)

Get returns SKU for given name and resourceType from the cache.

type Spec

type Spec struct {
	Name         string
	ResourceType ResourceType
}

Spec holds search criteria for a SKU.

type Supported

type Supported string

Supported models an enum of possible boolean values for resource support in the Azure API.

const (
	// CapabilitySupported is the value returned by this API from Azure when the capability is supported.
	CapabilitySupported Supported = "True"
	// CapabilityUnsupported is the value returned by this API from Azure when the capability is unsupported.
	CapabilityUnsupported Supported = "False"
)

Directories

Path Synopsis
Run go generate to regenerate this mock.
Run go generate to regenerate this mock.

Jump to

Keyboard shortcuts

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