Skip to content

Commit 20147c9

Browse files
Merge branch 'master' into enhancement/component-logging-details
2 parents eeed572 + 24699e7 commit 20147c9

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

converter/k8s.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func (k *K8sConverter) Convert(patternFile string) (string, error) {
1919
}
2020

2121
patterns.ProcessAnnotations(pattern)
22+
patterns.ProcessComponentStatus(pattern)
2223
return NewK8sManifestsFromPatternfile(pattern)
2324
}
2425

models/meshmodel/registry/v1beta1/component_filter.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,12 @@ func (componentFilter *ComponentFilter) Get(db *database.Handler) ([]entity.Enti
7272
Joins("JOIN category_dbs ON model_dbs.category_id = category_dbs.id").
7373
Joins("JOIN connections ON connections.id = model_dbs.connection_id")
7474

75-
// TODO(@MUzairS15): Refactor this once Status is made a first class field in ComponentFilter
76-
status := "enabled"
77-
78-
if componentFilter.Status != "" {
79-
status = componentFilter.Status
80-
}
81-
82-
finder = finder.Where("model_dbs.status = ?", status)
75+
componentStatus := "enabled"
76+
if componentFilter.Status != "" {
77+
componentStatus = componentFilter.Status
78+
}
79+
finder = finder.Where("component_definition_dbs.status = ?", componentStatus)
80+
8381
if componentFilter.Greedy {
8482
if componentFilter.Name != "" && componentFilter.DisplayName != "" {
8583
finder = finder.Where("component_definition_dbs.component->>'kind' LIKE ? OR display_name LIKE ?", "%"+componentFilter.Name+"%", componentFilter.DisplayName+"%")

models/patterns/pattern.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,19 @@ func ProcessAnnotations(pattern *pattern.PatternFile) {
4747
}
4848
pattern.Components = components
4949
}
50+
51+
func ProcessComponentStatus(pattern *pattern.PatternFile) {
52+
components := []*component.ComponentDefinition{}
53+
54+
hasComponentStatus := func(component *component.ComponentDefinition) bool {
55+
return component != nil && component.Status != nil
56+
}
57+
58+
for _, component := range pattern.Components {
59+
if hasComponentStatus(component) && string(*component.Status) == "ignored" {
60+
continue
61+
}
62+
components = append(components, component)
63+
}
64+
pattern.Components = components
65+
}

registry/component.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type ComponentCSV struct {
5959
func (c *ComponentCSV) CreateComponentDefinition(isModelPublished bool, defVersion string) (component.ComponentDefinition, error) {
6060
status := entity.Enabled
6161
if c.Status != "" {
62-
if utils.ReplaceSpacesAndConvertToLowercase(c.Status) == "false" {
62+
if utils.ReplaceSpacesAndConvertToLowercase(c.Status) == "ignored" {
6363
status = entity.Ignored
6464
}
6565
}
@@ -95,7 +95,7 @@ var compStyleValues = []string{
9595
func (c *ComponentCSV) UpdateCompDefinition(compDef *component.ComponentDefinition) error {
9696
status := entity.Enabled
9797
if c.Status != "" {
98-
if utils.ReplaceSpacesAndConvertToLowercase(c.Status) == "false" {
98+
if utils.ReplaceSpacesAndConvertToLowercase(c.Status) == "ignored" {
9999
status = entity.Ignored
100100
}
101101
}

utils/csv/csv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type CSV[E any] struct {
1616
reader *csv.Reader
1717
filePath string
1818
lineForColNo int
19-
// Stores the mapping for coumn name to golang equivalent attribute name.
19+
// Stores the mapping for column name to golang equivalent attribute name.
2020
// It is optional and default mapping is the lower case representation with spaces replaced with "_"
2121
// eg: ColumnnName: Descritption, equivalent golang attribute to which it will be mapped during unmarshal "description".
2222
columnToNameMapping map[string]string

0 commit comments

Comments
 (0)