From d471a4057f1ddaa8829ca8bdb171f212ec5d1f92 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Thu, 20 Apr 2023 01:05:16 +0530 Subject: [PATCH] Remove OAM Signed-off-by: Ashish Tiwari --- adapter/oam.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/adapter/oam.go b/adapter/oam.go index 796c1b1..6c7e1f7 100644 --- a/adapter/oam.go +++ b/adapter/oam.go @@ -187,22 +187,15 @@ type StaticCompConfig struct { // CreateComponents generates components for a given configuration and stores them. func CreateComponents(scfg StaticCompConfig) error { - meshmodeldirName, err := getLatestDirectory(scfg.MeshModelPath) - if err != nil { - return ErrCreatingComponents(err) - } + meshmodeldirName, _ := getLatestDirectory(scfg.MeshModelPath) meshmodelDir := filepath.Join(scfg.MeshModelPath, scfg.DirName) - _, err = os.Stat(meshmodelDir) - if err != nil && !os.IsNotExist(err) { - return ErrCreatingComponents(err) - } + _, err := os.Stat(meshmodelDir) if err != nil && os.IsNotExist(err) { err = os.Mkdir(meshmodelDir, 0777) if err != nil { return ErrCreatingComponents(err) } } - var comp *manifests.Component switch scfg.Method { case Manifests: @@ -229,9 +222,11 @@ func CreateComponents(scfg StaticCompConfig) error { } } //For Meshmodel components - err = copyCoreComponentsToNewVersion(filepath.Join(scfg.MeshModelPath, meshmodeldirName), filepath.Join(scfg.MeshModelPath, scfg.DirName), scfg.DirName, true) - if err != nil { - return ErrCreatingComponents(err) + if meshmodeldirName != "" { + err = copyCoreComponentsToNewVersion(filepath.Join(scfg.MeshModelPath, meshmodeldirName), filepath.Join(scfg.MeshModelPath, scfg.DirName), scfg.DirName, true) + if err != nil { + return ErrCreatingComponents(err) + } } return nil } @@ -269,6 +264,7 @@ func convertOAMtoMeshmodel(def []byte, schema string, isCore bool, meshmodelname } c.Model.DisplayName = manifests.FormatToReadableString(c.Model.Name) c.Model.Name = strings.ToLower(c.Model.Name) + c.Model.Metadata = c.Metadata c.Format = meshmodel.JSON c.Schema = schema byt, err := json.Marshal(c)