Skip to content

Commit

Permalink
add support to filter models based on annotation property
Browse files Browse the repository at this point in the history
Signed-off-by: MUzairS15 <muzair.shaikh810@gmail.com>
  • Loading branch information
MUzairS15 committed Dec 2, 2023
1 parent 327c100 commit 803ac87
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions models/meshmodel/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ func (rm *RegistryManager) GetModels(db *database.Handler, f types.Filter) ([]v1
finder = finder.Where("model_dbs.display_name = ?", mf.DisplayName)
}
}
if mf.Annotations == "true" {
finder = finder.Where("model_dbs.metadata->>'isAnnotation' = true")
} else if mf.Annotations == "false" {
finder = finder.Where("model_dbs.metadata->>'isAnnotation' = false")
}
if mf.Version != "" {
finder = finder.Where("model_dbs.version = ?", mf.Version)
}
Expand Down
1 change: 0 additions & 1 deletion utils/manifests/getComponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
k8s "github.com/layer5io/meshkit/utils/kubernetes"
)


func GetFromManifest(ctx context.Context, url string, resource int, cfg Config) (*Component, error) {
manifest, err := utils.ReadFileSource(url)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ func Contains[G []K, K comparable](slice G, ele K) bool {
return false
}


func Cast[K any](val interface{}) (K, error) {
assertedValue, ok := val.(K)
if !ok {
Expand All @@ -256,7 +255,7 @@ func Cast[K any](val interface{}) (K, error) {
return assertedValue, nil
}

func MarshalAndUnmarshal[fromType any, toType any](val fromType) (unmarshalledvalue toType, err error){
func MarshalAndUnmarshal[fromType any, toType any](val fromType) (unmarshalledvalue toType, err error) {
data, err := Marshal(val)
if err != nil {
return
Expand Down

0 comments on commit 803ac87

Please sign in to comment.