Documentation ¶
Index ¶
- Constants
- Variables
- func Attributes(cpu, memory, ntwPerfCat, vmCategory string) map[string]string
- func Contains(slice []string, s string) bool
- func CreateString(keys ...string) string
- func NewCloudInfo(providers []string, ciStore CloudInfoStore, logger Logger) (*cloudInfo, error)
- func NewScrapingManager(provider string, infoer CloudInfoer, store CloudInfoStore, log Logger, ...) *scrapingManager
- type CloudInfoStore
- type CloudInfoer
- type ErrorHandler
- type Executor
- type FloatFilter
- type InMemoryInstanceTypeStore
- type InMemoryProviderStore
- type InMemoryRegionStore
- type InMemoryServiceStore
- type InstanceType
- type InstanceTypeCategory
- type InstanceTypeCategoryFilter
- type InstanceTypeQuery
- type InstanceTypeQueryFilter
- type InstanceTypeQueryValidationError
- type InstanceTypeService
- type InstanceTypeStore
- type IntFilter
- type Logger
- type NetworkCategory
- type NetworkCategoryFilter
- type PeriodicExecutor
- type Provider
- type ProviderService
- type ProviderStore
- type Region
- type RegionService
- type RegionStore
- type ScrapingDriver
- type Service
- type ServiceService
- type ServiceStore
- type TaskFn
- type Zone
Constants ¶
const ( // vmKeyTemplate format for generating vm cache keys VmKeyTemplate = "/banzaicloud.com/cloudinfo/providers/%s/services/%s/regions/%s/vms" // priceKeyTemplate format for generating price cache keys PriceKeyTemplate = "/banzaicloud.com/cloudinfo/providers/%s/regions/%s/prices/%s" // zoneKeyTemplate format for generating zone cache keys ZoneKeyTemplate = "/banzaicloud.com/cloudinfo/providers/%s/services/%s/regions/%s/zones/" // regionKeyTemplate format for generating region cache keys RegionKeyTemplate = "/banzaicloud.com/cloudinfo/providers/%s/services/%s/regions/" // statusKeyTemplate format for generating status cache keys StatusKeyTemplate = "/banzaicloud.com/cloudinfo/providers/%s/status/" // imageKeyTemplate format for generating image cache keys ImageKeyTemplate = "/banzaicloud.com/cloudinfo/providers/%s/services/%s/regions/%s/images" // versionKeyTemplate format for generating kubernetes version cache keys VersionKeyTemplate = "/banzaicloud.com/cloudinfo/providers/%s/services/%s/regions/%s/versions" // servicesKeyTemplate key for storing provider specific services ServicesKeyTemplate = "/banzaicloud.com/cloudinfo/providers/%s/services" )
Variables ¶
var AllInstanceTypeCategory = []InstanceTypeCategory{ InstanceTypeCategoryGeneralPurpose, InstanceTypeCategoryMemoryOptimized, InstanceTypeCategoryStorageOptimized, InstanceTypeCategoryComputeOptimized, }
var AllNetworkCategory = []NetworkCategory{ NetworkCategoryLow, NetworkCategoryModerate, NetworkCategoryHigh, }
Functions ¶
func Attributes ¶
Attributes create a map with the specified parameters
func CreateString ¶
CreateString builds strings effectively
func NewCloudInfo ¶
func NewCloudInfo(providers []string, ciStore CloudInfoStore, logger Logger) (*cloudInfo, error)
NewCloudInfo creates a new cloudInfo instance
func NewScrapingManager ¶
func NewScrapingManager(provider string, infoer CloudInfoer, store CloudInfoStore, log Logger, metrics metrics.Reporter, tracer tracing.Tracer, eventBus messaging.EventBus, errorHandler ErrorHandler) *scrapingManager
Types ¶
type CloudInfoStore ¶
type CloudInfoStore interface { Ready() bool StoreRegions(provider, service string, val map[string]string) GetRegions(provider, service string) (map[string]string, bool) DeleteRegions(provider, service string) StoreZones(provider, service, region string, val []string) GetZones(provider, service, region string) ([]string, bool) DeleteZones(provider, service, region string) StorePrice(provider, region, instanceType string, val types.Price) GetPrice(provider, region, instanceType string) (types.Price, bool) StoreVm(provider, service, region string, val []types.VMInfo) GetVm(provider, service, region string) ([]types.VMInfo, bool) DeleteVm(provider, service, region string) StoreImage(provider, service, regionId string, val []types.Image) GetImage(provider, service, regionId string) ([]types.Image, bool) DeleteImage(provider, service, regionId string) StoreVersion(provider, service, region string, val []types.LocationVersion) GetVersion(provider, service, region string) ([]types.LocationVersion, bool) DeleteVersion(provider, service, region string) StoreStatus(provider string, val string) GetStatus(provider string) (string, bool) StoreServices(provider string, services []types.Service) GetServices(provider string) ([]types.Service, bool) Export(w io.Writer) error Import(r io.Reader) error Close() }
Storage operations for cloud information
type CloudInfoer ¶
type CloudInfoer interface { // Initialize is called once per product info renewals so it can be used to download a large price descriptor Initialize() (map[string]map[string]types.Price, error) // GetVirtualMachines retrieves the available virtual machines in a region GetVirtualMachines(region string) ([]types.VMInfo, error) // GetProducts gets product information based on the given arguments from an external system GetProducts(vms []types.VMInfo, service, regionId string) ([]types.VMInfo, error) // GetZones returns the availability zones in a region GetZones(region string) ([]string, error) // GetRegions retrieves the available regions form the external system GetRegions(service string) (map[string]string, error) // HasShortLivedPriceInfo signals if a product info provider has frequently changing price info HasShortLivedPriceInfo() bool // GetCurrentPrices retrieves all the spot prices in a region GetCurrentPrices(region string) (map[string]types.Price, error) // HasImages signals if a product info provider has image support HasImages() bool // GetServiceImages retrieves the images supported by the given service in the given region GetServiceImages(service, region string) ([]types.Image, error) // GetVersions retrieves the versions supported by the given service in the given region GetVersions(service, region string) ([]types.LocationVersion, error) // GetServiceProducts retrieves the products supported by the given service in the given region GetServiceProducts(region, service string) ([]types.ProductDetails, error) }
CloudInfoer lists operations for retrieving cloud provider information Implementers are expected to know the cloud provider specific logic (eg.: cloud provider client usage etc ...) This interface abstracts the cloud provider specifics to its clients
type ErrorHandler ¶
type ErrorHandler interface { // Handle handles an error. Handle(err error) }
ErrorHandler handles an error.
type FloatFilter ¶
type FloatFilter struct { Lt *float64 Lte *float64 Gt *float64 Gte *float64 Eq *float64 Ne *float64 In []float64 Nin []float64 }
FloatFilter represents the query operators for a float field.
type InMemoryInstanceTypeStore ¶
type InMemoryInstanceTypeStore struct {
// contains filtered or unexported fields
}
InMemoryInstanceTypeStore keeps instance types in the memory. Use it in tests or for development/demo purposes.
func NewInMemoryInstanceTypeStore ¶
func NewInMemoryInstanceTypeStore() *InMemoryInstanceTypeStore
NewInMemoryInstanceTypeStore returns a new InMemoryInstanceTypeStore.
func (*InMemoryInstanceTypeStore) GetProductDetails ¶
func (s *InMemoryInstanceTypeStore) GetProductDetails(provider string, service string, region string) ([]types.ProductDetails, error)
GetProductDetails retrieves product details from the given provider and region.
type InMemoryProviderStore ¶
type InMemoryProviderStore struct {
// contains filtered or unexported fields
}
InMemoryProviderStore keeps providers in the memory. Use it in tests or for development/demo purposes.
func NewInMemoryProviderStore ¶
func NewInMemoryProviderStore() *InMemoryProviderStore
NewInMemoryProviderStore returns a new InMemoryProviderStore.
func (*InMemoryProviderStore) GetProviders ¶
func (s *InMemoryProviderStore) GetProviders() ([]types.Provider, error)
type InMemoryRegionStore ¶
type InMemoryRegionStore struct {
// contains filtered or unexported fields
}
InMemoryRegionStore keeps regions in the memory. Use it in tests or for development/demo purposes.
func NewInMemoryRegionStore ¶
func NewInMemoryRegionStore() *InMemoryRegionStore
NewInMemoryRegionStore returns a new InMemoryRegionStore.
func (*InMemoryRegionStore) GetRegions ¶
type InMemoryServiceStore ¶
type InMemoryServiceStore struct {
// contains filtered or unexported fields
}
InMemoryServiceStore keeps services in the memory. Use it in tests or for development/demo purposes.
func NewInMemoryServiceStore ¶
func NewInMemoryServiceStore() *InMemoryServiceStore
NewInMemoryServiceStore returns a new InMemoryServiceStore.
func (*InMemoryServiceStore) GetServices ¶
func (s *InMemoryServiceStore) GetServices(provider string) ([]types.Service, error)
type InstanceType ¶
type InstanceType struct { Name string Region string Zone string Price float64 SpotPrice float64 CPU float64 Memory float64 Gpu float64 NetworkCategory NetworkCategory Category InstanceTypeCategory }
InstanceType represents a single instance type.
type InstanceTypeCategory ¶
type InstanceTypeCategory string
const ( InstanceTypeCategoryGeneralPurpose InstanceTypeCategory = "GENERAL_PURPOSE" InstanceTypeCategoryMemoryOptimized InstanceTypeCategory = "MEMORY_OPTIMIZED" InstanceTypeCategoryStorageOptimized InstanceTypeCategory = "STORAGE_OPTIMIZED" InstanceTypeCategoryComputeOptimized InstanceTypeCategory = "COMPUTE_OPTIMIZED" )
func (InstanceTypeCategory) IsValid ¶
func (e InstanceTypeCategory) IsValid() bool
func (InstanceTypeCategory) MarshalGQL ¶
func (e InstanceTypeCategory) MarshalGQL(w io.Writer)
func (InstanceTypeCategory) String ¶
func (e InstanceTypeCategory) String() string
func (*InstanceTypeCategory) UnmarshalGQL ¶
func (e *InstanceTypeCategory) UnmarshalGQL(v interface{}) error
type InstanceTypeCategoryFilter ¶
type InstanceTypeCategoryFilter struct { Eq *InstanceTypeCategory Ne *InstanceTypeCategory In []InstanceTypeCategory Nin []InstanceTypeCategory }
IntFilter represents the query operators for an instance type network category field.
type InstanceTypeQuery ¶
type InstanceTypeQuery struct { Region *string Zone *string Filter *InstanceTypeQueryFilter }
InstanceTypeQuery represents the input parameters if an instance type query.
type InstanceTypeQueryFilter ¶
type InstanceTypeQueryFilter struct { Price *FloatFilter SpotPrice *FloatFilter Spot *bool CPU *FloatFilter Memory *FloatFilter Gpu *FloatFilter NetworkCategory *NetworkCategoryFilter Category *InstanceTypeCategoryFilter }
InstanceTypeQueryFilter filters instance types by their fields.
type InstanceTypeQueryValidationError ¶
type InstanceTypeQueryValidationError struct {
Message string
}
InstanceTypeQueryValidationError is returned if an instance type query is invalid.
func (InstanceTypeQueryValidationError) Error ¶
func (e InstanceTypeQueryValidationError) Error() string
Error implements the error interface.
func (InstanceTypeQueryValidationError) IsBusinessError ¶
func (InstanceTypeQueryValidationError) IsBusinessError() bool
IsBusinessError tells the transport layer whether this error should be translated into the transport format or an internal error should be returned instead.
type InstanceTypeService ¶
type InstanceTypeService struct {
// contains filtered or unexported fields
}
InstanceTypeService filters instance types according to the received query.
func NewInstanceTypeService ¶
func NewInstanceTypeService(store InstanceTypeStore) *InstanceTypeService
NewInstanceTypeService returns a new InstanceTypeService.
func (*InstanceTypeService) Query ¶
func (s *InstanceTypeService) Query(ctx context.Context, provider string, service string, query InstanceTypeQuery) ([]InstanceType, error)
Query processes an instance type query and responds with a list match of instance types matching that query.
type InstanceTypeStore ¶
type InstanceTypeStore interface { // GetProductDetails retrieves product details from the given provider and region. GetProductDetails(provider string, service string, region string) ([]types.ProductDetails, error) // GetZones returns all the availability zones for a region. GetZones(provider, service, region string) ([]string, error) }
InstanceTypeStore retrieves instance types from the given provider and region.
type Logger ¶
type Logger interface { // Trace logs a debug event. Trace(msg string, fields ...map[string]interface{}) // Debug logs a debug event. Debug(msg string, fields ...map[string]interface{}) // Info logs an info event. Info(msg string, fields ...map[string]interface{}) // Warn logs a warning event. Warn(msg string, fields ...map[string]interface{}) // Error logs an error event. Error(msg string, fields ...map[string]interface{}) // WithFields annotates a logger with key-value pairs. WithFields(fields map[string]interface{}) Logger // WithContext annotates a logger with a context. WithContext(ctx context.Context) Logger }
Logger is the fundamental interface for all log operations.
type NetworkCategory ¶
type NetworkCategory string
const ( NetworkCategoryLow NetworkCategory = "LOW" NetworkCategoryModerate NetworkCategory = "MODERATE" NetworkCategoryHigh NetworkCategory = "HIGH" )
func (NetworkCategory) IsValid ¶
func (e NetworkCategory) IsValid() bool
func (NetworkCategory) MarshalGQL ¶
func (e NetworkCategory) MarshalGQL(w io.Writer)
func (NetworkCategory) String ¶
func (e NetworkCategory) String() string
func (*NetworkCategory) UnmarshalGQL ¶
func (e *NetworkCategory) UnmarshalGQL(v interface{}) error
type NetworkCategoryFilter ¶
type NetworkCategoryFilter struct { Eq *NetworkCategory Ne *NetworkCategory In []NetworkCategory Nin []NetworkCategory }
IntFilter represents the query operators for an instance type network category field.
type PeriodicExecutor ¶
type PeriodicExecutor struct {
// contains filtered or unexported fields
}
PeriodicExecutor Executor that periodically executes the passed in task function
type ProviderService ¶
type ProviderService struct {
// contains filtered or unexported fields
}
ProviderService returns the list of supported providers and relevant information.
func NewProviderService ¶
func NewProviderService(store ProviderStore) *ProviderService
NewProviderService returns a new ProviderService.
func (*ProviderService) ListProviders ¶
func (s *ProviderService) ListProviders(ctx context.Context) ([]Provider, error)
ListProviders returns a list of providers.
type ProviderStore ¶
type ProviderStore interface { // GetProviders returns the supported providers. GetProviders() ([]types.Provider, error) }
ProviderStore retrieves providers.
type Region ¶
Region is a general area in which a cloud provider has services available.
func (*Region) ProviderName ¶
ProviderName returns the provider name of the region. Used when resolving zones based on a region.
func (*Region) ServiceName ¶
ServiceName returns the service name of the region. Used when resolving zones based on a region.
type RegionService ¶
type RegionService struct {
// contains filtered or unexported fields
}
RegionService provides access to regions supported by a service.
func NewRegionService ¶
func NewRegionService(store RegionStore) *RegionService
NewRegionService returns a new RegionService.
func (*RegionService) ListRegions ¶
func (s *RegionService) ListRegions(ctx context.Context, provider string, service string) ([]Region, error)
ListRegions returns a list of regions supported by a service.
type RegionStore ¶
type RegionStore interface { // GetRegions returns the supported regions for a service. GetRegions(provider string, service string) (map[string]string, error) // GetZones returns the supported zones within a region. GetZones(provider string, service string, region string) ([]string, error) }
RegionStore retrieves regions.
type ScrapingDriver ¶
type ScrapingDriver struct {
// contains filtered or unexported fields
}
func NewScrapingDriver ¶
func NewScrapingDriver(renewalInterval time.Duration, infoers map[string]CloudInfoer, store CloudInfoStore, eventBus messaging.EventBus, metrics metrics.Reporter, tracer tracing.Tracer, errorHandler ErrorHandler, log Logger) *ScrapingDriver
func (*ScrapingDriver) RefreshProvider ¶
func (sd *ScrapingDriver) RefreshProvider(ctx context.Context, provider string)
func (*ScrapingDriver) StartScraping ¶
func (sd *ScrapingDriver) StartScraping() error
type Service ¶
type Service struct { Code string // contains filtered or unexported fields }
Service represents a single service.
func (*Service) ProviderName ¶
ProviderName returns the provider name of the service. Used when resolving regions based on a service.
type ServiceService ¶
type ServiceService struct {
// contains filtered or unexported fields
}
ServiceService returns the list of supported services.
func NewServiceService ¶
func NewServiceService(store ServiceStore) *ServiceService
NewServiceService returns a new ServiceService.
func (*ServiceService) ListServices ¶
ListServices returns a list of services supported by a provider.