Skip to content

Commit

Permalink
Merge pull request #272 from harkiratsm/fil
Browse files Browse the repository at this point in the history
add modelName filter to policy
  • Loading branch information
Revolyssup authored Mar 3, 2023
2 parents be29cff + d42b87a commit 500374c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions models/meshmodel/core/v1alpha1/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}) {
Expand All @@ -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())
Expand Down

0 comments on commit 500374c

Please sign in to comment.