Documentation ¶
Index ¶
- Constants
- func All(sku *SKU, conditions []FilterFn) bool
- func NameFilter(name string) func(*SKU) bool
- func ResourceTypeFilter(resourceType string) func(*SKU) bool
- type Cache
- func (c *Cache) Equal(other *Cache) bool
- func (c *Cache) Get(ctx context.Context, name, resourceType string) (SKU, bool)
- func (c *Cache) GetAvailabilityZones(ctx context.Context, filters ...FilterFn) []string
- func (c *Cache) GetVirtualMachineAvailabilityZones(ctx context.Context) []string
- func (c *Cache) GetVirtualMachineAvailabilityZonesForSize(ctx context.Context, size string) []string
- func (c *Cache) GetVirtualMachines(ctx context.Context) []SKU
- func (c *Cache) List(ctx context.Context, filters ...FilterFn) []SKU
- type CacheOption
- type ErrCapabilityNotFound
- type ErrCapabilityValueNil
- type ErrCapabilityValueParse
- type ErrClientNil
- type ErrClientNotNil
- type FilterFn
- type LazyCacheCreator
- type MapFn
- type NewCacheFunc
- type ResourceClient
- type ResourceProviderClient
- type SKU
- func (s *SKU) AvailabilityZones(location string) map[string]bool
- func (s *SKU) Equal(other *SKU) bool
- func (s *SKU) GetCapabilityQuantity(name string) (int64, error)
- func (s *SKU) GetLocation() string
- func (s *SKU) GetName() string
- func (s *SKU) GetResourceType() string
- func (s *SKU) HasCapability(name string) bool
- func (s *SKU) HasCapabilityWithCapacity(name string, value int64) (bool, error)
- func (s *SKU) HasCapabilityWithSeparator(name, value string) bool
- func (s *SKU) HasZonalCapability(name string) bool
- func (s *SKU) IsAvailable(location string) bool
- func (s *SKU) IsEncryptionAtHostSupported() bool
- func (s *SKU) IsEphemeralOSDiskSupported() bool
- func (s *SKU) IsResourceType(t string) bool
- func (s *SKU) IsRestricted(location string) bool
- func (s *SKU) IsUltraSSDAvailable() bool
- func (s *SKU) MaxCachedDiskBytes() (int64, error)
- func (s *SKU) Memory() (int64, error)
- func (s *SKU) VCPU() (int64, error)
- type Supported
Constants ¶
const ( // VirtualMachines is the . VirtualMachines = "virtualMachines" // Disks is a convenience constant to filter resource SKUs to only include disks. Disks = "disks" )
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 capacity. MemoryGB = "MemoryGB" // HyperVGenerations identifies the hyper-v generations this vm sku supports. HyperVGenerations = "HyperVGenerations" // EncryptionAtHost identifies the capability for accelerated networking support. EncryptionAtHost = "EncryptionAtHostSupported" // UltraSSDAvailable identifies the capability for ultra ssd // enablement. UltraSSDAvailable = "UltraSSDAvailable" // CachedDiskBytes identifies the maximum size of the cach disk for // a vm. CachedDiskBytes = "CachedDiskBytes" )
Variables ¶
This section is empty.
Functions ¶
func NameFilter ¶
NameFilter produces a filter function for the name of a resource sku.
func ResourceTypeFilter ¶
ResourceTypeFilter produces a filter function for any resource type.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores a list of known skus, possibly fetched with a provided client
func NewCache ¶
func NewCache(ctx context.Context, opts ...CacheOption) (*Cache, error)
NewCache instantiates a cache of resource sku data with a ResourceClient client, optionally with additional filtering by location. The accepted client interface matches the real Azure clients (it returns a paginated iterator).
func NewStaticCache ¶
func NewStaticCache(data []SKU, opts ...CacheOption) (*Cache, error)
NewStaticCache initializes a cache with data and no ability to refresh. Used for testing.
func (*Cache) GetAvailabilityZones ¶
GetAvailabilityZones returns the list of all availability zones in a given azure location.
func (*Cache) GetVirtualMachineAvailabilityZones ¶
GetVirtualMachineAvailabilityZones returns all virtual machine zones available in a given location.
func (*Cache) GetVirtualMachineAvailabilityZonesForSize ¶
func (c *Cache) GetVirtualMachineAvailabilityZonesForSize(ctx context.Context, size string) []string
GetVirtualMachineAvailabilityZonesForSize returns all virtual machine zones available in a given location.
func (*Cache) GetVirtualMachines ¶
GetVirtualMachines returns the list of all virtual machines *SKUs in a given azure location.
type CacheOption ¶
CacheOption describes functional options to customize the listing behavior of the cache.
func WithClient ¶
func WithClient(client client) CacheOption
WithClient is a functional option to use a cache backed by a client meeting the skewer signature.
func WithLocation ¶
func WithLocation(location string) CacheOption
WithLocation is a functional option to filter skus by location
func WithResourceClient ¶
func WithResourceClient(client ResourceClient) CacheOption
WithResourceClient is a functional option to use a cache backed by a ResourceClient.
func WithResourceProviderClient ¶
func WithResourceProviderClient(client ResourceProviderClient) CacheOption
WithResourceProviderClient is a functional option to use a cache backed by a ResourceProviderClient.
type ErrCapabilityNotFound ¶
type ErrCapabilityNotFound struct {
// contains filtered or unexported fields
}
ErrCapabilityNotFound will be returned when a capability could not be found, even without a value.
func (*ErrCapabilityNotFound) Error ¶
func (e *ErrCapabilityNotFound) Error() string
type ErrCapabilityValueNil ¶
type ErrCapabilityValueNil struct {
// contains filtered or unexported fields
}
ErrCapabilityValueNil will be returned when a capability was found by name but the value was nil.
func (*ErrCapabilityValueNil) Error ¶
func (e *ErrCapabilityValueNil) Error() string
type ErrCapabilityValueParse ¶
type ErrCapabilityValueParse struct {
// contains filtered or unexported fields
}
ErrCapabilityValueParse will be returned when a capability was found by name but the value was nil.
func (*ErrCapabilityValueParse) Error ¶
func (e *ErrCapabilityValueParse) Error() string
type ErrClientNil ¶
type ErrClientNil struct { }
ErrClientNil will be returned when a user attempts to create a cache without a client and use it.
func (*ErrClientNil) Error ¶
func (e *ErrClientNil) Error() string
type ErrClientNotNil ¶
type ErrClientNotNil struct { }
ErrClientNotNil will be returned when a user attempts to set two clients on the same cache.
func (*ErrClientNotNil) Error ¶
func (e *ErrClientNotNil) Error() string
type LazyCacheCreator ¶
type LazyCacheCreator struct {
// contains filtered or unexported fields
}
LazyCacheCreator is a convenience type for lazily instantiating caches.
func NewLazyCacheCreator ¶
func NewLazyCacheCreator() *LazyCacheCreator
NewLazyCacheCreator instantiates a lazy cache creator.
func (*LazyCacheCreator) GetCache ¶
func (l *LazyCacheCreator) GetCache(ctx context.Context, opts ...CacheOption) (*Cache, error)
GetCache returns the wrapped cache or instantiates a new one, storing it before returning a reference to it.
type NewCacheFunc ¶
type NewCacheFunc func(ctx context.Context, opts ...CacheOption) (*Cache, error)
NewCacheFunc describes the live cache instantiation signature. Used for testing.
type ResourceClient ¶
type ResourceClient interface {
ListComplete(ctx context.Context, filter string) (compute.ResourceSkusResultIterator, error)
}
ResourceClient is the required Azure client interface used to populate skewer's data.
type ResourceProviderClient ¶
type ResourceProviderClient interface {
List(ctx context.Context, filter string) (compute.ResourceSkusResultPage, error)
}
ResourceProviderClient is a convenience interface for uses cases specific to Azure resource providers.
type SKU ¶
type SKU compute.ResourceSku
SKU wraps an Azure compute SKU with richer functionality
func Filter ¶
Filter returns a new slice containing all values in the slice that satisfy all filterFn predicates.
func Map ¶
Map returns a new slice containing the results of applying the mapFn to each value in the original slice.
func (*SKU) AvailabilityZones ¶
AvailabilityZones returns the list of Availability Zones which have this resource SKU available and unrestricted.
func (*SKU) GetCapabilityQuantity ¶
GetCapabilityQuantity retrieves and parses the value of a numeric capability with the provided name. It errors if the capability is not found, the value was nil, or the value could not be parsed as an integer.
func (*SKU) GetLocation ¶
GetLocation returns the first found location on this *SKU resource. Typically only one should be listed (multiple SKU results will be returned for multiple regions). We fallback to locationInfo although this appears to be duplicate info.
func (*SKU) GetName ¶
GetName returns the name of this resource sku. It normalizes pointers to the empty string for comparison purposes. For example, "Standard_D8s_v3" for a virtual machine.
func (*SKU) GetResourceType ¶
GetResourceType returns the name of this resource sku. It normalizes pointers to the empty string for comparison purposes. For example, "virtualMachines" for a virtual machine.
func (*SKU) HasCapability ¶
HasCapability return true for a capability which can be either supported or not. Examples include "EphemeralOSDiskSupported", "EncryptionAtHostSupported", "AcceleratedNetworkingEnabled", and "RdmaEnabled"
func (*SKU) HasCapabilityWithCapacity ¶
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) HasCapabilityWithSeparator ¶
HasCapabilityWithSeparator return true for a capability which may be exposed as a comma-separated list. We check that the list contains the desired substring. An example is "HyperVGenerations" which may be "V1,V2"
func (*SKU) HasZonalCapability ¶
HasZonalCapability return true for a capability which can be either supported or not. Examples include "UltraSSDAvailable". This function only checks that zone details suggest support: it will return true for a whole location even when only one zone supports the feature. Currently, the only real scenario that appears to use zoneDetails is UltraSSDAvailable which always lists all regions as available. TODO(ace): update this function signature/behavior if necessary to account for per-zone availability.
func (*SKU) IsAvailable ¶
IsAvailable returns true when the requested location matches one on the sku, and there are no total restrictions on the location.
func (*SKU) IsEncryptionAtHostSupported ¶
func (*SKU) IsEphemeralOSDiskSupported ¶
func (*SKU) IsResourceType ¶
IsResourceType returns true when the wrapped SKU has the provided value as its resource type. This may be used to filter using values such as "virtualMachines", "disks", "availabilitySets", "snapshots", and "hostGroups/hosts".
func (*SKU) IsRestricted ¶
IsRestricted returns true when a location restriction exists for this SKU.
func (*SKU) IsUltraSSDAvailable ¶
func (*SKU) MaxCachedDiskBytes ¶
type Supported ¶
type Supported string
Supported models an enum of possible boolean values for resource support in the Azure API.
const ( // CapabilitySupported is an enum value for the string "True" returned when a SKU supports a binary capability. CapabilitySupported Supported = "True" // CapabilityUnupported is an enum value for the string "True" returned when a SKU does not support a binary capability. CapabilityUnupported Supported = "False" )