Skip to content

Commit

Permalink
Merge pull request #572 from Revolyssup/removeOAM
Browse files Browse the repository at this point in the history
Remove OAM and update adapter library
  • Loading branch information
Revolyssup committed Apr 19, 2023
2 parents 7a50544 + 2b97313 commit fc344db
Show file tree
Hide file tree
Showing 6,591 changed files with 1,508 additions and 624,844 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 2 additions & 6 deletions build/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ import (
var DefaultGenerationMethod string
var DefaultGenerationURL string
var LatestVersion string
var WorkloadPath string
var MeshModelPath string
var AllVersions []string

const Component = "Istio"

var Meshmodelmetadata = make(map[string]interface{})

var MeshModelConfig = adapter.MeshModelConfig{ //Move to build/config.go
Category: "Cloud Native Network",
Metadata: Meshmodelmetadata,
Metadata: map[string]interface{}{},
}

// NewConfig creates the configuration for creating components
Expand Down Expand Up @@ -59,9 +56,8 @@ func init() {
}()
byt, _ := io.ReadAll(f)

_ = json.Unmarshal(byt, &Meshmodelmetadata)
_ = json.Unmarshal(byt, &MeshModelConfig.Metadata)
wd, _ := os.Getwd()
WorkloadPath = filepath.Join(wd, "templates", "oam", "workloads")
MeshModelPath = filepath.Join(wd, "templates", "meshmodel", "components")
AllVersions, _ = utils.GetLatestReleaseTagsSorted("istio", "istio")
if len(AllVersions) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions build/meshmodel_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"secondaryColor": "#93b0e6",
"shape": "circle",
"logoURL": "https://github.com/istio/istio/blob/master/logo/istio-bluelogo-whitebackground-unframed.svg",
"svgColor": "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 160 240\"><g id=\"logo\" fill=\"#466BB0\"><rect id=\"background\" width=\"160\" height=\"240\" fill=\"#fff\"/><polygon id=\"hull\" points=\"0 210 160 210 60 240\"/><polygon id=\"mainsail\" points=\"0 200 60 190 60 80\"/><polygon id=\"headsail\" points=\"70 190 160 200 70 0\"/></g></svg>\n",
"svgWhite": "<svg viewBox=\"6.386270046234131 3.7419400215148926 18.227430820465088 25.258059978485107\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6.38627 24.7904L13.2215 23.738V12.1613L6.38627 24.7904Z\" fill=\"white\"/><path d=\"M6.38627 25.8427H24.6137L13.2215 29L6.38627 25.8427Z\" fill=\"white\"/><path d=\"M14.3608 23.7379L24.6137 24.7904L14.3608 3.74194V23.7379Z\" fill=\"white\"/></svg>"
"svgColor": "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"20\" width=\"20\" viewBox=\"0 0 160 240\"><g id=\"logo\" fill=\"#466BB0\"><rect id=\"background\" width=\"160\" height=\"240\" fill=\"#fff\"/><polygon id=\"hull\" points=\"0 210 160 210 60 240\"/><polygon id=\"mainsail\" points=\"0 200 60 190 60 80\"/><polygon id=\"headsail\" points=\"70 190 160 200 70 0\"/></g></svg>\n",
"svgWhite": "<svg height=\"20\" width=\"20\" viewBox=\"6.386270046234131 3.7419400215148926 18.227430820465088 25.258059978485107\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6.38627 24.7904L13.2215 23.738V12.1613L6.38627 24.7904Z\" fill=\"white\"/><path d=\"M6.38627 25.8427H24.6137L13.2215 29L6.38627 25.8427Z\" fill=\"white\"/><path d=\"M14.3608 23.7379L24.6137 24.7904L14.3608 3.74194V23.7379Z\" fill=\"white\"/></svg>"
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ replace (

require (
github.com/aspenmesh/istio-vet v0.0.0-20200806222806-9c8e9a962b9f
github.com/layer5io/meshery-adapter-library v0.6.5
github.com/layer5io/meshery-adapter-library v0.6.7
github.com/layer5io/meshkit v0.6.34
github.com/layer5io/service-mesh-performance v0.3.4
gopkg.in/yaml.v2 v2.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6Fm
github.com/layer5io/kuttl v0.4.1-0.20200723152044-916f10574334/go.mod h1:UmrVd7x+bNVKrpmKgTtfRiTKHZeNPcMjQproJ0vGwhE=
github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3e34 h1:QaViadDOBCMDUwYx78kfRvHMkzRVnh/GOhm3s2gxoP4=
github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3e34/go.mod h1:BQPLwdJt7v7y0fXIejI4whR9zMyX07Wjt5xrbgEmHLw=
github.com/layer5io/meshery-adapter-library v0.6.5 h1:0MYpWFwLDo3ziiU3RCvIHjAUQf6tWRHVmFIFEID06y0=
github.com/layer5io/meshery-adapter-library v0.6.5/go.mod h1:7vsze4Cd0pzKtbD+BARNa/vt+GYSzmkhKA6unmAD0qc=
github.com/layer5io/meshery-adapter-library v0.6.7 h1:d0NpqTwF4djt0SWKpIGjEl6BTFK9Li32ynYx5BS5A8E=
github.com/layer5io/meshery-adapter-library v0.6.7/go.mod h1:7vsze4Cd0pzKtbD+BARNa/vt+GYSzmkhKA6unmAD0qc=
github.com/layer5io/meshkit v0.6.34 h1:O6reRSDNZOIEvmU1SFYIoocdrYaBWYffvohXGAwcw10=
github.com/layer5io/meshkit v0.6.34/go.mod h1:eNje6+B3/EkAkyvNHgeelwD7pPEf12eTh8iPMgMGfiM=
github.com/layer5io/service-mesh-performance v0.3.2-0.20210122142912-a94e0658b021/go.mod h1:W153amv8aHAeIWxO7b7d7Vibt9RhaEVh4Uh+RG+BumQ=
Expand Down
73 changes: 1 addition & 72 deletions istio/oam/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ import (
"sync"

"github.com/layer5io/meshery-adapter-library/adapter"
"github.com/layer5io/meshery-istio/internal/config"
"github.com/layer5io/meshkit/models/meshmodel/core/types"
)

var (
basePath, _ = os.Getwd()

//WorkloadPath will be used by both static and component generation
WorkloadPath = filepath.Join(basePath, "templates", "oam", "workloads")
basePath, _ = os.Getwd()
MeshmodelComponents = filepath.Join(basePath, "templates", "meshmodel", "components")
traitPath = filepath.Join(basePath, "templates", "oam", "traits")
)

// AvailableVersions denote the component versions available statically
Expand Down Expand Up @@ -55,68 +50,6 @@ func RegisterMeshModelComponents(uuid, runtime, host, port string) error {
Register(uuid)
}

// RegisterWorkloads will register all of the workload definitions
// present in the path oam/workloads
//
// Registration process will send POST request to $runtime/api/oam/workload
func RegisterWorkloads(runtime, host string) error {
oamRDP := []adapter.OAMRegistrantDefinitionPath{}
pathSets, err := load(WorkloadPath)
if err != nil {
return err
}
for _, pathSet := range pathSets {
metadata := map[string]string{
config.OAMAdapterNameMetadataKey: config.IstioOperation,
}

if strings.HasSuffix(pathSet.name, "addon") {
metadata[config.OAMComponentCategoryMetadataKey] = "addon"
}

oamRDP = append(oamRDP, adapter.OAMRegistrantDefinitionPath{
OAMDefintionPath: pathSet.oamDefinitionPath,
OAMRefSchemaPath: pathSet.jsonSchemaPath,
Host: host,
Metadata: metadata,
})
}

return adapter.
NewOAMRegistrant(oamRDP, fmt.Sprintf("%s/api/oam/workload", runtime)).
Register()
}

// RegisterTraits will register all of the trait definitions
// present in the path oam/traits
//
// Registeration process will send POST request to $runtime/api/oam/trait
func RegisterTraits(runtime, host string) error {
oamRDP := []adapter.OAMRegistrantDefinitionPath{}

pathSets, err := load(traitPath)
if err != nil {
return err
}

for _, pathSet := range pathSets {
metadata := map[string]string{
config.OAMAdapterNameMetadataKey: config.IstioOperation,
}

oamRDP = append(oamRDP, adapter.OAMRegistrantDefinitionPath{
OAMDefintionPath: pathSet.oamDefinitionPath,
OAMRefSchemaPath: pathSet.jsonSchemaPath,
Host: host,
Metadata: metadata,
})
}

return adapter.
NewOAMRegistrant(oamRDP, fmt.Sprintf("%s/api/oam/trait", runtime)).
Register()
}

var versionLock sync.Mutex

func loadMeshmodelComponents(basepath string) ([]meshmodelDefinitionPathSet, error) {
Expand Down Expand Up @@ -176,7 +109,3 @@ func load(basePath string) ([]schemaDefinitionPathSet, error) {

return res, nil
}
func init() {
//This is done only to find available versions at startup
_, _ = load(WorkloadPath)
}
29 changes: 9 additions & 20 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"fmt"
"os"
"path"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -152,15 +151,6 @@ func serviceAddress() string {
}

func registerCapabilities(port string, log logger.Handler) {
// Register workloads
log.Info("Registering static workloads with Meshery Server...")
if err := oam.RegisterWorkloads(mesheryServerAddress(), serviceAddress()+":"+port); err != nil {
log.Error(err)
}
// Register traits
if err := oam.RegisterTraits(mesheryServerAddress(), serviceAddress()+":"+port); err != nil {
log.Error(err)
}
err := oam.RegisterMeshModelComponents(instanceID, mesheryServerAddress(), serviceAddress(), port)
if err != nil {
log.Error(err)
Expand Down Expand Up @@ -199,11 +189,9 @@ func registerWorkloads(port string, log logger.Handler) {
}

log.Info("Registering latest workload components for version ", version)

err := adapter.CreateComponents(adapter.StaticCompConfig{
URL: url,
Method: gm,
OAMPath: build.WorkloadPath,
MeshModelPath: build.MeshModelPath,
MeshModelConfig: build.MeshModelConfig,
DirName: version,
Expand All @@ -214,22 +202,23 @@ func registerWorkloads(port string, log logger.Handler) {
log.Error(err)
return
}
// err := adapter.CreateComponents(adapter.StaticCompConfig{
// URL: url,
// Method: gm,
// MeshModelPath: build.MeshModelPath,
// MeshModelConfig: build.MeshModelConfig,
// DirName: version,
// Config: build.NewConfig(version),
// })

//The below log is checked in the workflows. If you change this log, reflect that change in the workflow where components are generated
log.Info("Component creation completed for version ", version)

//Now we will register in case
log.Info("Registering workloads with Meshery Server for version ", version)
originalPath := oam.WorkloadPath
oam.WorkloadPath = filepath.Join(originalPath, version)
defer resetWorkloadPath(originalPath)
if err := oam.RegisterWorkloads(mesheryServerAddress(), serviceAddress()+":"+port); err != nil {
if err := oam.RegisterMeshModelComponents(instanceID, mesheryServerAddress(), serviceAddress(), port); err != nil {
log.Error(err)
return
}
log.Info("Latest workload components successfully registered for version ", version)
}

func resetWorkloadPath(orig string) {
oam.WorkloadPath = orig
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit fc344db

Please sign in to comment.