From 80a5658bfcb797232f1245778b07b56a5d11a128 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Mon, 3 Jul 2023 12:51:49 +0545 Subject: [PATCH] fix: add labels to component spec (#1112) * add labels to component spec * chore: make test && make resources --- api/v1/component_types.go | 13 +++++++------ api/v1/zz_generated.deepcopy.go | 14 ++++++++++++++ config/deploy/crd.yaml | 8 ++++++++ config/deploy/manifests.yaml | 8 ++++++++ config/schemas/component.schema.json | 16 ++++++++++++++++ config/schemas/topology.schema.json | 16 ++++++++++++++++ pkg/system_api.go | 1 + 7 files changed, 70 insertions(+), 6 deletions(-) diff --git a/api/v1/component_types.go b/api/v1/component_types.go index 2b1c5caf3..899174bfc 100644 --- a/api/v1/component_types.go +++ b/api/v1/component_types.go @@ -18,12 +18,13 @@ type Component struct { } type ComponentSpec struct { - Name string `json:"name,omitempty"` - Tooltip string `json:"tooltip,omitempty"` - Icon string `json:"icon,omitempty"` - Owner string `json:"owner,omitempty"` - Id *Template `json:"id,omitempty"` //nolint - Order int `json:"order,omitempty"` + Name string `json:"name,omitempty"` + Tooltip string `json:"tooltip,omitempty"` + Icon string `json:"icon,omitempty"` + Owner string `json:"owner,omitempty"` + Id *Template `json:"id,omitempty"` //nolint + Order int `json:"order,omitempty"` + Labels map[string]string `json:"labels,omitempty"` // The type of component, e.g. service, API, website, library, database, etc. Type string `json:"type,omitempty"` // The lifecycle state of the component e.g. production, staging, dev, etc. diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 4e19aebf1..92c41197d 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -897,6 +897,13 @@ func (in *ComponentSpec) DeepCopyInto(out *ComponentSpec) { *out = new(Template) **out = **in } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.Relationships != nil { in, out := &in.Relationships, &out.Relationships *out = make([]RelationshipSpec, len(*in)) @@ -981,6 +988,13 @@ func (in *ComponentSpecObject) DeepCopyInto(out *ComponentSpecObject) { *out = new(Template) **out = **in } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.Relationships != nil { in, out := &in.Relationships, &out.Relationships *out = make([]RelationshipSpec, len(*in)) diff --git a/config/deploy/crd.yaml b/config/deploy/crd.yaml index 4653f81f0..3c97dc1ba 100644 --- a/config/deploy/crd.yaml +++ b/config/deploy/crd.yaml @@ -4019,6 +4019,10 @@ spec: template: type: string type: object + labels: + additionalProperties: + type: string + type: object lifecycle: description: The lifecycle state of the component e.g. production, staging, dev, etc. type: string @@ -4310,6 +4314,10 @@ spec: template: type: string type: object + labels: + additionalProperties: + type: string + type: object lifecycle: description: The lifecycle state of the component e.g. production, staging, dev, etc. type: string diff --git a/config/deploy/manifests.yaml b/config/deploy/manifests.yaml index ae2f36d78..cbb6b5316 100644 --- a/config/deploy/manifests.yaml +++ b/config/deploy/manifests.yaml @@ -4288,6 +4288,10 @@ spec: template: type: string type: object + labels: + additionalProperties: + type: string + type: object lifecycle: description: The lifecycle state of the component e.g. production, staging, dev, etc. type: string @@ -4579,6 +4583,10 @@ spec: template: type: string type: object + labels: + additionalProperties: + type: string + type: object lifecycle: description: The lifecycle state of the component e.g. production, staging, dev, etc. type: string diff --git a/config/schemas/component.schema.json b/config/schemas/component.schema.json index 8b8e2f68c..7bc0361e9 100644 --- a/config/schemas/component.schema.json +++ b/config/schemas/component.schema.json @@ -659,6 +659,14 @@ "order": { "type": "integer" }, + "labels": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, "type": { "type": "string" }, @@ -731,6 +739,14 @@ "order": { "type": "integer" }, + "labels": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, "type": { "type": "string" }, diff --git a/config/schemas/topology.schema.json b/config/schemas/topology.schema.json index daacb364b..628b6f8c5 100644 --- a/config/schemas/topology.schema.json +++ b/config/schemas/topology.schema.json @@ -638,6 +638,14 @@ "order": { "type": "integer" }, + "labels": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, "type": { "type": "string" }, @@ -710,6 +718,14 @@ "order": { "type": "integer" }, + "labels": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, "type": { "type": "string" }, diff --git a/pkg/system_api.go b/pkg/system_api.go index e819d8020..a743ef0cc 100644 --- a/pkg/system_api.go +++ b/pkg/system_api.go @@ -267,6 +267,7 @@ func NewComponent(c v1.ComponentSpec) *Component { Icon: c.Icon, Selectors: c.Selectors, ComponentChecks: c.ComponentChecks, + Labels: c.Labels, Configs: configs, LogSelectors: c.LogSelectors, }