Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Singh <[email protected]>
  • Loading branch information
theBeginner86 committed Sep 28, 2023
1 parent 6aa7241 commit 5fc7b5c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion models/meshmodel/core/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const (
ComponentDefinition CapabilityType = "component"
PolicyDefinition CapabilityType = "policy"
RelationshipDefinition CapabilityType = "relationship"
Model CapabilityType = "model"
Model CapabilityType = "model"
)

// Each entity will have it's own Filter implementation via which it exposes the nobs and dials to fetch entities
Expand Down
1 change: 0 additions & 1 deletion models/meshmodel/core/v1alpha1/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func (m Model) GetID() uuid.UUID {
return m.ID
}


func CreateModel(db *database.Handler, cmodel Model) (uuid.UUID, error) {
byt, err := json.Marshal(cmodel)
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions models/meshmodel/registry/host.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package registry

import (
"fmt"
"time"
"encoding/json"
"fmt"
"sync"
"time"

"github.com/google/uuid"
"github.com/layer5io/meshkit/database"
Expand All @@ -28,7 +28,7 @@ type Host struct {
func createHost(db *database.Handler, h Host) (uuid.UUID, error) {
byt, err := json.Marshal(h)
if err != nil {
return uuid.UUID{}, err
return uuid.UUID{}, err
}
hID := uuid.NewSHA1(uuid.UUID{}, byt)
var host Host
Expand All @@ -38,15 +38,15 @@ func createHost(db *database.Handler, h Host) (uuid.UUID, error) {
if err != nil && err != gorm.ErrRecordNotFound {
return uuid.UUID{}, err
}

// if not exists then create a new host and return the id
if err == gorm.ErrRecordNotFound {
h.ID = hID
err = db.Create(&h).Error
if err != nil {
return uuid.UUID{}, err
}
return h.ID, nil
if err == gorm.ErrRecordNotFound {
h.ID = hID
err = db.Create(&h).Error
if err != nil {
return uuid.UUID{}, err
}
return h.ID, nil
}

// else return the id of the existing host
Expand Down
15 changes: 7 additions & 8 deletions models/meshmodel/registry/registry.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package registry

import (
"encoding/json"
"fmt"
"strings"
"time"
"encoding/json"

"github.com/google/uuid"
"github.com/layer5io/meshkit/database"
"github.com/layer5io/meshkit/models/meshmodel/core/types"
"github.com/layer5io/meshkit/models/meshmodel/core/v1alpha1"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"gorm.io/gorm/clause"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)

// MeshModelRegistrantData struct defines the body of the POST request that is sent to the capability
Expand Down 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 @@ -145,11 +145,10 @@ func (rm *RegistryManager) RegisterEntity(h Host, en Entity) error {
return rm.db.Create(&entry).Error
case v1alpha1.RelationshipDefinition:

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

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

relationshipID, modelID, err := v1alpha1.CreateRelationship(rm.db, entity)
if err != nil {
Expand Down

0 comments on commit 5fc7b5c

Please sign in to comment.