Skip to content

Commit

Permalink
Update configuration_metadata.go
Browse files Browse the repository at this point in the history
Support added for the configuration-properties.names property.
  • Loading branch information
AamnaZahid authored and anthonydahanne committed Oct 23, 2024
1 parent c031fd4 commit 00998bd
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions boot/configuration_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,34 +153,49 @@ func NewDataFlowConfigurationMetadata(path string, metadata ConfigurationMetadat
return ConfigurationMetadata{}, fmt.Errorf("unable to load properties from %s\n%w", file, err)
}

// Load classes
s, ok := p.Get("configuration-properties.classes")
if !ok {
return ConfigurationMetadata{}, nil
var classes []string
if ok {
for _, s := range strings.Split(s, ",") {
class := strings.TrimSpace(s)
if class != "" {
classes = append(classes, class)
}
}
}

var classes []string
for _, s := range strings.Split(s, ",") {
class := strings.TrimSpace(s)
if class == "" {
continue
// Load names
s, ok = p.Get("configuration-properties.names")
var names []string
if ok {
for _, s := range strings.Split(s, ",") {
name := strings.TrimSpace(s)
if name != "" {
names = append(names, name)
}
}
classes = append(classes, class)
}

// Merge classes and names
var combined []string
combined = append(combined, classes...)
combined = append(combined, names...)

m := ConfigurationMetadata{}

for _, g := range metadata.Groups {
for _, c := range classes {
if c == g.SourceType {
for _, c := range combined {
if c == g.SourceType || c == g.Name {
m.Groups = append(m.Groups, g)
break
}
}
}

for _, p := range metadata.Properties {
for _, c := range classes {
if c == p.SourceType {
for _, c := range combined {
if c == p.SourceType || c == p.Name {
m.Properties = append(m.Properties, p)
break
}
Expand Down

0 comments on commit 00998bd

Please sign in to comment.