From f279d814f648292b9191f723208813f81ab09529 Mon Sep 17 00:00:00 2001 From: MUzairS15 Date: Tue, 16 Jan 2024 19:43:47 +0530 Subject: [PATCH] feat: add support for selector sets in relationships Signed-off-by: MUzairS15 --- .../meshmodel/core/v1alpha1/relationship.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/models/meshmodel/core/v1alpha1/relationship.go b/models/meshmodel/core/v1alpha1/relationship.go index eb4ad569..4fa3d2ec 100644 --- a/models/meshmodel/core/v1alpha1/relationship.go +++ b/models/meshmodel/core/v1alpha1/relationship.go @@ -18,16 +18,16 @@ import ( type RelationshipDefinition struct { ID uuid.UUID `json:"-"` TypeMeta - Model Model `json:"model"` - HostName string `json:"hostname"` - HostID uuid.UUID `json:"hostID"` - DisplayHostName string `json:"displayhostname"` - Metadata map[string]interface{} `json:"metadata" yaml:"metadata"` - SubType string `json:"subType" yaml:"subType" gorm:"subType"` - EvaluationQuery string `json:"evaluationQuery" yaml:"evaluationQuery" gorm:"evaluationQuery"` - Selectors map[string]interface{} `json:"selectors" yaml:"selectors"` - CreatedAt time.Time `json:"-"` - UpdatedAt time.Time `json:"-"` + Model Model `json:"model"` + HostName string `json:"hostname"` + HostID uuid.UUID `json:"hostID"` + DisplayHostName string `json:"displayhostname"` + Metadata map[string]interface{} `json:"metadata" yaml:"metadata"` + SubType string `json:"subType" yaml:"subType" gorm:"subType"` + EvaluationQuery string `json:"evaluationQuery" yaml:"evaluationQuery" gorm:"evaluationQuery"` + Selectors []map[string]interface{} `json:"selectors" yaml:"selectors"` + CreatedAt time.Time `json:"-"` + UpdatedAt time.Time `json:"-"` } type RelationshipDefinitionDB struct { @@ -123,7 +123,7 @@ func (rdb *RelationshipDefinitionDB) GetRelationshipDefinition(m Model) (r Relat } _ = json.Unmarshal(rdb.Metadata, &r.Metadata) if r.Selectors == nil { - r.Selectors = make(map[string]interface{}) + r.Selectors = []map[string]interface{}{} } _ = json.Unmarshal(rdb.Selectors, &r.Selectors) r.SubType = rdb.SubType