Skip to content

Commit

Permalink
updated mapping and schema to support icons (#37)
Browse files Browse the repository at this point in the history
* updated mapping and schema to support icons

* typo

* update entity schema

* update entity schema

* updated test

* controller test

* removed typo

* white spaces
  • Loading branch information
OmriGez authored Feb 1, 2024
1 parent 58b7a20 commit b24e223
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ 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\"",
Icon: "\"Microservice\"",
Properties: map[string]string{
"namespace": "default",
"namespace": "\"default\"",
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/k8s/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func TestCreateDeployment(t *testing.T) {
{
Identifier: ".metadata.name",
Blueprint: "\"k8s-export-test-bp\"",
Icon: "\"Microservice\"",
Team: "\"Test\"",
Properties: map[string]string{
"text": "\"pod\"",
Expand All @@ -190,6 +191,7 @@ func TestUpdateDeployment(t *testing.T) {
{
Identifier: ".metadata.name",
Blueprint: "\"k8s-export-test-bp\"",
Icon: "\"Microservice\"",
Team: "[\"Test\", \"Test2\"]",
Properties: map[string]string{
"text": "\"pod\"",
Expand Down
6 changes: 6 additions & 0 deletions pkg/port/mapping/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/port/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -181,6 +182,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"`
Expand Down

0 comments on commit b24e223

Please sign in to comment.