draft of compute units catalog

This commit is contained in:
mr 2025-06-17 16:14:44 +02:00
parent 9e52663261
commit 0b0952b28c
2 changed files with 19 additions and 10 deletions

View File

@ -25,6 +25,7 @@ type ResourceInstanceITF interface {
GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF
GetPeerGroups() ([]ResourcePartnerITF, []map[string][]string) GetPeerGroups() ([]ResourcePartnerITF, []map[string][]string)
ClearPeerGroups() ClearPeerGroups()
GetSelectedPartnership() ResourcePartnerITF
GetPartnerships(peerID string, groups []string) []ResourcePartnerITF GetPartnerships(peerID string, groups []string) []ResourcePartnerITF
} }

View File

@ -150,9 +150,20 @@ type ResourceInstance[T ResourcePartnerITF] struct {
Env []models.Param `json:"env,omitempty" bson:"env,omitempty"` Env []models.Param `json:"env,omitempty" bson:"env,omitempty"`
Inputs []models.Param `json:"inputs,omitempty" bson:"inputs,omitempty"` Inputs []models.Param `json:"inputs,omitempty" bson:"inputs,omitempty"`
Outputs []models.Param `json:"outputs,omitempty" bson:"outputs,omitempty"` Outputs []models.Param `json:"outputs,omitempty" bson:"outputs,omitempty"`
SelectedPartnershipIndex *int `json:"selected_partnership_index,omitempty" bson:"selected_partnership_index,omitempty"` // SelectedInstance is the selected instance
Partnerships []T `json:"partnerships,omitempty" bson:"partnerships,omitempty"` Partnerships []T `json:"partnerships,omitempty" bson:"partnerships,omitempty"`
} }
func (r *ResourceInstance[T]) GetSelectedPartnership() ResourcePartnerITF {
if r.SelectedPartnershipIndex != nil && len(r.Partnerships) > *r.SelectedPartnershipIndex {
return r.Partnerships[*r.SelectedPartnershipIndex]
}
if len(r.Partnerships) > 0 {
return r.Partnerships[0]
}
return nil
}
func (ri *ResourceInstance[T]) ClearEnv() { func (ri *ResourceInstance[T]) ClearEnv() {
ri.Env = []models.Param{} ri.Env = []models.Param{}
ri.Inputs = []models.Param{} ri.Inputs = []models.Param{}
@ -206,9 +217,6 @@ type ResourcePartnerShip[T pricing.PricingProfileITF] struct {
func (ri *ResourcePartnerShip[T]) GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF { func (ri *ResourcePartnerShip[T]) GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF {
profiles := []pricing.PricingProfileITF{} profiles := []pricing.PricingProfileITF{}
if ri.PeerGroups[peerID] != nil { if ri.PeerGroups[peerID] != nil {
for _, ri := range ri.PricingProfiles {
profiles = append(profiles, ri)
}
if slices.Contains(groups, "*") { if slices.Contains(groups, "*") {
for _, ri := range ri.PricingProfiles { for _, ri := range ri.PricingProfiles {
profiles = append(profiles, ri) profiles = append(profiles, ri)