Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Meshery Cloud, adapters, operators, CLIs) depends on it, so changes fan out down

- [architecture](docs/agent-instructions/architecture.md) - orientation: package map, the two core pipelines, cross-cutting packages.
- [errors](docs/agent-instructions/errors.md) - read before adding or changing any error: conventions, errorutil workflow, code allocation.
- [registration](docs/agent-instructions/registration.md) - read before touching `models/registration/` or `models/meshmodel/registry/`.
- [registration](docs/agent-instructions/registration.md) - read before touching `models/registration/` or `models/registry/manager/`.
- [testing](docs/agent-instructions/testing.md) - make targets, flags, single-test forms, lint and tidy discipline.
- [naming-conventions](docs/agent-instructions/naming-conventions.md) - full identifier-naming contract and authority links.
- [event-streaming](docs/event-streaming.md) - read when working on events, broadcasters, or the `Event`/`EventBuilder` types shared with Meshery Server.
Expand Down
4 changes: 2 additions & 2 deletions docs/agent-instructions/registration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MeshModel Registration Pipeline

Read this before touching `models/registration/` or `models/meshmodel/registry/`.
Read this before touching `models/registration/` or `models/registry/manager/`.

## Shape of the pipeline

Expand All @@ -11,7 +11,7 @@ Read this before touching `models/registration/` or `models/meshmodel/registry/`
and a `RegistrationErrorStore`) drives `Register(entity)` for each
`RegisterableEntity` - currently directory (`dir.go`), tar (`tar.go`), and OCI
(`oci.go`) sources.
- `models/meshmodel/registry/` persists registrants, models, components, and
- `models/registry/manager/` persists registrants, models, components, and
relationships through GORM-backed helpers (`RegistryManager`), with versioned entity
handling under `registry/v1alpha3` and `registry/v1beta1`.

Expand Down
14 changes: 5 additions & 9 deletions models/meshmodel/entity/error.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package entity

import (
"fmt"
import registryentity "github.com/meshery/meshkit/models/registry/entity"

"github.com/meshery/meshkit/errors"
)

const (
ErrUpdateEntityStatusCode = "meshkit-11243"
)
const ErrUpdateEntityStatusCode = registryentity.ErrUpdateEntityStatusCode

// ErrUpdateEntityStatus is a deprecated wrapper for registryentity.ErrUpdateEntityStatus.
// Deprecated: use registryentity.ErrUpdateEntityStatus instead.
func ErrUpdateEntityStatus(err error, entity string, status EntityStatus) error {
return errors.New(ErrUpdateEntityStatusCode, errors.Alert, []string{fmt.Sprintf("unable to update %s to %s", entity, status)}, []string{err.Error()}, []string{}, []string{})
return registryentity.ErrUpdateEntityStatus(err, entity, status)
}
18 changes: 10 additions & 8 deletions models/meshmodel/entity/status.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package entity

import "github.com/meshery/meshkit/database"
import registryentity "github.com/meshery/meshkit/models/registry/entity"

type EntityStatus string
// EntityStatus is a deprecated alias for registryentity.EntityStatus.
// Deprecated: use registryentity.EntityStatus instead.
type EntityStatus = registryentity.EntityStatus

const (
Ignored EntityStatus = "ignored"
Enabled EntityStatus = "enabled"
Duplicate EntityStatus = "duplicate"
Ignored = registryentity.Ignored
Enabled = registryentity.Enabled
Duplicate = registryentity.Duplicate
)

type Status interface {
UpdateStatus(db *database.Handler, status EntityStatus) error
}
// Status is a deprecated alias for registryentity.Status.
// Deprecated: use registryentity.Status instead.
type Status = registryentity.Status
57 changes: 29 additions & 28 deletions models/meshmodel/entity/types.go
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
// Package entity is a deprecated compatibility shim for the registry entity
// package.
//
// It exists solely because github.com/meshery/schemas@v1.3.26 (our currently
// pinned dependency) has helper files that import this path directly by
// convention. All types here are pure aliases (type X = Y) of their
// counterparts in github.com/meshery/meshkit/models/registry/entity, so
// nothing drifts between the two paths.
//
// Deprecated: import github.com/meshery/meshkit/models/registry/entity
Comment thread
Ayush-kr-giga marked this conversation as resolved.
// directly. This shim should be deleted once meshkit's go.mod pin on
// github.com/meshery/schemas is bumped past v1.3.26 to a version that no
// longer references the old meshmodel path.
package entity

import (
"github.com/meshery/meshkit/database"
core "github.com/meshery/schemas/models/core"
registryentity "github.com/meshery/meshkit/models/registry/entity"
)

type EntityType string
// EntityType is a deprecated alias for registryentity.EntityType.
// Deprecated: use registryentity.EntityType instead.
type EntityType = registryentity.EntityType

