Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move MeshModel to Model. #468

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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 generators/artifacthub/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/layer5io/meshkit/models/meshmodel/core/v1alpha1"
"github.com/layer5io/meshkit/models/model/core/v1alpha1"
"github.com/layer5io/meshkit/utils"
"github.com/layer5io/meshkit/utils/component"
"github.com/layer5io/meshkit/utils/manifests"
Expand Down
2 changes: 1 addition & 1 deletion generators/github/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"os"

"github.com/layer5io/meshkit/models/meshmodel/core/v1alpha1"
"github.com/layer5io/meshkit/models/model/core/v1alpha1"
"github.com/layer5io/meshkit/utils"
"github.com/layer5io/meshkit/utils/component"
"github.com/layer5io/meshkit/utils/manifests"
Expand Down
4 changes: 2 additions & 2 deletions models/controllers/meshery_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func (mb *mesheryBroker) GetStatus() MesheryControllerStatus {
// TODO: Confirm if the presence of operator is needed to use the operator client sdk
_, err = operatorClient.CoreV1Alpha1().Brokers("meshery").Get(context.TODO(), "meshery-broker", metav1.GetOptions{})
if err == nil {
monitoringEndpoint, err := mb.GetEndpointForPort(brokerMonitoringPortName)
if err == nil {
monitoringEndpoint, endpointErr := mb.GetEndpointForPort(brokerMonitoringPortName)
if endpointErr == nil {
if ConnectivityTest(MesheryServer, monitoringEndpoint) {
mb.status = Connected
return mb.status
Expand Down
4 changes: 2 additions & 2 deletions models/controllers/meshsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (ms *meshsync) GetStatus() MesheryControllerStatus {
case v1.PodRunning:
ms.status = Running
broker := NewMesheryBrokerHandler(ms.kclient)
brokerEndpoint, err := broker.GetEndpointForPort(brokerMonitoringPortName)
if err != nil {
brokerEndpoint, endpointErr := broker.GetEndpointForPort(brokerMonitoringPortName)
if endpointErr != nil {
return ms.status
}
isConnected := ConnectivityTest(MeshSync, brokerEndpoint)
Expand Down
2 changes: 1 addition & 1 deletion models/interfaces.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models

import "github.com/layer5io/meshkit/models/meshmodel/core/v1alpha1"
import "github.com/layer5io/meshkit/models/model/core/v1alpha1"

// anything that can be validated is a Validator
type Validator interface {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/google/uuid"
"github.com/layer5io/meshkit/database"
"github.com/layer5io/meshkit/models/meshmodel/core/types"
"github.com/layer5io/meshkit/models/model/core/types"
"github.com/layer5io/meshkit/utils"
"gorm.io/gorm/clause"
)
Expand Down Expand Up @@ -86,7 +86,7 @@ func CreateComponent(db *database.Handler, c ComponentDefinition) (uuid.UUID, uu
err = db.Create(&cdb).Error
return c.ID, mid, err
}
func GetMeshModelComponents(db *database.Handler, f ComponentFilter) (c []ComponentDefinition, count int64, unique int) {
func GetModelComponents(db *database.Handler, f ComponentFilter) (c []ComponentDefinition, count int64, unique int) {
type componentDefinitionWithModel struct {
ComponentDefinitionDB
ModelDB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package v1alpha1

import "github.com/google/uuid"

type MeshModelHostsWithEntitySummary struct {
type ModelHostsWithEntitySummary struct {
ID uuid.UUID `json:"id"`
Hostname string `json:"hostname"`
Port int `json:"port"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/google/uuid"
"github.com/layer5io/meshkit/database"
"github.com/layer5io/meshkit/models/meshmodel/core/types"
"github.com/layer5io/meshkit/models/model/core/types"
"github.com/layer5io/meshkit/utils"
"gorm.io/gorm"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/google/uuid"
"github.com/layer5io/meshkit/database"
"github.com/layer5io/meshkit/models/meshmodel/core/types"
"github.com/layer5io/meshkit/models/model/core/types"
)

type PolicyDefinition struct {
Expand Down Expand Up @@ -55,7 +55,7 @@ func (p PolicyDefinition) Type() types.CapabilityType {
return types.PolicyDefinition
}

func GetMeshModelPolicy(db *database.Handler, f PolicyFilter) (pl []PolicyDefinition) {
func GetModelPolicy(db *database.Handler, f PolicyFilter) (pl []PolicyDefinition) {
type componentDefinitionWithModel struct {
PolicyDefinitionDB
Model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/google/uuid"
"github.com/layer5io/meshkit/database"
"github.com/layer5io/meshkit/models/meshmodel/core/types"
"github.com/layer5io/meshkit/models/model/core/types"
"gorm.io/gorm/clause"
)

Expand Down Expand Up @@ -63,7 +63,7 @@ func (rf *RelationshipFilter) Create(m map[string]interface{}) {
return
}
}
func GetMeshModelRelationship(db *database.Handler, f RelationshipFilter) (r []RelationshipDefinition, count int64) {
func GetModelRelationship(db *database.Handler, f RelationshipFilter) (r []RelationshipDefinition, count int64) {
type componentDefinitionWithModel struct {
RelationshipDefinitionDB
ModelDB
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (h *Host) AfterFind(tx *gorm.DB) error {
return nil
}

// Each host from where meshmodels can be generated needs to implement this interface
// Each host from where models can be generated needs to implement this interface
// HandleDependents, contains host specific logic for provisioning required CRDs/operators for corresponding components.
type IHost interface {
HandleDependents(comp v1alpha1.Component, kc *kubernetes.Client, isDeploy bool) (string, error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ import (

"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"
"github.com/layer5io/meshkit/models/model/core/types"
"github.com/layer5io/meshkit/models/model/core/v1alpha1"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)

// MeshModelRegistrantData struct defines the body of the POST request that is sent to the capability
// ModelRegistrantData struct defines the body of the POST request that is sent to the capability
// registry (Meshery)
//
// The body contains the
// 1. Host information
// 2. Entity type
// 3. Entity
type MeshModelRegistrantData struct {
type ModelRegistrantData struct {
Host Host `json:"host"`
EntityType types.CapabilityType `json:"entityType"`
Entity []byte `json:"entity"` //This will be type converted to appropriate entity on server based on passed entity type
Expand Down Expand Up @@ -223,7 +223,7 @@ func (rm *RegistryManager) UpdateEntityStatus(ID string, status string, entity s
}
}

func (rm *RegistryManager) GetRegistrants(f *v1alpha1.HostFilter) ([]v1alpha1.MeshModelHostsWithEntitySummary, int64, error) {
func (rm *RegistryManager) GetRegistrants(f *v1alpha1.HostFilter) ([]v1alpha1.ModelHostsWithEntitySummary, int64, error) {
var result []v1alpha1.MesheryHostSummaryDB
var totalcount int64
db := rm.db
Expand Down Expand Up @@ -263,10 +263,10 @@ func (rm *RegistryManager) GetRegistrants(f *v1alpha1.HostFilter) ([]v1alpha1.Me
return nil, 0, err
}

var response []v1alpha1.MeshModelHostsWithEntitySummary
var response []v1alpha1.ModelHostsWithEntitySummary

for _, r := range result {
res := v1alpha1.MeshModelHostsWithEntitySummary{
res := v1alpha1.ModelHostsWithEntitySummary{
ID: r.HostID,
Hostname: HostnameToPascalCase(r.Hostname),
Port: r.Port,
Expand All @@ -285,21 +285,21 @@ func (rm *RegistryManager) GetEntities(f types.Filter) ([]Entity, *int64, *int)
switch filter := f.(type) {
case *v1alpha1.ComponentFilter:
en := make([]Entity, 0)
comps, count, unique := v1alpha1.GetMeshModelComponents(rm.db, *filter)
comps, count, unique := v1alpha1.GetModelComponents(rm.db, *filter)
for _, comp := range comps {
en = append(en, comp)
}
return en, &count, &unique
case *v1alpha1.RelationshipFilter:
en := make([]Entity, 0)
relationships, count := v1alpha1.GetMeshModelRelationship(rm.db, *filter)
relationships, count := v1alpha1.GetModelRelationship(rm.db, *filter)
for _, rel := range relationships {
en = append(en, rel)
}
return en, &count, nil
case *v1alpha1.PolicyFilter:
en := make([]Entity, 0)
policies := v1alpha1.GetMeshModelPolicy(rm.db, *filter)
policies := v1alpha1.GetModelPolicy(rm.db, *filter)
for _, pol := range policies {
en = append(en, pol)
}
Expand Down
4 changes: 2 additions & 2 deletions models/oam/core/v1alpha1/application_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/layer5io/meshkit/models/meshmodel/core/v1alpha1"
"github.com/layer5io/meshkit/models/model/core/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -35,7 +35,7 @@ type ComponentParameter struct {
Description *string `json:"description,omitempty"`
}

const MesheryAnnotationPrefix = "design.meshmodel.io"
const MesheryAnnotationPrefix = "design.model.io"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MUzairS15 this is to be design.meshery.io, right?


func GetAPIVersionFromComponent(comp Component) string {
return comp.Annotations[MesheryAnnotationPrefix+".k8s.APIVersion"]
Expand Down
2 changes: 1 addition & 1 deletion utils/component/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

"cuelang.org/go/cue"
"github.com/layer5io/meshkit/models/meshmodel/core/v1alpha1"
"github.com/layer5io/meshkit/models/model/core/v1alpha1"
"github.com/layer5io/meshkit/utils"
"github.com/layer5io/meshkit/utils/manifests"
)
Expand Down
2 changes: 1 addition & 1 deletion utils/component/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package component
import (
"testing"

"github.com/layer5io/meshkit/models/meshmodel/core/v1alpha1"
"github.com/layer5io/meshkit/models/model/core/v1alpha1"
"github.com/layer5io/meshkit/utils/manifests"
)

Expand Down
Loading