Skip to content

Commit 93ece74

Browse files
authored
Merge pull request #131 from gr455/meshmodel-components
Add meshmodel component support
2 parents 8b3a4c7 + 6506ed6 commit 93ece74

File tree

115 files changed

+13095
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+13095
-15
lines changed

appmesh/oam/register.go

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,59 @@ import (
44
"fmt"
55
"os"
66
"path/filepath"
7+
"strconv"
78
"strings"
9+
"sync"
810

911
"github.com/layer5io/meshery-adapter-library/adapter"
1012
"github.com/layer5io/meshery-app-mesh/internal/config"
13+
"github.com/layer5io/meshkit/models/meshmodel/core/types"
1114
)
1215

1316
var (
14-
basePath, _ = os.Getwd()
15-
// WorkloadPath contains the path to the workload schemas and definitions directory
16-
WorkloadPath = filepath.Join(basePath, "templates", "oam", "workloads")
17+
basePath, _ = os.Getwd()
18+
WorkloadPath = filepath.Join(basePath, "templates", "oam", "workloads")
19+
MeshmodelComponents = filepath.Join(basePath, "templates", "meshmodel", "components")
20+
traitPath = filepath.Join(basePath, "templates", "oam", "traits")
1721
// traitPath = filepath.Join(basePath, "templates", "oam", "traits")
1822
pathSets = []schemaDefinitionPathSet{}
1923
)
2024

2125
// AvailableVersions denote the component versions available statically
2226
var AvailableVersions = map[string]bool{}
27+
var availableVersionGlobalMutex sync.Mutex
2328

2429
type schemaDefinitionPathSet struct {
2530
oamDefinitionPath string
2631
jsonSchemaPath string
2732
name string
2833
}
2934

35+
type meshmodelDefinitionPathSet struct {
36+
meshmodelDefinitionPath string
37+
}
38+
39+
func RegisterMeshModelComponents(uuid, runtime, host, port string) error {
40+
meshmodelRDP := []adapter.MeshModelRegistrantDefinitionPath{}
41+
pathSets, err := loadMeshmodelComponents(MeshmodelComponents)
42+
if err != nil {
43+
return err
44+
}
45+
portint, _ := strconv.Atoi(port)
46+
for _, pathSet := range pathSets {
47+
meshmodelRDP = append(meshmodelRDP, adapter.MeshModelRegistrantDefinitionPath{
48+
EntityDefintionPath: pathSet.meshmodelDefinitionPath,
49+
Host: host,
50+
Port: portint,
51+
Type: types.ComponentDefinition,
52+
})
53+
}
54+
55+
return adapter.
56+
NewMeshModelRegistrant(meshmodelRDP, fmt.Sprintf("%s/api/meshmodel/components/register", runtime)).
57+
Register(uuid)
58+
}
59+
3060
// RegisterWorkloads will register all of the workload definitions
3161
// present in the path oam/workloads
3262
//
@@ -56,6 +86,31 @@ func RegisterWorkloads(runtime, host string) error {
5686
Register()
5787
}
5888

89+
func loadMeshmodelComponents(basepath string) ([]meshmodelDefinitionPathSet, error) {
90+
res := []meshmodelDefinitionPathSet{}
91+
if err := filepath.Walk(basepath, func(path string, info os.FileInfo, err error) error {
92+
if err != nil {
93+
return err
94+
}
95+
96+
if info.IsDir() {
97+
return nil
98+
}
99+
100+
res = append(res, meshmodelDefinitionPathSet{
101+
meshmodelDefinitionPath: path,
102+
})
103+
availableVersionGlobalMutex.Lock()
104+
AvailableVersions[filepath.Base(filepath.Dir(path))] = true // Getting available versions already existing on file system
105+
availableVersionGlobalMutex.Unlock()
106+
return nil
107+
}); err != nil {
108+
return nil, err
109+
}
110+
111+
return res, nil
112+
}
113+
59114
// RegisterTraits will register all of the trait definitions
60115
// present in the path oam/traits
61116
//
@@ -107,7 +162,9 @@ func load(basePath string) ([]schemaDefinitionPathSet, error) {
107162
jsonSchemaPath: fmt.Sprintf("%s.meshery.layer5io.schema.json", nameWithPath),
108163
name: filepath.Base(nameWithPath),
109164
})
165+
availableVersionGlobalMutex.Lock()
110166
AvailableVersions[filepath.Base(filepath.Dir(path))] = true
167+
availableVersionGlobalMutex.Unlock()
111168
}
112169

