From c525b0eca878ec8df7a73a6262ada6e58d89ab14 Mon Sep 17 00:00:00 2001 From: OmriGez Date: Thu, 1 Feb 2024 15:06:31 +0200 Subject: [PATCH 1/8] updated mapping and schema to support icons --- pkg/defaults/defaults_test.go | 2 +- pkg/port/mapping/entity.go | 6 ++++++ pkg/port/models.go | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/defaults/defaults_test.go b/pkg/defaults/defaults_test.go index 444aa57..1947644 100644 --- a/pkg/defaults/defaults_test.go +++ b/pkg/defaults/defaults_test.go @@ -202,7 +202,7 @@ func Test_InitIntegration_DeprecatedResourcesConfiguration(t *testing.T) { { Kind: "workload", Port: port.Port{ - Entity: port.EntityMappings{ + Entity: port.EntityMa§ppings{ Mappings: []port.EntityMapping{ { Identifier: "workload", diff --git a/pkg/port/mapping/entity.go b/pkg/port/mapping/entity.go index fa8180b..e0e951c 100644 --- a/pkg/port/mapping/entity.go +++ b/pkg/port/mapping/entity.go @@ -28,6 +28,12 @@ func NewEntity(obj interface{}, mapping port.EntityMapping) (*port.Entity, error return &port.Entity{}, err } } + if mapping.Icon != "" { + entity.Icon, err = jq.ParseString(mapping.Icon, obj) + if err != nil { + return &port.Entity{}, err + } + } entity.Properties, err = jq.ParseMapInterface(mapping.Properties, obj) if err != nil { return &port.Entity{}, err diff --git a/pkg/port/models.go b/pkg/port/models.go index b5e472c..c1ba627 100644 --- a/pkg/port/models.go +++ b/pkg/port/models.go @@ -181,6 +181,7 @@ type EntityMapping struct { Identifier string `json:"identifier"` Title string `json:"title"` Blueprint string `json:"blueprint"` + Icon string `json:"icon,omitempty"` Team string `json:"team,omitempty"` Properties map[string]string `json:"properties,omitempty"` Relations map[string]string `json:"relations,omitempty"` From 1d1f8aeafd3196096775d7d0fd942d0aa502e0b9 Mon Sep 17 00:00:00 2001 From: OmriGez Date: Thu, 1 Feb 2024 15:07:35 +0200 Subject: [PATCH 2/8] typo --- pkg/defaults/defaults_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/defaults/defaults_test.go b/pkg/defaults/defaults_test.go index 1947644..444aa57 100644 --- a/pkg/defaults/defaults_test.go +++ b/pkg/defaults/defaults_test.go @@ -202,7 +202,7 @@ func Test_InitIntegration_DeprecatedResourcesConfiguration(t *testing.T) { { Kind: "workload", Port: port.Port{ - Entity: port.EntityMa§ppings{ + Entity: port.EntityMappings{ Mappings: []port.EntityMapping{ { Identifier: "workload", From f1bf9604e17785b16c6a442ce759a2220730ef07 Mon Sep 17 00:00:00 2001 From: OmriGez Date: Thu, 1 Feb 2024 15:13:42 +0200 Subject: [PATCH 3/8] update entity schema --- pkg/port/models.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/port/models.go b/pkg/port/models.go index c1ba627..f631be6 100644 --- a/pkg/port/models.go +++ b/pkg/port/models.go @@ -22,6 +22,7 @@ type ( Identifier string `json:"identifier,omitempty"` Title string `json:"title"` Blueprint string `json:"blueprint"` + Icon string `json:"icon,omitempty"` Team interface{} `json:"team,omitempty"` Properties map[string]interface{} `json:"properties"` Relations map[string]interface{} `json:"relations"` From 1a04f49f747149ad0be79568cb658d03c9089965 Mon Sep 17 00:00:00 2001 From: OmriGez Date: Thu, 1 Feb 2024 16:02:13 +0200 Subject: [PATCH 4/8] update entity schema --- pkg/defaults/defaults_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/defaults/defaults_test.go b/pkg/defaults/defaults_test.go index 444aa57..a9afb6c 100644 --- a/pkg/defaults/defaults_test.go +++ b/pkg/defaults/defaults_test.go @@ -205,11 +205,11 @@ func Test_InitIntegration_DeprecatedResourcesConfiguration(t *testing.T) { Entity: port.EntityMappings{ Mappings: []port.EntityMapping{ { - Identifier: "workload", - Title: "Workload", - Blueprint: "workload", + Identifier: "\"workload\"", + Title: "\"Workload\"", + Blueprint: "\"workload\"", Properties: map[string]string{ - "namespace": "default", + "namespace": "\"default\"", }, }, }, From 3d1c0af0928d3bff4a4d9c8f880e02df055d5839 Mon Sep 17 00:00:00 2001 From: OmriGez Date: Thu, 1 Feb 2024 16:57:02 +0200 Subject: [PATCH 5/8] updated test --- pkg/defaults/defaults_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/defaults/defaults_test.go b/pkg/defaults/defaults_test.go index a9afb6c..b12088d 100644 --- a/pkg/defaults/defaults_test.go +++ b/pkg/defaults/defaults_test.go @@ -208,6 +208,7 @@ func Test_InitIntegration_DeprecatedResourcesConfiguration(t *testing.T) { Identifier: "\"workload\"", Title: "\"Workload\"", Blueprint: "\"workload\"", + Icon: "\"Microservice\"", Properties: map[string]string{ "namespace": "\"default\"", }, From 4fc74e7d0a7f1117ec2d86c9a7b8d0c4618c994a Mon Sep 17 00:00:00 2001 From: OmriGez Date: Thu, 1 Feb 2024 17:17:51 +0200 Subject: [PATCH 6/8] controller test --- pkg/k8s/controller_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/k8s/controller_test.go b/pkg/k8s/controller_test.go index 78c8e37..37f5043 100644 --- a/pkg/k8s/controller_test.go +++ b/pkg/k8s/controller_test.go @@ -164,6 +164,7 @@ func TestCreateDeployment(t *testing.T) { { Identifier: ".metadata.name", Blueprint: "\"k8s-export-test-bp\"", + Icon: "\"AWS\"", Team: "\"Test\"", Properties: map[string]string{ "text": "\"pod\"", @@ -190,6 +191,7 @@ func TestUpdateDeployment(t *testing.T) { { Identifier: ".metadata.name", Blueprint: "\"k8s-export-test-bp\"", + Icon: "\"AWS\"", Team: "[\"Test\", \"Test2\"]", Properties: map[string]string{ "text": "\"pod\"", From 11e54be86548f09868d326c302ba28abfb58d350 Mon Sep 17 00:00:00 2001 From: OmriGez Date: Thu, 1 Feb 2024 17:40:30 +0200 Subject: [PATCH 7/8] removed typo --- pkg/k8s/controller_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/k8s/controller_test.go b/pkg/k8s/controller_test.go index 37f5043..5c25d7a 100644 --- a/pkg/k8s/controller_test.go +++ b/pkg/k8s/controller_test.go @@ -164,7 +164,7 @@ func TestCreateDeployment(t *testing.T) { { Identifier: ".metadata.name", Blueprint: "\"k8s-export-test-bp\"", - Icon: "\"AWS\"", + Icon: "\"Microservice\"", Team: "\"Test\"", Properties: map[string]string{ "text": "\"pod\"", @@ -191,7 +191,7 @@ func TestUpdateDeployment(t *testing.T) { { Identifier: ".metadata.name", Blueprint: "\"k8s-export-test-bp\"", - Icon: "\"AWS\"", + Icon: "\"Microservice\"", Team: "[\"Test\", \"Test2\"]", Properties: map[string]string{ "text": "\"pod\"", From 68875bef67b12f428dffd1635e4ea26ee052bbeb Mon Sep 17 00:00:00 2001 From: OmriGez Date: Thu, 1 Feb 2024 17:50:41 +0200 Subject: [PATCH 8/8] white spaces --- pkg/defaults/defaults_test.go | 2 +- pkg/k8s/controller_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/defaults/defaults_test.go b/pkg/defaults/defaults_test.go index b12088d..7a7c07e 100644 --- a/pkg/defaults/defaults_test.go +++ b/pkg/defaults/defaults_test.go @@ -208,7 +208,7 @@ func Test_InitIntegration_DeprecatedResourcesConfiguration(t *testing.T) { Identifier: "\"workload\"", Title: "\"Workload\"", Blueprint: "\"workload\"", - Icon: "\"Microservice\"", + Icon: "\"Microservice\"", Properties: map[string]string{ "namespace": "\"default\"", }, diff --git a/pkg/k8s/controller_test.go b/pkg/k8s/controller_test.go index 5c25d7a..7ab154c 100644 --- a/pkg/k8s/controller_test.go +++ b/pkg/k8s/controller_test.go @@ -164,7 +164,7 @@ func TestCreateDeployment(t *testing.T) { { Identifier: ".metadata.name", Blueprint: "\"k8s-export-test-bp\"", - Icon: "\"Microservice\"", + Icon: "\"Microservice\"", Team: "\"Test\"", Properties: map[string]string{ "text": "\"pod\"", @@ -191,7 +191,7 @@ func TestUpdateDeployment(t *testing.T) { { Identifier: ".metadata.name", Blueprint: "\"k8s-export-test-bp\"", - Icon: "\"Microservice\"", + Icon: "\"Microservice\"", Team: "[\"Test\", \"Test2\"]", Properties: map[string]string{ "text": "\"pod\"",