diff --git a/models/meshmodel/core/v1alpha1/policy.go b/models/meshmodel/core/v1alpha1/policy.go index 3e9bb5b1..ecc9efbb 100644 --- a/models/meshmodel/core/v1alpha1/policy.go +++ b/models/meshmodel/core/v1alpha1/policy.go @@ -32,8 +32,9 @@ type PolicyDefinitionDB struct { } type PolicyFilter struct { - Kind string - SubType string + Kind string + SubType string + ModelName string } func (pf *PolicyFilter) Create(m map[string]interface{}) { @@ -60,11 +61,14 @@ func GetMeshModelPolicy(db *database.Handler, f PolicyFilter) (pl []PolicyDefini Select("policy_definition_dbs.*, models.*"). Joins("JOIN models ON models.id = policy_definition_dbs.model_id") if f.Kind != "" { - finder = finder.Where("policy_definition_dbs.type = ?", f.Kind) + finder = finder.Where("policy_definition_dbs.kind = ?", f.Kind) } if f.SubType != "" { finder = finder.Where("policy_definition_dbs.sub_type = ?", f.SubType) } + if f.ModelName != "" { + finder = finder.Where("models.name = ?", f.ModelName) + } err := finder.Scan(&componentDefinitionsWithModel).Error if err != nil { fmt.Println(err.Error())