const (
ComponentDefinition EntityType = "component"
PolicyDefinition EntityType = "policy"
RelationshipDefinition EntityType = "relationship"
Model EntityType = "model"
Category EntityType = "category"
// ConnectionDefinition is the registry entity type for connection
// definitions: uninitialized, per-model connection templates registered
// alongside components and relationships. The schemas connection helper
// (github.com/meshery/schemas/models/v1beta3/connection) reports this type.
ConnectionDefinition EntityType = "connection"
ComponentDefinition = registryentity.ComponentDefinition
PolicyDefinition = registryentity.PolicyDefinition
RelationshipDefinition = registryentity.RelationshipDefinition
Model = registryentity.Model
Category = registryentity.Category
ConnectionDefinition = registryentity.ConnectionDefinition
)

// Each entity will have it's own Filter implementation via which it exposes the nobs and dials to fetch entities
type Filter interface {
Create(map[string]interface{})
Get(db *database.Handler) (entities []Entity, count int64, unique int, err error)
GetById(db *database.Handler) (entity Entity, err error)
}
// Filter is a deprecated alias for registryentity.Filter.
// Deprecated: use registryentity.Filter instead.
type Filter = registryentity.Filter

type Entity interface {
// Entity is referred as any type of schema managed by the registry
// ComponentDefinitions and PolicyDefinitions are examples of entities
Type() EntityType
GetEntityDetail() string
GenerateID() (core.Uuid, error)
GetID() core.Uuid
Create(db *database.Handler, hostID core.Uuid) (entityID core.Uuid, err error)
}
// Entity is a deprecated alias for registryentity.Entity.
// Deprecated: use registryentity.Entity instead.
type Entity = registryentity.Entity
4 changes: 2 additions & 2 deletions models/patterns/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/Masterminds/semver/v3"

"github.com/meshery/meshkit/encoding"
"github.com/meshery/meshkit/models/meshmodel/registry"
regv1beta1 "github.com/meshery/meshkit/models/meshmodel/registry/v1beta1"
"github.com/meshery/meshkit/models/registry/manager"
regv1beta1 "github.com/meshery/meshkit/models/registry/manager/v1beta1"
"github.com/meshery/meshkit/utils"
component "github.com/meshery/schemas/models/v1beta2/component"
registrycomponent "github.com/meshery/schemas/models/v1beta3/component"
Expand Down
2 changes: 1 addition & 1 deletion models/registration/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"path/filepath"
"reflect"

"github.com/meshery/meshkit/models/meshmodel/entity"
"github.com/meshery/meshkit/models/oci"
"github.com/meshery/meshkit/models/registry/entity"

meshkitFileUtils "github.com/meshery/meshkit/files"
"github.com/meshery/meshkit/utils"
Expand Down
2 changes: 1 addition & 1 deletion models/registration/interface.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package registration

import (
"github.com/meshery/meshkit/models/meshmodel/entity"
"github.com/meshery/meshkit/models/registry/entity"
)

/*
Expand Down
6 changes: 3 additions & 3 deletions models/registration/register.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package registration

import (
"github.com/meshery/meshkit/models/meshmodel/core/v1beta1"
"github.com/meshery/meshkit/models/meshmodel/entity"
meshmodel "github.com/meshery/meshkit/models/meshmodel/registry"
"github.com/meshery/meshkit/models/registry/core/v1beta1"
"github.com/meshery/meshkit/models/registry/entity"
meshmodel "github.com/meshery/meshkit/models/registry/manager"
"github.com/meshery/schemas/models/v1alpha3/relationship"
"github.com/meshery/schemas/models/v1beta1/connection"
"github.com/meshery/schemas/models/v1beta1/model"
Expand Down
2 changes: 1 addition & 1 deletion models/registration/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/meshery/meshkit/encoding"
"github.com/meshery/meshkit/models/meshmodel/entity"
"github.com/meshery/meshkit/models/registry/entity"
"github.com/meshery/meshkit/schema"
"github.com/meshery/schemas/models/v1alpha3"
"github.com/meshery/schemas/models/v1alpha3/relationship"
Expand Down
2 changes: 1 addition & 1 deletion models/registration/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package registration
import (
"testing"

"github.com/meshery/meshkit/models/meshmodel/entity"
"github.com/meshery/meshkit/models/registry/entity"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"sync"

"github.com/meshery/meshkit/models/meshmodel/registry"
"github.com/meshery/meshkit/models/meshmodel/registry/v1alpha3"
"github.com/meshery/meshkit/models/registry/manager"
"github.com/meshery/meshkit/models/registry/manager/v1alpha3"
"github.com/meshery/meshkit/utils"
patching "github.com/meshery/meshkit/utils/patching"
// NOTE: This file continues to reference v1beta1/pattern for `PatternFile`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ import (
"github.com/meshery/schemas/models/v1beta3/component"
)

type MeshModelHostsWithEntitySummary struct {
// RegistryHostsWithEntitySummary represents a registry host along with a summary of its entities.
type RegistryHostsWithEntitySummary struct {
connection.Connection
Summary EntitySummary `json:"summary"`
}

// MeshModelHostsWithEntitySummary is a deprecated alias for RegistryHostsWithEntitySummary.
// Deprecated: use RegistryHostsWithEntitySummary instead.
type MeshModelHostsWithEntitySummary = RegistryHostsWithEntitySummary

type EntitySummary struct {
Models int64 `json:"models"`
Components int64 `json:"components"`
Expand Down Expand Up @@ -126,10 +132,10 @@ func (k Kubernetes) String() string {

type GitHub struct{}

func(gh GitHub) HandleDependents(_ component.ComponentDefinition, _ *kubernetes.Client, _, _ bool) (summary string, err error) {
func (gh GitHub) HandleDependents(_ component.ComponentDefinition, _ *kubernetes.Client, _, _ bool) (summary string, err error) {
return summary, err
}

func(gh GitHub) String() string {
func (gh GitHub) String() string {
return "github"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import (
modelv1beta2 "github.com/meshery/schemas/models/v1beta2/model"
"gorm.io/gorm/clause"

"github.com/meshery/meshkit/models/meshmodel/entity"
"github.com/meshery/meshkit/models/registry/entity"
)

// swagger:response PolicyDefinition
type PolicyDefinition struct {
ID core.Uuid `json:"-"`
Kind string `json:"kind,omitempty" yaml:"kind"`
Version string `json:"version,omitempty" yaml:"version"`
ModelID core.Uuid `json:"-" gorm:"column:modelID"`
ID core.Uuid `json:"-"`
Kind string `json:"kind,omitempty" yaml:"kind"`
Version string `json:"version,omitempty" yaml:"version"`
ModelID core.Uuid `json:"-" gorm:"column:modelID"`
Model modelv1beta2.ModelDefinition `json:"model"`
SubType string `json:"subType" yaml:"subType"`
Expression map[string]interface{} `json:"expression" yaml:"expression" gorm:"type:bytes;serializer:json"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
SubType string `json:"subType" yaml:"subType"`
Expression map[string]interface{} `json:"expression" yaml:"expression" gorm:"type:bytes;serializer:json"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}

func (p PolicyDefinition) GetID() core.Uuid {
Expand Down
15 changes: 15 additions & 0 deletions models/registry/entity/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package entity

import (
"fmt"

"github.com/meshery/meshkit/errors"
)

const (
ErrUpdateEntityStatusCode = "meshkit-11243"
)

func ErrUpdateEntityStatus(err error, entity string, status EntityStatus) error {
return errors.New(ErrUpdateEntityStatusCode, errors.Alert, []string{fmt.Sprintf("unable to update %s to %s", entity, status)}, []string{err.Error()}, []string{}, []string{})
}
15 changes: 15 additions & 0 deletions models/registry/entity/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package entity

import "github.com/meshery/meshkit/database"

type EntityStatus string

const (
Ignored EntityStatus = "ignored"
Enabled EntityStatus = "enabled"
Duplicate EntityStatus = "duplicate"
)

type Status interface {
UpdateStatus(db *database.Handler, status EntityStatus) error
}
38 changes: 38 additions & 0 deletions models/registry/entity/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package entity

import (
"github.com/meshery/meshkit/database"
core "github.com/meshery/schemas/models/core"
)

type EntityType string

const (
ComponentDefinition EntityType = "component"
PolicyDefinition EntityType = "policy"
RelationshipDefinition EntityType = "relationship"
Model EntityType = "model"
Category EntityType = "category"
// ConnectionDefinition is the registry entity type for connection
// definitions: uninitialized, per-model connection templates registered
// alongside components and relationships. The schemas connection helper
// (github.com/meshery/schemas/models/v1beta3/connection) reports this type.
ConnectionDefinition EntityType = "connection"
)

// Each entity will have it's own Filter implementation via which it exposes the nobs and dials to fetch entities
type Filter interface {
Create(map[string]interface{})
Get(db *database.Handler) (entities []Entity, count int64, unique int, err error)
GetById(db *database.Handler) (entity Entity, err error)
}

type Entity interface {
// Entity is referred as any type of schema managed by the registry
// ComponentDefinitions and PolicyDefinitions are examples of entities
Type() EntityType
GetEntityDetail() string
GenerateID() (core.Uuid, error)
GetID() core.Uuid
Create(db *database.Handler, hostID core.Uuid) (entityID core.Uuid, err error)
}
File renamed without changes.
Loading
Loading