Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated mapping and schema to support icons #37

Merged
merged 8 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading