From c53e25e69a7bcb19f57b09810164169ec00f0d1b Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 11 Feb 2025 09:16:18 +0100 Subject: [PATCH] add purchase resource in model catalog --- models/resources/compute.go | 4 ++-- models/resources/data.go | 2 +- models/resources/priced_resource.go | 2 +- models/resources/resource.go | 1 - models/resources/storage.go | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/models/resources/compute.go b/models/resources/compute.go index 06a76b7..7a0e014 100644 --- a/models/resources/compute.go +++ b/models/resources/compute.go @@ -148,9 +148,9 @@ func (r *PricedComputeResource) GetPrice() (float64, error) { } if r.SelectedPricing == nil { if len(r.PricingProfiles) == 0 { - return 0, errors.New("pricing profile must be set") + return 0, errors.New("pricing profile must be set on Priced Compute" + r.ResourceID) } - *r.SelectedPricing = r.PricingProfiles[0] + r.SelectedPricing = &r.PricingProfiles[0] } pricing := *r.SelectedPricing price := float64(0) diff --git a/models/resources/data.go b/models/resources/data.go index b3ebb03..774baaf 100644 --- a/models/resources/data.go +++ b/models/resources/data.go @@ -164,7 +164,7 @@ func (r *PricedDataResource) GetPrice() (float64, error) { if len(r.PricingProfiles) == 0 { return 0, errors.New("pricing profile must be set on Priced Data" + r.ResourceID) } - *r.SelectedPricing = r.PricingProfiles[0] + r.SelectedPricing = &r.PricingProfiles[0] } pricing := *r.SelectedPricing var err error diff --git a/models/resources/priced_resource.go b/models/resources/priced_resource.go index e553be9..ab0bfe6 100644 --- a/models/resources/priced_resource.go +++ b/models/resources/priced_resource.go @@ -86,7 +86,7 @@ func (r *PricedResource) GetPrice() (float64, error) { if len(r.PricingProfiles) == 0 { return 0, errors.New("pricing profile must be set on Priced Resource " + r.ResourceID) } - *r.SelectedPricing = 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/resource.go b/models/resources/resource.go index 2ade037..a9a7a57 100644 --- a/models/resources/resource.go +++ b/models/resources/resource.go @@ -182,7 +182,6 @@ func (ri *ResourcePartnerShip[T]) GetPricingsProfiles(peerID string, groups []st } for _, p := range ri.PeerGroups[peerID] { if slices.Contains(groups, p) { - for _, ri := range ri.PricingProfiles { profiles = append(profiles, ri) } diff --git a/models/resources/storage.go b/models/resources/storage.go index b09804e..9f43d69 100644 --- a/models/resources/storage.go +++ b/models/resources/storage.go @@ -175,7 +175,7 @@ func (r *PricedStorageResource) GetPrice() (float64, error) { if len(r.PricingProfiles) == 0 { return 0, errors.New("pricing profile must be set on Priced Storage" + r.ResourceID) } - *r.SelectedPricing = r.PricingProfiles[0] + r.SelectedPricing = &r.PricingProfiles[0] } pricing := *r.SelectedPricing var err error