Skip to content

Commit 5fc7b5c

Browse files
committed
lint
Signed-off-by: Pranav Singh <pranavsingh02@hotmail.com>
1 parent 6aa7241 commit 5fc7b5c

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

models/meshmodel/core/types/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const (
66
ComponentDefinition CapabilityType = "component"
77
PolicyDefinition CapabilityType = "policy"
88
RelationshipDefinition CapabilityType = "relationship"
9-
Model CapabilityType = "model"
9+
Model CapabilityType = "model"
1010
)
1111

1212
// Each entity will have it's own Filter implementation via which it exposes the nobs and dials to fetch entities

models/meshmodel/core/v1alpha1/models.go

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func (m Model) GetID() uuid.UUID {
6161
return m.ID
6262
}
6363

64-
6564
func CreateModel(db *database.Handler, cmodel Model) (uuid.UUID, error) {
6665
byt, err := json.Marshal(cmodel)
6766
if err != nil {

models/meshmodel/registry/host.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package registry
22

33
import (
4-
"fmt"
5-
"time"
64
"encoding/json"
5+
"fmt"
76
"sync"
7+
"time"
88

99
"github.com/google/uuid"
1010
"github.com/layer5io/meshkit/database"
@@ -28,7 +28,7 @@ type Host struct {
2828
func createHost(db *database.Handler, h Host) (uuid.UUID, error) {
2929
byt, err := json.Marshal(h)
3030
if err != nil {
31-
return uuid.UUID{}, err
31+
return uuid.UUID{}, err
3232
}
3333
hID := uuid.NewSHA1(uuid.UUID{}, byt)
3434
var host Host
@@ -38,15 +38,15 @@ func createHost(db *database.Handler, h Host) (uuid.UUID, error) {
3838
if err != nil && err != gorm.ErrRecordNotFound {
3939
return uuid.UUID{}, err
4040
}
41-
41+
4242
// if not exists then create a new host and return the id
43-
if err == gorm.ErrRecordNotFound {
44-
h.ID = hID
45-
err = db.Create(&h).Error
46-
if err != nil {
47-
return uuid.UUID{}, err
48-
}
49-
return h.ID, nil
43+
if err == gorm.ErrRecordNotFound {
44+
h.ID = hID
45+
err = db.Create(&h).Error
46+
if err != nil {
47+
return uuid.UUID{}, err
48+
}
49+
return h.ID, nil
5050
}
5151

5252
// else return the id of the existing host

models/meshmodel/registry/registry.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package registry
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"strings"
67
"time"
7-
"encoding/json"
88

99
"github.com/google/uuid"
1010
"github.com/layer5io/meshkit/database"
1111
"github.com/layer5io/meshkit/models/meshmodel/core/types"
1212
"github.com/layer5io/meshkit/models/meshmodel/core/v1alpha1"
1313
"golang.org/x/text/cases"
1414
"golang.org/x/text/language"
15-
"gorm.io/gorm/clause"
1615
"gorm.io/gorm"
16+
"gorm.io/gorm/clause"
1717
)
1818

1919
// MeshModelRegistrantData struct defines the body of the POST request that is sent to the capability
@@ -49,7 +49,7 @@ type RegistryManager struct {
4949
db *database.Handler //This database handler will be used to perform queries inside the database
5050
}
5151

52-
func registerModel(db *database.Handler, regID, modelID uuid.UUID) error {
52+
func registerModel(db *database.Handler, regID, modelID uuid.UUID) error {
5353
entity := Registry{
5454
RegistrantID: regID,
5555
Entity: modelID,
@@ -145,11 +145,10 @@ func (rm *RegistryManager) RegisterEntity(h Host, en Entity) error {
145145
return rm.db.Create(&entry).Error
146146
case v1alpha1.RelationshipDefinition:
147147

148-
registrantID, err := createHost(rm.db, h)
149-
if err != nil {
150-
return err
151-
}
152-
148+
registrantID, err := createHost(rm.db, h)
149+
if err != nil {
150+
return err
151+
}
153152

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

0 commit comments

Comments
 (0)