@@ -9,26 +9,24 @@ import (
99 "github.com/meshery/meshkit/database"
1010 "github.com/meshery/meshkit/models/meshmodel/entity"
1111 "github.com/meshery/meshkit/utils"
12+ schemav1beta1 "github.com/meshery/schemas/models/v1beta1"
1213 "github.com/meshery/schemas/models/v1beta1/connection"
1314 v1beta1 "github.com/meshery/schemas/models/v1beta1/model"
1415 "gorm.io/gorm/clause"
1516)
1617
17- // ConnectionSchemaVersion is the schema version for connection definitions
18- // This should match the schema version defined in the JSON schema
19- const ConnectionSchemaVersion = "connections.meshery.io/v1beta1"
18+ // ConnectionSchemaVersion is imported from the schemas repo
19+ // This ensures consistency with the schema definition
20+ const ConnectionSchemaVersion = schemav1beta1 . ConnectionSchemaVersion
2021
21- // swagger:response ConnectionDefinition
22+ // ConnectionDefinition wraps the Connection from schemas to implement the Entity interface
23+ // This allows us to use Connection entities directly in PackagingUnit as requested by maintainer
2224type ConnectionDefinition struct {
23- ID uuid.UUID `json:"-" gorm:"primaryKey"`
24- Kind string `json:"kind,omitempty" yaml:"kind"`
25- Version string `json:"version,omitempty" yaml:"version"`
26- ModelID uuid.UUID `json:"-" gorm:"column:modelID"`
27- Model v1beta1.ModelDefinition `json:"model"`
28- SubType string `json:"subType" yaml:"subType"`
29- Connection connection.Connection `json:"connection" yaml:"connection"`
30- CreatedAt time.Time `json:"-"`
31- UpdatedAt time.Time `json:"-"`
25+ connection.Connection
26+ ModelID uuid.UUID `json:"-" gorm:"column:modelID"`
27+ Model v1beta1.ModelDefinition `json:"model"`
28+ CreatedAt time.Time `json:"-"`
29+ UpdatedAt time.Time `json:"-"`
3230}
3331
3432func (c ConnectionDefinition ) GetID () uuid.UUID {
@@ -43,12 +41,12 @@ func (c *ConnectionDefinition) GenerateID() (uuid.UUID, error) {
4341 return id , nil
4442}
4543
46- func (c ConnectionDefinition ) Type () entity.EntityType {
44+ func (c ConnectionDefinition ) EntityType () entity.EntityType {
4745 return entity .ConnectionDefinition
4846}
4947
5048func (c * ConnectionDefinition ) GetEntityDetail () string {
51- return fmt .Sprintf ("type: %s, definition version : %s, name : %s, model: %s, version: %s" , c .Type (), c .Version , c .Kind , c .Model .Name , c .Model .Version )
49+ return fmt .Sprintf ("type: %s, name : %s, kind : %s, model: %s, version: %s" , c .EntityType (), c .Name , c .Kind , c .Model .Name , c .Model .Version )
5250}
5351
5452func (c * ConnectionDefinition ) Create (db * database.Handler , hostID uuid.UUID ) (uuid.UUID , error ) {
0 commit comments