Skip to content

Commit

Permalink
register model into registry for relationship/policy registeration pr…
Browse files Browse the repository at this point in the history
…ocess

Signed-off-by: Pranav Singh <[email protected]>
  • Loading branch information
theBeginner86 committed Sep 28, 2023
1 parent a51b1bf commit ff63b38
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions models/meshmodel/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type RegistryManager struct {
db *database.Handler //This database handler will be used to perform queries inside the database
}

func RegisterModel(db *database.Handler, regID, modelID uuid.UUID) error {
func registerModel(db *database.Handler, regID, modelID uuid.UUID) error {
entity := Registry{
RegistrantID: regID,
Entity: modelID,
Expand Down Expand Up @@ -129,12 +129,11 @@ func (rm *RegistryManager) RegisterEntity(h Host, en Entity) error {
return err
}

err = RegisterModel(rm.db, registrantID, modelID)
err = registerModel(rm.db, registrantID, modelID)
if err != nil {
return err
}


entry := Registry{
ID: uuid.New(),
RegistrantID: registrantID,
Expand All @@ -145,14 +144,23 @@ func (rm *RegistryManager) RegisterEntity(h Host, en Entity) error {
}
return rm.db.Create(&entry).Error
case v1alpha1.RelationshipDefinition:
relationshipID, err := v1alpha1.CreateRelationship(rm.db, entity)

registrantID, err := createHost(rm.db, h)
if err != nil {
return err
}


relationshipID, modelID, err := v1alpha1.CreateRelationship(rm.db, entity)
if err != nil {
return err
}
registrantID, err := createHost(rm.db, h)

err = registerModel(rm.db, registrantID, modelID)
if err != nil {
return err
}

entry := Registry{
ID: uuid.New(),
RegistrantID: registrantID,
Expand All @@ -164,14 +172,22 @@ func (rm *RegistryManager) RegisterEntity(h Host, en Entity) error {
return rm.db.Create(&entry).Error
//Add logic for Policies and other entities below
case v1alpha1.PolicyDefinition:
policyID, err := v1alpha1.CreatePolicy(rm.db, entity)
registrantID, err := createHost(rm.db, h)
if err != nil {
return err
}
registrantID, err := createHost(rm.db, h)

policyID, modelID, err := v1alpha1.CreatePolicy(rm.db, entity)
if err != nil {
return err
}

err = registerModel(rm.db, registrantID, modelID)
if err != nil {
return err
}


entry := Registry{
ID: uuid.New(),
RegistrantID: registrantID,
Expand Down

0 comments on commit ff63b38

Please sign in to comment.