resourceskus

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 13 Imported by: 1

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

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureClient

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

AzureClient contains the Azure go-sdk Client.

func NewClient

func NewClient(auth azure.Authorizer) *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(auth azure.Authorizer, location string) (*Cache, error)

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

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(azure.Authorizer, string) *Cache

NewCacheFunc allows for mocking out the underlying client.

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

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

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

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