Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit e41b605

Browse files
authored
Merge pull request #238 from meshery/removeOAM
Remove OAM and update adapter library
2 parents 3e8d22d + fa2a77c commit e41b605

File tree

3,594 files changed

+6523
-197157
lines changed

Some content is hidden

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

3,594 files changed

+6523
-197157
lines changed

build/config.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,16 @@ import (
1818

1919
var DefaultGenerationMethod string
2020
var LatestVersion string
21-
var WorkloadPath string
2221
var MeshModelPath string
2322
var CRDnames []string
2423
var OverrideURL string
2524
var AllVersions []string
2625

2726
const Component = "OSM"
2827

29-
var meshmodelmetadata = make(map[string]interface{})
30-
3128
var MeshModelConfig = adapter.MeshModelConfig{ //Move to build/config.go
32-
Category: "Orchestration & Management",
33-
Metadata: meshmodelmetadata,
29+
Category: "Cloud Native Network",
30+
Metadata: map[string]interface{}{},
3431
}
3532

3633
// NewConfig creates the configuration for creating components
@@ -68,8 +65,7 @@ func init() {
6865
}()
6966
byt, _ := io.ReadAll(f)
7067

71-
_ = json.Unmarshal(byt, &meshmodelmetadata)
72-
WorkloadPath = filepath.Join(wd, "templates", "oam", "workloads")
68+
_ = json.Unmarshal(byt, &MeshModelConfig.Metadata)
7369
MeshModelPath = filepath.Join(wd, "templates", "meshmodel", "components")
7470
AllVersions, _ = utils.GetLatestReleaseTagsSorted("openservicemesh", "osm")
7571
if len(AllVersions) == 0 {

build/meshmodel_component.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/meshmodel_metadata.json

Lines changed: 7 additions & 0 deletions
Large diffs are not rendered by default.

go.mod

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

1111
require (
1212
github.com/google/uuid v1.3.0
13-
github.com/layer5io/meshery-adapter-library v0.6.5
14-
github.com/layer5io/meshkit v0.6.31
13+
github.com/layer5io/meshery-adapter-library v0.6.7
14+
github.com/layer5io/meshkit v0.6.40
1515
github.com/layer5io/service-mesh-performance v0.3.4
1616
gopkg.in/yaml.v2 v2.4.0
1717
k8s.io/apimachinery v0.26.1
@@ -28,8 +28,6 @@ require (
2828
github.com/Masterminds/squirrel v1.5.3 // indirect
2929
github.com/Microsoft/go-winio v0.5.2 // indirect
3030
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
31-
github.com/PuerkitoBio/purell v1.1.1 // indirect
32-
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
3331
github.com/acomagu/bufpipe v1.0.3 // indirect
3432
github.com/apache/thrift v0.13.0 // indirect
3533
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
@@ -123,7 +121,6 @@ require (
123121
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
124122
github.com/opencontainers/go-digest v1.0.0 // indirect
125123
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
126-
github.com/pelletier/go-toml v1.9.5 // indirect
127124
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
128125
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
129126
github.com/pkg/errors v0.9.1 // indirect
@@ -132,7 +129,6 @@ require (
132129
github.com/prometheus/common v0.37.0 // indirect
133130
github.com/prometheus/procfs v0.8.0 // indirect
134131
github.com/rubenv/sql-migrate v1.2.0 // indirect
135-
github.com/russross/blackfriday v1.6.0 // indirect
136132
github.com/russross/blackfriday/v2 v2.1.0 // indirect
137133
github.com/sergi/go-diff v1.1.0 // indirect
138134
github.com/shopspring/decimal v1.2.0 // indirect

go.sum

Lines changed: 18 additions & 240 deletions
Large diffs are not rendered by default.

main.go

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"fmt"
1919
"os"
2020
"path"
21-
"path/filepath"
2221
"strings"
2322
"time"
2423

@@ -132,16 +131,6 @@ func serviceAddress() string {
132131
}
133132

134133
func registerCapabilities(port string, log logger.Handler) {
135-
// Register workloads
136-
if err := oam.RegisterWorkloads(mesheryServerAddress(), serviceAddress()+":"+port); err != nil {
137-
log.Info(err.Error())
138-
}
139-
140-
// Register traits
141-
if err := oam.RegisterTraits(mesheryServerAddress(), serviceAddress()+":"+port); err != nil {
142-
log.Info(err.Error())
143-
}
144-
145134
// Register meshmodel components
146135
if err := oam.RegisterMeshModelComponents(instanceID, mesheryServerAddress(), serviceAddress(), port); err != nil {
147136
log.Info(err.Error())
@@ -168,22 +157,13 @@ func registerWorkloads(port string, log logger.Handler) {
168157
log.Info("Components available statically for version ", version, ". Skipping dynamic component registeration")
169158
return
170159
}
171-
//If a URL is passed from env variable, it will be used for component generation with default method being "using manifests"
172-
// In case a helm chart URL is passed, COMP_GEN_METHOD env variable should be set to Helm otherwise the component generation fails
173-
if os.Getenv("COMP_GEN_URL") != "" && (os.Getenv("COMP_GEN_METHOD") == "Helm" || os.Getenv("COMP_GEN_METHOD") == "Manifest") {
174-
build.OverrideURL = os.Getenv("COMP_GEN_URL")
175-
gm = os.Getenv("COMP_GEN_METHOD")
176-
log.Info("Registering workload components from url ", build.OverrideURL, " using ", gm, " method...")
177-
build.CRDnames = []string{"user passed configuration"}
178-
}
179160
log.Info("Registering latest workload components for version ", version)
180161
// Register workloads
181162
for _, crd := range build.CRDnames {
182163
log.Info("Generating components for ", crd)
183164
if err := adapter.CreateComponents(adapter.StaticCompConfig{
184165
URL: build.GetDefaultURL(crd),
185166
Method: gm,
186-
OAMPath: build.WorkloadPath,
187167
MeshModelPath: build.MeshModelPath,
188168
MeshModelConfig: build.MeshModelConfig,
189169
DirName: version,
@@ -197,19 +177,12 @@ func registerWorkloads(port string, log logger.Handler) {
197177

198178
//*The below log is checked in the workflows. If you change this log, reflect that change in the workflow where components are generated
199179
log.Info("Component creation completed for version ", version)
200-
201180
//Now we will register in case
202181
log.Info("Registering workloads with Meshery Server for version ", version)
203-
originalPath := oam.WorkloadPath
204-
oam.WorkloadPath = filepath.Join(originalPath, version)
205-
defer resetWorkloadPath(originalPath)
206-
if err := oam.RegisterWorkloads(mesheryServerAddress(), serviceAddress()+":"+port); err != nil {
182+
if err := oam.RegisterMeshModelComponents(instanceID, mesheryServerAddress(), serviceAddress(), port); err != nil {
207183
log.Info(err.Error())
208184
return
209185
}
210186

211187
log.Info("Latest workload components successfully registered.")
212188
}
213-
func resetWorkloadPath(orig string) {
214-
oam.WorkloadPath = orig
215-
}

osm/oam/register.go

Lines changed: 1 addition & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,21 @@ import (
55
"os"
66
"path/filepath"
77
"strconv"
8-
"strings"
98
"sync"
109

1110
"github.com/layer5io/meshery-adapter-library/adapter"
12-
"github.com/layer5io/meshery-osm/internal/config"
1311
"github.com/layer5io/meshkit/models/meshmodel/core/types"
1412
)
1513

1614
var (
17-
basePath, _ = os.Getwd()
18-
//WorkloadPath will be used by both static and component generation
19-
WorkloadPath = filepath.Join(basePath, "templates", "oam", "workloads")
15+
basePath, _ = os.Getwd()
2016
MeshmodelComponents = filepath.Join(basePath, "templates", "meshmodel", "components")
21-
traitPath = filepath.Join(basePath, "templates", "oam", "traits")
2217
)
2318

2419
// AvailableVersions denote the component versions available statically
2520
var AvailableVersions = map[string]bool{}
26-
var pathSets []schemaDefinitionPathSet
2721
var availableVersionGlobalMutex sync.Mutex
2822

29-
type schemaDefinitionPathSet struct {
30-
oamDefinitionPath string
31-
jsonSchemaPath string
32-
name string
33-
}
34-
3523
type meshmodelDefinitionPathSet struct {
3624
meshmodelDefinitionPath string
3725
}
@@ -57,65 +45,6 @@ func RegisterMeshModelComponents(uuid, runtime, host, port string) error {
5745
Register(uuid)
5846
}
5947

60-
// RegisterWorkloads will register all of the workload definitions
61-
// present in the path oam/workloads
62-
//
63-
// Registration process will send POST request to $runtime/api/oam/workload
64-
func RegisterWorkloads(runtime, host string) error {
65-
oamRDP := []adapter.OAMRegistrantDefinitionPath{}
66-
67-
for _, pathSet := range pathSets {
68-
metadata := map[string]string{
69-
config.OAMAdapterNameMetadataKey: config.OSMOperation,
70-
}
71-
72-
if strings.HasSuffix(pathSet.name, "addon") {
73-
metadata[config.OAMComponentCategoryMetadataKey] = "addon"
74-
}
75-
76-
oamRDP = append(oamRDP, adapter.OAMRegistrantDefinitionPath{
77-
OAMDefintionPath: pathSet.oamDefinitionPath,
78-
OAMRefSchemaPath: pathSet.jsonSchemaPath,
79-
Host: host,
80-
Metadata: metadata,
81-
})
82-
}
83-
84-
return adapter.
85-
NewOAMRegistrant(oamRDP, fmt.Sprintf("%s/api/oam/workload", runtime)).
86-
Register()
87-
}
88-
89-
// RegisterTraits will register all of the trait definitions
90-
// present in the path oam/traits
91-
//
92-
// Registeration process will send POST request to $runtime/api/oam/trait
93-
func RegisterTraits(runtime, host string) error {
94-
oamRDP := []adapter.OAMRegistrantDefinitionPath{}
95-
96-
pathSets, err := load(traitPath)
97-
if err != nil {
98-
return err
99-
}
100-
101-
for _, pathSet := range pathSets {
102-
metadata := map[string]string{
103-
config.OAMAdapterNameMetadataKey: config.OSMOperation,
104-
}
105-
106-
oamRDP = append(oamRDP, adapter.OAMRegistrantDefinitionPath{
107-
OAMDefintionPath: pathSet.oamDefinitionPath,
108-
OAMRefSchemaPath: pathSet.jsonSchemaPath,
109-
Host: host,
110-
Metadata: metadata,
111-
})
112-
}
113-
114-
return adapter.
115-
NewOAMRegistrant(oamRDP, fmt.Sprintf("%s/api/oam/trait", runtime)).
116-
Register()
117-
}
118-
11948
func loadMeshmodelComponents(basepath string) ([]meshmodelDefinitionPathSet, error) {
12049
res := []meshmodelDefinitionPathSet{}
12150
if err := filepath.Walk(basepath, func(path string, info os.FileInfo, err error) error {
@@ -140,46 +69,3 @@ func loadMeshmodelComponents(basepath string) ([]meshmodelDefinitionPathSet, err
14069

14170
return res, nil
14271
}
143-
144-
func load(basePath string) ([]schemaDefinitionPathSet, error) {
145-
res := []schemaDefinitionPathSet{}
146-
147-
if err := filepath.Walk(basePath, func(path string, info os.FileInfo, err error) error {
148-
if err != nil {
149-
return err
150-
}
151-
152-
if info.IsDir() {
153-
return nil
154-
}
155-
156-
if matched, err := filepath.Match("*_definition.json", filepath.Base(path)); err != nil {
157-
return err
158-
} else if matched {
159-
nameWithPath := strings.TrimSuffix(path, "_definition.json")
160-
161-
res = append(res, schemaDefinitionPathSet{
162-
oamDefinitionPath: path,
163-
jsonSchemaPath: fmt.Sprintf("%s.meshery.layer5io.schema.json", nameWithPath),
164-
name: filepath.Base(nameWithPath),
165-
})
166-
availableVersionGlobalMutex.Lock()
167-
AvailableVersions[filepath.Base(filepath.Dir(path))] = true
168-
availableVersionGlobalMutex.Unlock()
169-
}
170-
171-
return nil
172-
}); err != nil {
173-
return nil, err
174-
}
175-
176-
return res, nil
177-
}
178-
179-
func init() {
180-
var err error
181-
pathSets, err = load(WorkloadPath)
182-
if err != nil {
183-
fmt.Println("Err loading components: ", err.Error())
184-
}
185-
}

templates/meshmodel/components/v0.0.1/egress.OSM.meshery.layer5.io_meshmodel.json

Lines changed: 32 additions & 1 deletion
Large diffs are not rendered by default.

templates/meshmodel/components/v0.0.1/extensionservice.OSM.meshery.layer5.io_meshmodel.json

Lines changed: 33 additions & 1 deletion
Large diffs are not rendered by default.

templates/meshmodel/components/v0.0.1/httproutegroup.OSM.meshery.layer5.io_meshmodel.json

Lines changed: 8 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)