ensurePricing
This commit is contained in:
@@ -185,11 +185,28 @@ type PricedStorageResource struct {
|
||||
UsageStorageGB float64 `json:"storage_gb,omitempty" bson:"storage_gb,omitempty"`
|
||||
}
|
||||
|
||||
func (r *PricedStorageResource) ensurePricing() {
|
||||
if r.SelectedPricing == nil {
|
||||
r.SelectedPricing = &StorageResourcePricingProfile{}
|
||||
}
|
||||
}
|
||||
|
||||
func (r *PricedStorageResource) IsPurchasable() bool {
|
||||
r.ensurePricing()
|
||||
return r.SelectedPricing.IsPurchasable()
|
||||
}
|
||||
|
||||
func (r *PricedStorageResource) IsBooked() bool {
|
||||
r.ensurePricing()
|
||||
return r.SelectedPricing.IsBooked()
|
||||
}
|
||||
|
||||
func (r *PricedStorageResource) GetType() tools.DataType {
|
||||
return tools.STORAGE_RESOURCE
|
||||
}
|
||||
|
||||
func (r *PricedStorageResource) GetPriceHT() (float64, error) {
|
||||
r.ensurePricing()
|
||||
if r.BookingConfiguration == nil {
|
||||
r.BookingConfiguration = &BookingConfiguration{}
|
||||
}
|
||||
@@ -202,9 +219,6 @@ func (r *PricedStorageResource) GetPriceHT() (float64, error) {
|
||||
add := r.BookingConfiguration.UsageStart.Add(time.Duration(1 * time.Hour))
|
||||
r.BookingConfiguration.UsageEnd = &add
|
||||
}
|
||||
if r.SelectedPricing == nil {
|
||||
return 0, errors.New("pricing profile must be set on Priced Storage" + r.ResourceID)
|
||||
}
|
||||
pricing := r.SelectedPricing
|
||||
var err error
|
||||
amountOfData := float64(1)
|
||||
|
||||
Reference in New Issue
Block a user