Skip to content

Commit

Permalink
newProductDetails method move to the productinfo file
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Prekopcsák authored and matyix committed Jul 5, 2018
1 parent bb69352 commit 887d048
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 11 additions & 1 deletion pkg/productinfo/productinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (cpi *CachingProductInfo) GetProductDetails(cloud string, region string) ([

var pr Price
for i, vm := range vms {
pd := cpi.newProductDetails(vm, cloud)
pd := cpi.newProductDetails(cloud, vm)
if cachedVal, ok := cpi.vmAttrStore.Get(cpi.getPriceKey(cloud, region, vm.Type)); ok {
pr = cachedVal.(Price)
// fill the on demand price if appropriate
Expand All @@ -412,6 +412,16 @@ func (cpi *CachingProductInfo) GetProductDetails(cloud string, region string) ([
return details, nil
}

// newProductDetails creates a new ProductDetails struct and returns a pointer to it
func (cpi *CachingProductInfo) newProductDetails(provider string, vm VmInfo) *ProductDetails {
pd := ProductDetails{}
pd.VmInfo = vm
pd.Burst = vm.IsBurst()
ntwMapper, _ := cpi.GetNetworkPerfMapper(provider)
pd.NtwPerfCat = vm.NetworkPerformance(ntwMapper)
return &pd
}

// Contains is a helper function to check if a slice contains a string
func Contains(slice []string, s string) bool {
for _, e := range slice {
Expand Down
10 changes: 0 additions & 10 deletions pkg/productinfo/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,3 @@ type ProductDetailSource interface {
// GetProductDetails gathers the product details information known by telescope
GetProductDetails(cloud string, region string) ([]ProductDetails, error)
}

// newProductDetails creates a new ProductDetails struct and returns a pointer to it
func (cpi *CachingProductInfo) newProductDetails(vm VmInfo, provider string) *ProductDetails {
pd := ProductDetails{}
pd.VmInfo = vm
pd.Burst = vm.IsBurst()
ntwMapper, _ := cpi.GetNetworkPerfMapper(provider)
pd.NtwPerfCat = vm.NetworkPerformance(ntwMapper)
return &pd
}

0 comments on commit 887d048

Please sign in to comment.