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

@ -144,13 +144,24 @@ type Credentials struct {
type ResourceInstance[T ResourcePartnerITF] struct { type ResourceInstance[T ResourcePartnerITF] struct {
utils.AbstractObject utils.AbstractObject
Location GeoPoint `json:"location,omitempty" bson:"location,omitempty"` Location GeoPoint `json:"location,omitempty" bson:"location,omitempty"`
Country countries.CountryCode `json:"country,omitempty" bson:"country,omitempty"` Country countries.CountryCode `json:"country,omitempty" bson:"country,omitempty"`
AccessProtocol string `json:"access_protocol,omitempty" bson:"access_protocol,omitempty"` AccessProtocol string `json:"access_protocol,omitempty" bson:"access_protocol,omitempty"`
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"`
Partnerships []T `json:"partnerships,omitempty" bson:"partnerships,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"`
}
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() {
@ -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)