diff --git a/models/resources/compute.go b/models/resources/compute.go index 071aaf4..06a76b7 100644 --- a/models/resources/compute.go +++ b/models/resources/compute.go @@ -146,13 +146,13 @@ func (r *PricedComputeResource) GetPrice() (float64, error) { add := r.UsageStart.Add(time.Duration(1 * time.Hour)) r.UsageEnd = &add } - pricing := *r.SelectedPricing - if pricing == nil { + if r.SelectedPricing == nil { if len(r.PricingProfiles) == 0 { return 0, errors.New("pricing profile must be set") } - pricing = r.PricingProfiles[0] + *r.SelectedPricing = r.PricingProfiles[0] } + pricing := *r.SelectedPricing price := float64(0) for _, l := range []map[string]float64{r.CPUsLocated, r.GPUsLocated} { for model, amountOfData := range l { diff --git a/models/resources/data.go b/models/resources/data.go index 2b1636d..e94e61b 100644 --- a/models/resources/data.go +++ b/models/resources/data.go @@ -161,15 +161,12 @@ func (r *PricedDataResource) GetPrice() (float64, error) { r.UsageEnd = &add } if r.SelectedPricing == nil { - return 0, errors.New("selected pricing must be set") - } - pricing := *r.SelectedPricing - if pricing == nil { if len(r.PricingProfiles) == 0 { return 0, errors.New("pricing profile must be set") } - pricing = r.PricingProfiles[0] + *r.SelectedPricing = r.PricingProfiles[0] } + pricing := *r.SelectedPricing var err error amountOfData := float64(1) if pricing.GetOverrideStrategyValue() >= 0 { diff --git a/models/resources/priced_resource.go b/models/resources/priced_resource.go index 4184d68..7858e30 100644 --- a/models/resources/priced_resource.go +++ b/models/resources/priced_resource.go @@ -82,12 +82,12 @@ func (r *PricedResource) GetPrice() (float64, error) { add := r.UsageStart.Add(time.Duration(1 * time.Hour)) r.UsageEnd = &add } - pricing := *r.SelectedPricing - if pricing == nil { + if r.SelectedPricing == nil { if len(r.PricingProfiles) == 0 { return 0, errors.New("pricing profile must be set") } - pricing = r.PricingProfiles[0] + *r.SelectedPricing = r.PricingProfiles[0] } + pricing := *r.SelectedPricing return pricing.GetPrice(1, 0, *r.UsageStart, *r.UsageEnd) } diff --git a/models/resources/storage.go b/models/resources/storage.go index 02212ed..2113b1b 100644 --- a/models/resources/storage.go +++ b/models/resources/storage.go @@ -171,13 +171,13 @@ func (r *PricedStorageResource) GetPrice() (float64, error) { add := r.UsageStart.Add(time.Duration(1 * time.Hour)) r.UsageEnd = &add } - pricing := *r.SelectedPricing - if pricing == nil { + if r.SelectedPricing == nil { if len(r.PricingProfiles) == 0 { return 0, errors.New("pricing profile must be set") } - pricing = r.PricingProfiles[0] + *r.SelectedPricing = r.PricingProfiles[0] } + pricing := *r.SelectedPricing var err error amountOfData := float64(1) if pricing.GetOverrideStrategyValue() >= 0 {