Documentation
¶
Index ¶
- Constants
- func All(sku *SKU, conditions []FilterFn) bool
- func LocationFilter(location string) func(*SKU) bool
- func NameFilter(name string) func(*SKU) bool
- func ResourceTypeFilter(resourceType string) func(*SKU) bool
- func UnsafeLocationFilter(location string) func(*SKU) bool
- type Cache
- func (c *Cache) Equal(other *Cache) bool
- func (c *Cache) Get(ctx context.Context, name, resourceType, location string) (SKU, error)
- 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 Config
- type ErrCapabilityNotFound
- type ErrCapabilityValueNil
- type ErrCapabilityValueParse
- type ErrClientNil
- type ErrClientNotNil
- type ErrMultipleSKUsMatch
- type ErrSKUNotFound
- type FilterFn
- type MapFn
- type NewCacheFunc
- type Option
- 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) GetCapabilityFloatQuantity(name string) (float64, error)
- func (s *SKU) GetCapabilityIntegerQuantity(name string) (int64, error)
- func (s *SKU) GetLocation() (string, error)
- 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) HasLocation(location string) bool
- func (s *SKU) HasLocationRestriction(location 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() (float64, 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 LocationFilter ¶ added in v0.0.4
LocationFilter matches against a SKU listing the given location
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.
func UnsafeLocationFilter ¶ added in v0.0.5
UnsafeLocationFilter produces a filter function for the location of a resource sku. This function dangerously ignores all SKUS without a properly specified location. Use this only if you know what you are doing.
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 ¶
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 ¶
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 Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config contains configuration options for a cache.
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 ErrMultipleSKUsMatch ¶ added in v0.0.7
ErrMultipleSKUsMatch will be returned when multiple skus match a fully qualified triple of resource type, location and name. This should usually not happen.
func (*ErrMultipleSKUsMatch) Error ¶ added in v0.0.7
func (e *ErrMultipleSKUsMatch) Error() string
type ErrSKUNotFound ¶ added in v0.0.7
ErrSKUNotFound will be returned when no skus match a fully qualified triple of resource type, location and name. The SKU may not exist.
func (*ErrSKUNotFound) Error ¶ added in v0.0.7
func (e *ErrSKUNotFound) Error() string
type NewCacheFunc ¶
NewCacheFunc describes the live cache instantiation signature. Used for testing.
type Option ¶
Option describes functional options to customize the listing behavior of the cache.
func WithClient ¶
func WithClient(client client) Option
WithClient is a functional option to use a cache backed by a client meeting the skewer signature.
func WithLocation ¶
WithLocation is a functional option to filter skus by location
func WithResourceClient ¶
func WithResourceClient(client ResourceClient) Option
WithResourceClient is a functional option to use a cache backed by a ResourceClient.
func WithResourceProviderClient ¶
func WithResourceProviderClient(client ResourceProviderClient) Option
WithResourceProviderClient is a functional option to use a cache backed by a ResourceProviderClient.
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 Wrap ¶
func Wrap(in []compute.ResourceSku) []SKU
Wrap takes an array of compute resource skus and wraps them into an array of our richer type.
func (*SKU) AvailabilityZones ¶
AvailabilityZones returns the list of Availability Zones which have this resource SKU available and unrestricted.
func (*SKU) GetCapabilityFloatQuantity ¶
GetCapabilityFloatQuantity retrieves and parses the value of a floating point 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) GetCapabilityIntegerQuantity ¶
GetCapabilityIntegerQuantity retrieves and parses the value of an integer 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 location for a given SKU.
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) HasLocation ¶ added in v0.0.7
HasLocation returns true if the given sku exposes this region for deployment.
func (*SKU) HasLocationRestriction ¶ added in v0.0.7
HasLocationRestriction returns true if the location is restricted for this sku.
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" // CapabilityUnsupported is an enum value for the string "False" returned when a SKU does not support a binary capability. CapabilityUnsupported Supported = "False" )