From fbf9d12f7d02739e5d8834e48a8753d9ad171868 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Thu, 15 Dec 2022 15:14:58 +0530 Subject: [PATCH 1/3] Fix failing lint checks and externalize config Signed-off-by: Ashish Tiwari --- build/config.go | 19 ++++++++++--------- build/meshmodel_metadata.json | 8 ++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 build/meshmodel_metadata.json diff --git a/build/config.go b/build/config.go index ae51036f..7fa7a736 100644 --- a/build/config.go +++ b/build/config.go @@ -1,7 +1,9 @@ package build import ( + "encoding/json" "fmt" + "io" "os" "path/filepath" "strings" @@ -22,19 +24,12 @@ var CRDnamesURL map[string]string const Component = "Linkerd" -var meshmodelmetadata = map[string]interface{}{ - "Primary Color": "#0DA6E5", - "Secondary Color": "#0DA6E5", - "Shape": "circle", - "Logo URL": "https://github.com/cncf/artwork/blob/master/projects/linkerd/icon/white/linkerd-icon-white.svg", - "SVG_Color": "", - "SVG_White": "", -} +var Meshmodelmetadata = make(map[string]interface{}) var MeshModelConfig = adapter.MeshModelConfig{ //Move to build/config.go Category: "Orchestration & Management", SubCategory: "Service Mesh", - Metadata: meshmodelmetadata, + Metadata: Meshmodelmetadata, } // NewConfig creates the configuration for creating components @@ -57,6 +52,12 @@ func NewConfig(version string) manifests.Config { } } func init() { + //Initialize Metadata including logo svgs + f, _ := os.Open("./build/meshmodel_metadata.json") + defer f.Close() + byt, _ := io.ReadAll(f) + + _ = json.Unmarshal(byt, &Meshmodelmetadata) wd, _ := os.Getwd() WorkloadPath = filepath.Join(wd, "templates", "oam", "workloads") MeshModelPath = filepath.Join(wd, "templates", "meshmodel", "components") diff --git a/build/meshmodel_metadata.json b/build/meshmodel_metadata.json new file mode 100644 index 00000000..21a4d868 --- /dev/null +++ b/build/meshmodel_metadata.json @@ -0,0 +1,8 @@ +{ + "Primary Color": "#0DA6E5", + "Secondary Color": "#0DA6E5", + "Shape": "circle", + "Logo URL": "https://github.com/cncf/artwork/blob/master/projects/linkerd/icon/white/linkerd-icon-white.svg", + "SVG_Color": "", + "SVG_White": "" +} \ No newline at end of file From 186dec2bfb71ec8397776cd4f0bc9604e647c90b Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Mon, 26 Dec 2022 18:56:50 +0530 Subject: [PATCH 2/3] Remove Logo URL Signed-off-by: Ashish Tiwari --- build/meshmodel_metadata.json | 1 - 1 file changed, 1 deletion(-) diff --git a/build/meshmodel_metadata.json b/build/meshmodel_metadata.json index 21a4d868..87ce318c 100644 --- a/build/meshmodel_metadata.json +++ b/build/meshmodel_metadata.json @@ -2,7 +2,6 @@ "Primary Color": "#0DA6E5", "Secondary Color": "#0DA6E5", "Shape": "circle", - "Logo URL": "https://github.com/cncf/artwork/blob/master/projects/linkerd/icon/white/linkerd-icon-white.svg", "SVG_Color": "", "SVG_White": "" } \ No newline at end of file From 66a93f1dc2e5c42fdf15686bad67288ed9ce1ba7 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Mon, 26 Dec 2022 19:05:54 +0530 Subject: [PATCH 3/3] Merge conf Signed-off-by: Ashish Tiwari --- build/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/config.go b/build/config.go index 7fa7a736..b4348b6f 100644 --- a/build/config.go +++ b/build/config.go @@ -54,7 +54,12 @@ func NewConfig(version string) manifests.Config { func init() { //Initialize Metadata including logo svgs f, _ := os.Open("./build/meshmodel_metadata.json") - defer f.Close() + defer func() { + err := f.Close() + if err != nil { + fmt.Println(err.Error()) + } + }() byt, _ := io.ReadAll(f) _ = json.Unmarshal(byt, &Meshmodelmetadata)