Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions models/meshmodel/core/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const (
ComponentDefinition CapabilityType = "component"
PolicyDefinition CapabilityType = "policy"
RelationshipDefinition CapabilityType = "relationship"
Model CapabilityType = "model"
)

// Each entity will have it's own Filter implementation via which it exposes the nobs and dials to fetch entities
Expand Down
11 changes: 11 additions & 0 deletions models/meshmodel/core/v1alpha1/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/google/uuid"
"github.com/layer5io/meshkit/database"
"github.com/layer5io/meshkit/models/meshmodel/core/types"
"gorm.io/gorm"
)

Expand Down Expand Up @@ -38,6 +39,9 @@ type Model struct {
Version string `json:"version"`
DisplayName string `json:"displayName" gorm:"modelDisplayName"`
Category Category `json:"category"`
HostID uuid.UUID `json:"hostID"`
HostName string `json:"hostName"`
DisplayHostName string `json:"displayHostName"`
Metadata map[string]interface{} `json:"metadata" yaml:"modelMetadata"`
}
type ModelDB struct {
Expand Down Expand Up @@ -99,3 +103,10 @@ func (c *Model) GetModelDB() (cmd ModelDB) {
cmd.Metadata, _ = json.Marshal(c.Metadata)
return
}

func (r Model) Type() types.CapabilityType {
return types.Model
}
func (r Model) GetID() uuid.UUID {
return r.ID
}
7 changes: 7 additions & 0 deletions models/meshmodel/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ func (rm *RegistryManager) GetEntities(f types.Filter) ([]Entity, *int64, *int)
en = append(en, pol)
}
return en, nil, nil
case *v1alpha1.ModelFilter:
en := make([]Entity, 0)
models, count, _ := rm.GetModels(rm.db, filter)
for _, model := range models {
en = append(en, model)
}
return en, &count, nil
default:
return nil, nil, nil
}
Expand Down