113170
return nil

build/config.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,26 @@ var DefaultGenerationMethod string
1616
var DefaultGenerationURL string
1717
var LatestVersion string
1818
var WorkloadPath string
19+
var MeshModelPath string
1920
var AllVersions []string
2021

2122
const Component = "APP_MESH"
2223

24+
var meshmodelmetadata = map[string]interface{}{
25+
"Primary Color": "#F49322",
26+
"Secondary Color": "#F4BC79",
27+
"Shape": "circle",
28+
"Logo URL": "",
29+
"SVG_Color": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE svg><svg width=\"32\" height=\"32\" viewBox=\"0 0 122 122\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M34.667 116.007C4.287 101.462-8.551 65.04 5.992 34.657A60.98 60.98 0 0 1 87.333 5.98c30.38 14.544 43.218 50.966 28.675 81.35-14.544 30.383-50.962 43.222-81.341 28.677Z\" fill=\"#F49322\"/><path d=\"m29.488 41.005-1.92-3.24 11.328-5.76 1.92 3.24-11.328 5.76Zm18.048-9.18-1.92-3.24 10.176-5.22 1.92 3.24-10.176 5.22Zm10.368 26.1-10.176-5.04 1.728-3.24 10.176 5.04-1.728 3.24Zm-17.088-8.46-10.176-5.04 1.728-3.24 10.176 5.04-1.728 3.24Zm24.576 8.1-1.728-3.24 10.368-4.68 1.728 3.24-10.368 4.68Zm17.28-7.92-1.728-3.24 10.368-4.68 1.728 3.24-10.368 4.68Zm-25.92 50.58-11.52-5.76 1.728-3.24 11.52 5.76-1.728 3.24Zm-17.28-8.28-10.176-5.04 1.728-3.24 10.176 5.04-1.728 3.24Zm-10.368-46.26h-3.84v13.86h3.84v-13.86Zm33.792 35.82h-3.84v14.22h3.84v-14.22Z\" fill=\"#fff\"/><path d=\"M27.184 47.125a5.425 5.425 0 0 1-3.648-1.44c-.96-.9-1.536-2.16-1.536-3.42 0-1.26.576-2.52 1.536-3.42 1.92-1.8 5.376-1.8 7.296 0 .96.9 1.536 2.16 1.536 3.42 0 1.26-.576 2.52-1.536 3.42-.96.9-2.304 1.44-3.648 1.44Zm0-6.12c-.384 0-.768.18-.96.36-.192.18-.384.54-.384.9s.192.72.384.9c.576.54 1.344.54 1.92 0 .192-.18.384-.54.384-.9s-.192-.72-.384-.9a1.52 1.52 0 0 0-.96-.36Zm0 46.44a5.425 5.425 0 0 1-3.648-1.44c-.96-.9-1.536-2.16-1.536-3.42 0-1.26.576-2.52 1.536-3.42 1.92-1.8 5.376-1.8 7.296 0 .96.9 1.536 2.16 1.536 3.42 0 1.26-.576 2.52-1.536 3.42-.96.9-2.304 1.44-3.648 1.44Zm0-6.12c-.384 0-.768.18-.96.36-.192.18-.384.54-.384.9s.192.72.384.9c.576.54 1.344.54 1.92 0 .192-.18.384-.54.384-.9s-.192-.72-.384-.9a1.52 1.52 0 0 0-.96-.36Zm33.792 22.32a5.425 5.425 0 0 1-3.648-1.44c-.96-.9-1.536-2.16-1.536-3.42 0-1.26.576-2.52 1.536-3.42 2.112-1.98 5.376-1.98 7.296 0 2.112 1.98 2.112 5.04 0 6.84-1.152.9-2.304 1.44-3.648 1.44Zm0-6.3c-.384 0-.768.18-.96.36-.576.54-.576 1.26 0 1.8s1.344.54 1.92 0c.576-.54.576-1.26 0-1.8-.384-.18-.768-.36-.96-.36Zm0-34.2a5.425 5.425 0 0 1-3.648-1.44c-.96-.9-1.536-2.16-1.536-3.42 0-1.26.576-2.52 1.536-3.42 2.112-1.98 5.376-1.98 7.296 0 2.112 1.98 2.112 5.04 0 6.84-1.152 1.08-2.304 1.44-3.648 1.44Zm0-6.12c-.384 0-.768.18-.96.36-.576.54-.576 1.26 0 1.8s1.344.54 1.92 0c.576-.54.576-1.26 0-1.8-.384-.18-.768-.36-.96-.36Zm33.216 30.42a5.425 5.425 0 0 1-3.648-1.44c-2.112-1.98-2.112-5.04 0-6.84 1.92-1.8 5.376-1.8 7.296 0 .96.9 1.536 2.16 1.536 3.42 0 1.26-.576 2.52-1.536 3.42-.96.9-2.304 1.44-3.648 1.44Zm0-6.12c-.384 0-.768.18-.96.36-.576.54-.576 1.26 0 1.8s1.344.54 1.92 0c.576-.54.576-1.26 0-1.8a1.52 1.52 0 0 0-.96-.36Zm0-34.2a5.425 5.425 0 0 1-3.648-1.44c-2.112-1.98-2.112-5.04 0-6.84 1.92-1.8 5.376-1.8 7.296 0 2.112 1.98 2.112 5.04 0 6.84-.96.9-2.304 1.44-3.648 1.44Zm0-6.12c-.384 0-.768.18-.96.36-.576.54-.576 1.26 0 1.8s1.344.54 1.92 0c.576-.54.576-1.26 0-1.8a1.52 1.52 0 0 0-.96-.36Zm-33.216-12.24a5.425 5.425 0 0 1-3.648-1.44c-.96-.9-1.536-2.16-1.536-3.42 0-1.26.576-2.52 1.536-3.42 2.112-1.98 5.376-1.98 7.296 0 2.112 1.98 2.112 5.04 0 6.84-1.152.9-2.304 1.44-3.648 1.44Zm0-6.12c-.384 0-.768.18-.96.36-.576.54-.576 1.26 0 1.8s1.344.54 1.92 0c.576-.54.576-1.26 0-1.8-.384-.36-.768-.36-.96-.36Z\" fill=\"#fff\"/><path d=\"M29.104 63.145h-3.84v15.48h3.84v-15.48Zm66.816-17.46h-3.84v13.86h3.84v-13.86Zm0 17.46h-3.84v15.48h3.84v-15.48Zm-14.784-28.08 1.92-3.24L94 37.405l-1.92 3.24-10.944-5.58Zm-18.432-9.36 1.92-3.24 11.712 5.94-1.92 3.24-11.712-5.94Zm.192 36h-3.84v14.22h3.84v-14.22Zm.576 35.46 11.136-5.4 1.728 3.24-11.136 5.4-1.728-3.24Zm16.704-8.1 10.944-5.4 1.728 3.24-10.944 5.4-1.728-3.24Z\" fill=\"#fff\"/></svg>",
30+
"SVG_White": "<svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><g clip-path=\"url(#a)\" fill=\"#fff\"><path d=\"M3.095 8.319 2.3 7.094l4.682-2.178.794 1.225L3.095 8.32Zm7.46-3.47L9.76 3.622l4.205-1.973.794 1.225-4.206 1.973Zm4.285 9.866-4.207-1.905.715-1.225 4.206 1.906-.715 1.224Zm-7.063-3.198L3.57 9.612l.714-1.225 4.206 1.905-.714 1.225Zm10.157 3.063-.714-1.225 4.285-1.77.714 1.225-4.285 1.77Zm7.142-2.995-.714-1.225 4.285-1.769.714 1.225-4.285 1.77ZM14.363 30.707l-4.761-2.178.714-1.224 4.761 2.177-.714 1.225Zm-7.142-3.13-4.206-1.905.715-1.226 4.205 1.906-.714 1.225ZM2.936 10.088H1.35v5.24h1.587v-5.24ZM16.903 23.63h-1.587v5.376h1.587V23.63Z\"/><path d=\"M2.143 10.633a2.36 2.36 0 0 1-1.508-.545C.238 9.748 0 9.272 0 8.795c0-.476.238-.952.635-1.293.793-.68 2.222-.68 3.015 0 .397.34.635.817.635 1.293 0 .477-.238.953-.635 1.293a2.36 2.36 0 0 1-1.507.545Zm0-2.314a.662.662 0 0 0-.397.136.484.484 0 0 0-.159.34c0 .136.08.273.159.34a.59.59 0 0 0 .793 0 .484.484 0 0 0 .16-.34.484.484 0 0 0-.16-.34.662.662 0 0 0-.396-.136Zm0 17.556a2.36 2.36 0 0 1-1.508-.544C.238 24.991 0 24.515 0 24.038c0-.476.238-.953.635-1.293.793-.68 2.222-.68 3.015 0 .397.34.635.817.635 1.293 0 .477-.238.953-.635 1.293a2.36 2.36 0 0 1-1.507.544Zm0-2.313a.662.662 0 0 0-.397.136.484.484 0 0 0-.159.34c0 .136.08.272.159.34a.59.59 0 0 0 .793 0 .484.484 0 0 0 .16-.34.484.484 0 0 0-.16-.34.663.663 0 0 0-.396-.136ZM16.11 32a2.36 2.36 0 0 1-1.509-.544c-.396-.34-.635-.817-.635-1.293 0-.477.239-.953.635-1.293.873-.749 2.222-.749 3.016 0 .873.748.873 1.905 0 2.586-.476.34-.952.544-1.508.544Zm0-2.382a.662.662 0 0 0-.398.137c-.238.204-.238.476 0 .68a.59.59 0 0 0 .794 0c.238-.204.238-.476 0-.68-.159-.069-.317-.137-.397-.137Zm0-12.929a2.36 2.36 0 0 1-1.509-.544c-.396-.34-.635-.817-.635-1.293 0-.477.239-.953.635-1.293.873-.749 2.222-.749 3.016 0 .873.748.873 1.905 0 2.586-.476.408-.952.544-1.508.544Zm0-2.314a.662.662 0 0 0-.398.136c-.238.205-.238.477 0 .681a.59.59 0 0 0 .794 0c.238-.204.238-.476 0-.68-.159-.069-.317-.137-.397-.137Zm13.728 11.5a2.36 2.36 0 0 1-1.508-.544c-.873-.748-.873-1.905 0-2.586.793-.68 2.222-.68 3.015 0 .397.34.635.817.635 1.293 0 .477-.238.953-.635 1.293a2.36 2.36 0 0 1-1.507.544Zm0-2.313a.662.662 0 0 0-.397.136c-.238.204-.238.476 0 .68a.59.59 0 0 0 .793 0c.238-.204.238-.476 0-.68a.663.663 0 0 0-.396-.136Zm0-12.929a2.36 2.36 0 0 1-1.508-.545c-.873-.748-.873-1.905 0-2.586.793-.68 2.222-.68 3.015 0 .873.749.873 1.906 0 2.586a2.36 2.36 0 0 1-1.507.545Zm0-2.314a.663.663 0 0 0-.397.136c-.238.204-.238.476 0 .68a.59.59 0 0 0 .793 0c.238-.204.238-.476 0-.68a.662.662 0 0 0-.396-.136ZM16.11 3.692a2.36 2.36 0 0 1-1.509-.545c-.396-.34-.635-.816-.635-1.293 0-.476.239-.952.635-1.293.873-.748 2.222-.748 3.016 0 .873.749.873 1.906 0 2.586-.476.34-.952.545-1.508.545Zm0-2.314a.662.662 0 0 0-.398.136c-.238.204-.238.476 0 .68a.59.59 0 0 0 .794 0c.238-.204.238-.476 0-.68-.159-.136-.317-.136-.397-.136Z\"/><path d=\"M2.936 16.689H1.35v5.852h1.587V16.69Zm27.616-6.601h-1.587v5.24h1.587v-5.24Zm0 6.601h-1.587v5.852h1.587V16.69Zm-6.11-10.616.793-1.225 4.523 2.11-.793 1.225-4.523-2.11Zm-7.619-3.538.794-1.225 4.84 2.245-.793 1.225-4.84-2.245Zm.08 13.61h-1.587v5.376h1.587v-5.376Zm.237 13.405 4.603-2.041.715 1.225-4.603 2.041-.714-1.225Zm6.905-3.062 4.523-2.041.714 1.225-4.523 2.04-.714-1.224Z\"/></g><defs><clipPath id=\"a\"><path fill=\"#fff\" d=\"M0 0h32v32H0z\"/></clipPath></defs></svg>",
31+
}
32+
33+
var MeshModelConfig = adapter.MeshModelConfig{ //Move to build/config.go
34+
Category: "Orchestration & Management",
35+
SubCategory: "Service Mesh",
36+
Metadata: meshmodelmetadata,
37+
}
38+
2339
// NewConfig creates the configuration for creating components
2440
func NewConfig(version string) manifests.Config {
2541
return manifests.Config{
@@ -41,6 +57,7 @@ func NewConfig(version string) manifests.Config {
4157
func init() {
4258
wd, _ := os.Getwd()
4359
WorkloadPath = filepath.Join(wd, "templates", "oam", "workloads")
60+
MeshModelPath = filepath.Join(wd, "templates", "meshmodel", "components")
4461
AllVersions, _ = utils.GetLatestReleaseTagsSorted("aws", "aws-app-mesh-controller-for-k8s")
4562
if len(AllVersions) == 0 {
4663
return

go.mod

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ replace (
1010

1111
require (
1212
github.com/google/uuid v1.3.0
13-
github.com/layer5io/meshery-adapter-library v0.6.0
13+
github.com/layer5io/meshery-adapter-library v0.6.3
1414
github.com/layer5io/meshkit v0.6.11
1515
github.com/layer5io/service-mesh-performance v0.3.4
1616
gopkg.in/yaml.v2 v2.4.0
@@ -73,6 +73,15 @@ require (
7373
github.com/huandu/xstrings v1.3.2 // indirect
7474
github.com/imdario/mergo v0.3.12 // indirect
7575
github.com/inconshreveable/mousetrap v1.0.0 // indirect
76+
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
77+
github.com/jackc/pgconn v1.13.0 // indirect
78+
github.com/jackc/pgio v1.0.0 // indirect
79+
github.com/jackc/pgpassfile v1.0.0 // indirect
80+
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
81+
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
82+
github.com/jackc/pgtype v1.12.0 // indirect
83+
github.com/jackc/pgx/v4 v4.17.2 // indirect
84+
github.com/jinzhu/inflection v1.0.0 // indirect
7685
github.com/jinzhu/now v1.1.5 // indirect
7786
github.com/jmoiron/sqlx v1.3.5 // indirect
7887
github.com/josharian/intern v1.0.0 // indirect
@@ -125,7 +134,6 @@ require (
125134
github.com/spf13/jwalterweatherman v1.1.0 // indirect
126135
github.com/spf13/pflag v1.0.5 // indirect
127136
github.com/spf13/viper v1.11.0 // indirect
128-
github.com/stretchr/objx v0.4.0 // indirect
129137
github.com/subosito/gotenv v1.2.0 // indirect
130138
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
131139
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
@@ -152,6 +160,8 @@ require (
152160
gopkg.in/inf.v0 v0.9.1 // indirect
153161
gopkg.in/ini.v1 v1.66.4 // indirect
154162
gopkg.in/yaml.v3 v3.0.1 // indirect
163+
gorm.io/driver/postgres v1.3.10 // indirect
164+
gorm.io/driver/sqlite v1.3.1 // indirect
155165
gorm.io/gorm v1.23.7 // indirect
156166
helm.sh/helm/v3 v3.9.4 // indirect
157167
k8s.io/api v0.25.1 // indirect

0 commit comments

Comments
 (0)