add purchase resource in model catalog

This commit is contained in:
mr 2025-02-11 08:30:38 +01:00
parent a573a4ce71
commit ffaa67fb5d
2 changed files with 13 additions and 3 deletions

View File

@ -84,7 +84,7 @@ func (r *PricedResource) GetPrice() (float64, error) {
}
if r.SelectedPricing == nil {
if len(r.PricingProfiles) == 0 {
return 0, errors.New("pricing profile must be set on Priced Resource" + r.ResourceID)
return 0, errors.New("pricing profile must be set on Priced Resource " + r.ResourceID)
}
*r.SelectedPricing = r.PricingProfiles[0]
}

View File

@ -169,10 +169,20 @@ type ResourcePartnerShip[T pricing.PricingProfileITF] struct {
}
func (ri *ResourcePartnerShip[T]) GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF {
profiles := []pricing.PricingProfileITF{}
if ri.PeerGroups[peerID] != nil {
for _, ri := range ri.PricingProfiles {
profiles = append(profiles, ri)
}
if slices.Contains(groups, "*") {
for _, ri := range ri.PricingProfiles {
profiles = append(profiles, ri)
}
return profiles
}
for _, p := range ri.PeerGroups[peerID] {
if slices.Contains(groups, p) {
profiles := []pricing.PricingProfileITF{}
for _, ri := range ri.PricingProfiles {
profiles = append(profiles, ri)
}
@ -180,7 +190,7 @@ func (ri *ResourcePartnerShip[T]) GetPricingsProfiles(peerID string, groups []st
}
}
}
return []pricing.PricingProfileITF{}
return profiles
}
func (rp *ResourcePartnerShip[T]) GetPeerGroups() map[string][]string {